FreeType-2.1.10 API Reference
Outline Processing
Synopsis
#FT_OutlineFT_Outline #FT_Outline_MoveToFuncFT_Outline_MoveToFunc #FT_OUTLINE_FLAGSFT_OUTLINE_FLAGS #FT_Outline_LineToFuncFT_Outline_LineToFunc #FT_Outline_NewFT_Outline_New #FT_Outline_ConicToFuncFT_Outline_ConicToFunc #FT_Outline_DoneFT_Outline_Done #FT_Outline_CubicToFuncFT_Outline_CubicToFunc #FT_Outline_CopyFT_Outline_Copy #FT_Outline_FuncsFT_Outline_Funcs #FT_Outline_TranslateFT_Outline_Translate #FT_Outline_DecomposeFT_Outline_Decompose #FT_Outline_TransformFT_Outline_Transform #FT_Outline_Get_CBoxFT_Outline_Get_CBox #FT_Outline_EmboldenFT_Outline_Embolden #FT_Outline_Get_BitmapFT_Outline_Get_Bitmap #FT_Outline_ReverseFT_Outline_Reverse #FT_Outline_RenderFT_Outline_Render #FT_Outline_CheckFT_Outline_Check #FT_OrientationFT_Orientation #FT_Outline_Get_BBoxFT_Outline_Get_BBox #FT_Outline_Get_OrientationFT_Outline_Get_Orientation #ft_outline_flagsft_outline_flags This section contains routines used to create and destroy scalable glyph images known as `outlines'. These can also be measured, transformed, and converted into bitmaps and pixmaps.
FT_Outline 
  
typedef struct  FT_Outline_
  {
    
short       n_contours;      /* number of contours in glyph        */
    
short       n_points;        /* number of points in the glyph      */
    
ft2-basic_types.html#FT_VectorFT_Vector *  points;          /* the outline's points               */
    
char*       tags;            /* the points flags                   */
    
short*      contours;        /* the contour end points             */
    
int         flags;           /* outline masks                      */
  } 
FT_Outline;
This structure is used to describe an outline to the scan-line converter.
fields n_contours The number of contours in the outline.
n_points The number of points in the outline.
points A pointer to an array of `n_points' FT_Vector elements, giving the outline's point coordinates.
tags A pointer to an array of `n_points' chars, giving each outline point's type. If bit 0 is unset, the point is `off' the curve, i.e. a Bezier control point, while it is `on' when set.
Bit 1 is meaningful for `off' points only. If set, it indicates a third-order Bezier arc control point; and a second-order control point if unset.
contours An array of `n_contours' shorts, giving the end point of each contour within the outline. For example, the first contour is defined by the points `0' to `contours[0]', the second one is defined by the points `contours[0]+1' to `contours[1]', etc.
flags A set of bit flags used to characterize the outline and give hints to the scan-converter and hinter on how to convert/grid-fit it. See FT_Outline_Flags.
FT_OUTLINE_FLAGS 
#define 
ft2-outline_processing.html#FT_OUTLINE_FLAGSFT_OUTLINE_NONE              0x0
#define 
ft2-outline_processing.html#FT_OUTLINE_FLAGSFT_OUTLINE_OWNER             0x1
#define 
ft2-outline_processing.html#FT_OUTLINE_FLAGSFT_OUTLINE_EVEN_ODD_FILL     0x2
#define 
ft2-outline_processing.html#FT_OUTLINE_FLAGSFT_OUTLINE_REVERSE_FILL      0x4
#define 
ft2-outline_processing.html#FT_OUTLINE_FLAGSFT_OUTLINE_IGNORE_DROPOUTS   0x8
#define 
ft2-outline_processing.html#FT_OUTLINE_FLAGSFT_OUTLINE_HIGH_PRECISION    0x100
#define 
ft2-outline_processing.html#FT_OUTLINE_FLAGSFT_OUTLINE_SINGLE_PASS       0x200
A list of bit-field constants use for the flags in an outline's `flags' field.
values FT_OUTLINE_NONE Value 0 is reserved.
FT_OUTLINE_OWNER If set, this flag indicates that the outline's field arrays (i.e. `points', `flags' & `contours') are `owned' by the outline object, and should thus be freed when it is destroyed.
FT_OUTLINE_EVEN_ODD_FILL By default, outlines are filled using the non-zero winding rule. If set to 1, the outline will be filled using the even-odd fill rule (only works with the smooth raster).
FT_OUTLINE_REVERSE_FILL By default, outside contours of an outline are oriented in clock-wise direction, as defined in the TrueType specification. This flag is set if the outline uses the opposite direction (typically for Type 1 fonts). This flag is ignored by the scan-converter. However, it is very important for the auto-hinter.
FT_OUTLINE_IGNORE_DROPOUTS By default, the scan converter will try to detect drop-outs in an outline and correct the glyph bitmap to ensure consistent shape continuity. If set, this flag hints the scan-line converter to ignore such cases.
FT_OUTLINE_HIGH_PRECISION This flag indicates that the scan-line converter should try to convert this outline to bitmaps with the highest possible quality. It is typically set for small character sizes. Note that this is only a hint, that might be completely ignored by a given scan-converter.
FT_OUTLINE_SINGLE_PASS This flag is set to force a given scan-converter to only use a single pass over the outline to render a bitmap glyph image. Normally, it is set for very large character sizes. It is only a hint, that might be completely ignored by a given scan-converter.
FT_Outline_New 
  FT_EXPORT( 
ft2-basic_types.html#FT_ErrorFT_Error  )
  
FT_Outline_New( ft2-base_interface.html#FT_LibraryFT_Library    library,
                  
ft2-basic_types.html#FT_UIntFT_UInt       numPoints,
                  
ft2-basic_types.html#FT_IntFT_Int        numContours,
                  
ft2-outline_processing.html#FT_OutlineFT_Outline   *anoutline );
  FT_EXPORT( 
ft2-basic_types.html#FT_ErrorFT_Error  )
  FT_Outline_New_Internal( 
ft2-system_interface.html#FT_MemoryFT_Memory     memory,
                           
ft2-basic_types.html#FT_UIntFT_UInt       numPoints,
                           
ft2-basic_types.html#FT_IntFT_Int        numContours,
                           
ft2-outline_processing.html#FT_OutlineFT_Outline   *anoutline );
Creates a new outline of a given size.
input library A handle to the library object from where the outline is allocated. Note however that the new outline will NOT necessarily be FREED, when destroying the library, by FT_Done_FreeType().
numPoints The maximal number of points within the outline.
numContours The maximal number of contours within the outline.
output anoutline A handle to the new outline. NULL in case of error.
return FreeType error code. 0 means success.
note The reason why this function takes a `library' parameter is simply to use the library's memory allocator.
FT_Outline_Done 
  FT_EXPORT( 
ft2-basic_types.html#FT_ErrorFT_Error  )
  
FT_Outline_Done( ft2-base_interface.html#FT_LibraryFT_Library    library,
                   
ft2-outline_processing.html#FT_OutlineFT_Outline *  outline );
  FT_EXPORT( 
ft2-basic_types.html#FT_ErrorFT_Error  )
  FT_Outline_Done_Internal( 
ft2-system_interface.html#FT_MemoryFT_Memory     memory,
                            
ft2-outline_processing.html#FT_OutlineFT_Outline *  outline );
Destroys an outline created with FT_Outline_New().
input library A handle of the library object used to allocate the outline.
outline A pointer to the outline object to be discarded.
return FreeType error code. 0 means success.
note If the outline's `owner' field is not set, only the outline descriptor will be released.
The reason why this function takes an `library' parameter is simply to use FT_Free().
FT_Outline_Copy 
  FT_EXPORT( 
ft2-basic_types.html#FT_ErrorFT_Error  )
  
FT_Outline_Copy( const ft2-outline_processing.html#FT_OutlineFT_Outline *  source,
                   
ft2-outline_processing.html#FT_OutlineFT_Outline         *target );
Copies an outline into another one. Both objects must have the same sizes (number of points & number of contours) when this function is called.
input source A handle to the source outline.
output target A handle to the target outline.
return FreeType error code. 0 means success.
FT_Outline_Translate 
  FT_EXPORT( 
void )
  
FT_Outline_Translate( const ft2-outline_processing.html#FT_OutlineFT_Outline *  outline,
                        
ft2-basic_types.html#FT_PosFT_Pos              xOffset,
                        
ft2-basic_types.html#FT_PosFT_Pos              yOffset );
Applies a simple translation to the points of an outline.
inout outline A pointer to the target outline descriptor.
input xOffset The horizontal offset.
yOffset The vertical offset.
FT_Outline_Transform 
  FT_EXPORT( 
void )
  
FT_Outline_Transform( const ft2-outline_processing.html#FT_OutlineFT_Outline *  outline,
                        
const ft2-basic_types.html#FT_MatrixFT_Matrix *   matrix );
Applies a simple 2x2 matrix to all of an outline's points. Useful for applying rotations, slanting, flipping, etc.
inout outline A pointer to the target outline descriptor.
input matrix A pointer to the transformation matrix.
note You can use FT_Outline_Translate() if you need to translate the outline's points.
FT_Outline_Embolden 
  FT_EXPORT_DEF( 
ft2-basic_types.html#FT_ErrorFT_Error  )
  
FT_Outline_Embolden( ft2-outline_processing.html#FT_OutlineFT_Outline *  outline,
                       
ft2-basic_types.html#FT_PosFT_Pos        strength );
Emboldens an outline. The new outline will be at most 4 times `strength' pixels wider and higher. You may think of the left and bottom borders as unchanged.
inout outline A handle to the target outline.
input strength How strong the glyph is emboldened. Expressed in 26.6 pixel format.
return FreeType error code. 0 means success.
FT_Outline_Reverse 
  FT_EXPORT( 
void )
  
FT_Outline_Reverse( ft2-outline_processing.html#FT_OutlineFT_Outline *  outline );
Reverses the drawing direction of an outline. This is used to ensure consistent fill conventions for mirrored glyphs.
inout outline A pointer to the target outline descriptor.
note This functions toggles the bit flag `FT_OUTLINE_REVERSE_FILL' in the outline's `flags' field.
It shouldn't be used by a normal client application, unless it knows what it is doing.
FT_Outline_Check 
  FT_EXPORT( 
ft2-basic_types.html#FT_ErrorFT_Error  )
  
FT_Outline_Check( ft2-outline_processing.html#FT_OutlineFT_Outline *  outline );
Check the contents of an outline descriptor.
input outline A handle to a source outline.
return FreeType error code. 0 means success.
FT_Outline_Get_BBox 
  FT_EXPORT( 
ft2-basic_types.html#FT_ErrorFT_Error  )
  
FT_Outline_Get_BBox( ft2-outline_processing.html#FT_OutlineFT_Outline *  outline,
                       
ft2-basic_types.html#FT_BBoxFT_BBox      *abbox );
Computes the exact bounding box of an outline. This is slower than computing the control box. However, it uses an advanced algorithm which returns very quickly when the two boxes coincide. Otherwise, the outline Bezier arcs are walked over to extract their extrema.
input outline A pointer to the source outline.
output abbox The outline's exact bounding box.
return FreeType error code. 0 means success.
ft_outline_flags 
#define 
ft2-outline_processing.html#ft_outline_flagsft_outline_none              ft2-outline_processing.html#FT_OUTLINE_FLAGSFT_OUTLINE_NONE #define 
ft2-outline_processing.html#ft_outline_flagsft_outline_owner             ft2-outline_processing.html#FT_OUTLINE_FLAGSFT_OUTLINE_OWNER #define 
ft2-outline_processing.html#ft_outline_flagsft_outline_even_odd_fill     ft2-outline_processing.html#FT_OUTLINE_FLAGSFT_OUTLINE_EVEN_ODD_FILL #define 
ft2-outline_processing.html#ft_outline_flagsft_outline_reverse_fill      ft2-outline_processing.html#FT_OUTLINE_FLAGSFT_OUTLINE_REVERSE_FILL #define 
ft2-outline_processing.html#ft_outline_flagsft_outline_ignore_dropouts   ft2-outline_processing.html#FT_OUTLINE_FLAGSFT_OUTLINE_IGNORE_DROPOUTS #define 
ft2-outline_processing.html#ft_outline_flagsft_outline_high_precision    ft2-outline_processing.html#FT_OUTLINE_FLAGSFT_OUTLINE_HIGH_PRECISION #define 
ft2-outline_processing.html#ft_outline_flagsft_outline_single_pass       ft2-outline_processing.html#FT_OUTLINE_FLAGSFT_OUTLINE_SINGLE_PASS These constants are deprecated. Please use the corresponding ft2-outline_processing.html#FT_OUTLINE_FLAGSFT_OUTLINE_FLAGS  values.
values ft_outline_none See ft2-outline_processing.html#FT_OUTLINE_FLAGSFT_OUTLINE_NONE .
ft_outline_owner See ft2-outline_processing.html#FT_OUTLINE_FLAGSFT_OUTLINE_OWNER .
ft_outline_even_odd_fill See ft2-outline_processing.html#FT_OUTLINE_FLAGSFT_OUTLINE_EVEN_ODD_FILL .
ft_outline_reverse_fill See ft2-outline_processing.html#FT_OUTLINE_FLAGSFT_OUTLINE_REVERSE_FILL .
ft_outline_ignore_dropouts See ft2-outline_processing.html#FT_OUTLINE_FLAGSFT_OUTLINE_IGNORE_DROPOUTS .
ft_outline_high_precision See ft2-outline_processing.html#FT_OUTLINE_FLAGSFT_OUTLINE_HIGH_PRECISION .
ft_outline_single_pass See ft2-outline_processing.html#FT_OUTLINE_FLAGSFT_OUTLINE_SINGLE_PASS .
FT_Outline_MoveToFunc 
  
typedef int  (*
FT_Outline_MoveToFunc)( ft2-basic_types.html#FT_VectorFT_Vector *  to,
                            
void*       user );
#define FT_Outline_MoveTo_Func  
FT_Outline_MoveToFunc A function pointer type used to describe the signature of a `move to' function during outline walking/decomposition.
A `move to' is emitted to start a new contour in an outline.
input to A pointer to the target point of the `move to'.
user A typeless pointer which is passed from the caller of the decomposition function.
return Error code. 0 means success.
FT_Outline_LineToFunc 
  
typedef int  (*
FT_Outline_LineToFunc)( ft2-basic_types.html#FT_VectorFT_Vector *  to,
                            
void*       user );
#define  FT_Outline_LineTo_Func  
FT_Outline_LineToFunc A function pointer type used to describe the signature of a `line to' function during outline walking/decomposition.
A `line to' is emitted to indicate a segment in the outline.
input to A pointer to the target point of the `line to'.
user A typeless pointer which is passed from the caller of the decomposition function.
return Error code. 0 means success.
FT_Outline_ConicToFunc 
  
typedef int  (*
FT_Outline_ConicToFunc)( ft2-basic_types.html#FT_VectorFT_Vector *  control,
                             
ft2-basic_types.html#FT_VectorFT_Vector *  to,
                             
void*       user );
#define  FT_Outline_ConicTo_Func  
FT_Outline_ConicToFunc A function pointer type use to describe the signature of a `conic to' function during outline walking/decomposition.
A `conic to' is emitted to indicate a second-order Bezier arc in the outline.
input control An intermediate control point between the last position and the new target in `to'.
to A pointer to the target end point of the conic arc.
user A typeless pointer which is passed from the caller of the decomposition function.
return Error code. 0 means success.
FT_Outline_CubicToFunc 
  
typedef int  (*
FT_Outline_CubicToFunc)( ft2-basic_types.html#FT_VectorFT_Vector *  control1,
                             
ft2-basic_types.html#FT_VectorFT_Vector *  control2,
                             
ft2-basic_types.html#FT_VectorFT_Vector *  to,
                             
void*       user );
#define  FT_Outline_CubicTo_Func  
FT_Outline_CubicToFunc A function pointer type used to describe the signature of a `cubic to' function during outline walking/decomposition.
A `cubic to' is emitted to indicate a third-order Bezier arc.
input control1 A pointer to the first Bezier control point.
control2 A pointer to the second Bezier control point.
to A pointer to the target end point.
user A typeless pointer which is passed from the caller of the decomposition function.
return Error code. 0 means success.
FT_Outline_Funcs 
  
typedef struct  FT_Outline_Funcs_
  {
    
ft2-outline_processing.html#FT_Outline_MoveToFuncFT_Outline_MoveToFunc    move_to;
    
ft2-outline_processing.html#FT_Outline_LineToFuncFT_Outline_LineToFunc    line_to;
    
ft2-outline_processing.html#FT_Outline_ConicToFuncFT_Outline_ConicToFunc   conic_to;
    
ft2-outline_processing.html#FT_Outline_CubicToFuncFT_Outline_CubicToFunc   cubic_to;
    
int                     shift;
    
ft2-basic_types.html#FT_PosFT_Pos                   delta;
  } 
FT_Outline_Funcs;
A structure to hold various function pointers used during outline decomposition in order to emit segments, conic, and cubic Beziers, as well as `move to' and `close to' operations.
fields move_to The `move to' emitter.
line_to The segment emitter.
conic_to The second-order Bezier arc emitter.
cubic_to The third-order Bezier arc emitter.
shift The shift that is applied to coordinates before they are sent to the emitter.
delta The delta that is applied to coordinates before they are sent to the emitter, but after the shift.
note The point coordinates sent to the emitters are the transformed version of the original coordinates (this is important for high accuracy during scan-conversion). The transformation is simple:
x' = (x << shift) - delta y' = (x << shift) - delta
Set the value of `shift' and `delta' to 0 to get the original point coordinates.
FT_Outline_Decompose 
  FT_EXPORT( 
ft2-basic_types.html#FT_ErrorFT_Error  )
  
FT_Outline_Decompose( ft2-outline_processing.html#FT_OutlineFT_Outline *              outline,
                        
const ft2-outline_processing.html#FT_Outline_FuncsFT_Outline_Funcs *  func_interface,
                        
void*                    user );
Walks over an outline's structure to decompose it into individual segments and Bezier arcs. This function is also able to emit `move to' and `close to' operations to indicate the start and end of new contours in the outline.
input outline A pointer to the source target.
func_interface A table of `emitters', i.e,. function pointers called during decomposition to indicate path operations.
inout user A typeless pointer which is passed to each emitter during the decomposition. It can be used to store the state during the decomposition.
return FreeType error code. 0 means sucess.
FT_Outline_Get_CBox 
  FT_EXPORT( 
void )
  
FT_Outline_Get_CBox( const ft2-outline_processing.html#FT_OutlineFT_Outline *  outline,
                       
ft2-basic_types.html#FT_BBoxFT_BBox            *acbox );
Returns an outline's `control box'. The control box encloses all the outline's points, including Bezier control points. Though it coincides with the exact bounding box for most glyphs, it can be slightly larger in some situations (like when rotating an outline which contains Bezier outside arcs).
Computing the control box is very fast, while getting the bounding box can take much more time as it needs to walk over all segments and arcs in the outline. To get the latter, you can use the `ftbbox' component which is dedicated to this single task.
input outline A pointer to the source outline descriptor.
output acbox The outline's control box.
FT_Outline_Get_Bitmap 
  FT_EXPORT( 
ft2-basic_types.html#FT_ErrorFT_Error  )
  
FT_Outline_Get_Bitmap( ft2-base_interface.html#FT_LibraryFT_Library         library,
                         
ft2-outline_processing.html#FT_OutlineFT_Outline *       outline,
                         
const ft2-basic_types.html#FT_BitmapFT_Bitmap   *abitmap );
Renders an outline within a bitmap. The outline's image is simply OR-ed to the target bitmap.
input library A handle to a FreeType library object.
outline A pointer to the source outline descriptor.
output abitmap A pointer to the target bitmap descriptor.
return FreeType error code. 0 means success.
note This function does NOT CREATE the bitmap, it only renders an outline image within the one you pass to it!
It will use the raster correponding to the default glyph format.
FT_Outline_Render 
  FT_EXPORT( 
ft2-basic_types.html#FT_ErrorFT_Error  )
  
FT_Outline_Render( ft2-base_interface.html#FT_LibraryFT_Library          library,
                     
ft2-outline_processing.html#FT_OutlineFT_Outline *        outline,
                     
ft2-raster.html#FT_Raster_ParamsFT_Raster_Params *  params );
Renders an outline within a bitmap using the current scan-convert. This functions uses an FT_Raster_Params structure as an argument, allowing advanced features like direct composition, translucency, etc.
input library A handle to a FreeType library object.
outline A pointer to the source outline descriptor.
inout params A pointer to a FT_Raster_Params structure used to describe the rendering operation.
return FreeType error code. 0 means success.
note You should know what you are doing and how FT_Raster_Params works to use this function.
The field `params.source' will be set to `outline' before the scan converter is called, which means that the value you give to it is actually ignored.
FT_Orientation 
  
typedef enum  {
    
ft2-outline_processing.html#FT_OrientationFT_ORIENTATION_TRUETYPE    = 0,
    
ft2-outline_processing.html#FT_OrientationFT_ORIENTATION_POSTSCRIPT  = 1,
    
ft2-outline_processing.html#FT_OrientationFT_ORIENTATION_FILL_RIGHT  = ft2-outline_processing.html#FT_OrientationFT_ORIENTATION_TRUETYPE ,
    
ft2-outline_processing.html#FT_OrientationFT_ORIENTATION_FILL_LEFT   = ft2-outline_processing.html#FT_OrientationFT_ORIENTATION_POSTSCRIPT   
  } 
FT_Orientation;
A list of values used to describe an outline's contour orientation.
The TrueType and Postscript specifications use different conventions to determine whether outline contours should be filled or unfilled.
values FT_ORIENTATION_TRUETYPE According to the TrueType specification, clockwise contours must be filled, and counter-clockwise ones must be unfilled.
FT_ORIENTATION_POSTSCRIPT According to the Postscript specification, counter-clockwise contours must be filled, and clockwise ones must be unfilled.
FT_ORIENTATION_FILL_RIGHT This is identical to ft2-outline_processing.html#FT_OrientationFT_ORIENTATION_TRUETYPE , but is used to remember that in TrueType, everything that is to the right of the drawing direction of a contour must be filled.
FT_ORIENTATION_FILL_LEFT This is identical to ft2-outline_processing.html#FT_OrientationFT_ORIENTATION_POSTSCRIPT , but is used to remember that in Postscript, everything that is to the left of the drawing direction of a contour must be filled.
FT_Outline_Get_Orientation 
  FT_EXPORT( 
ft2-outline_processing.html#FT_OrientationFT_Orientation  )
  
FT_Outline_Get_Orientation( ft2-outline_processing.html#FT_OutlineFT_Outline *  outline );
This function analyzes a glyph outline and tries to compute its fill orientation (see ft2-outline_processing.html#FT_OrientationFT_Orientation ). This is done by computing the direction of each global horizontal and/or vertical extrema within the outline.
Note that this will return ft2-outline_processing.html#FT_OrientationFT_ORIENTATION_TRUETYPE  for empty outlines.
input outline A handle to the source outline.
return The orientation.
