FreeType_2.1.2 API Reference
Whole document tree
    

Whole document tree

FreeType_2.1.2 API Reference

FreeType_2.1.2 API Reference

Outline Processing

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      */

    FT_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


  typedef enum  FT_Outline_Flags_
  {
    ft_outline_none            = 0,
    ft_outline_owner           = 1,
    ft_outline_even_odd_fill   = 2,
    ft_outline_reverse_fill    = 4,
    ft_outline_ignore_dropouts = 8,
    ft_outline_high_precision  = 256,
    ft_outline_single_pass     = 512

  } FT_Outline_Flags;

A simple type used to enumerates the flags in an outline's `outline_flags' field.


fields
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( FT_Error )
  FT_Outline_New( FT_Library   library,
                  FT_UInt      numPoints,
                  FT_Int       numContours,
                  FT_Outline  *anoutline );


  FT_EXPORT( FT_Error )
  FT_Outline_New_Internal( FT_Memory    memory,
                           FT_UInt      numPoints,
                           FT_Int       numContours,
                           FT_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( FT_Error )
  FT_Outline_Done( FT_Library   library,
                   FT_Outline*  outline );


  FT_EXPORT( FT_Error )
  FT_Outline_Done_Internal( FT_Memory    memory,
                            FT_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( FT_Error )
  FT_Outline_Copy( FT_Outline*  source,
                   FT_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( FT_Outline*  outline,
                        FT_Pos       xOffset,
                        FT_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( FT_Outline*  outline,
                        FT_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_Reverse


  FT_EXPORT( void )
  FT_Outline_Reverse( FT_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( FT_Error )
  FT_Outline_Check( FT_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_CBox


  FT_EXPORT( void )
  FT_Outline_Get_CBox( FT_Outline*  outline,
                       FT_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_BBox


  FT_EXPORT( FT_Error )
  FT_Outline_Get_BBox( FT_Outline*  outline,
                       FT_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_Get_Bitmap


  FT_EXPORT( FT_Error )
  FT_Outline_Get_Bitmap( FT_Library   library,
                         FT_Outline*  outline,
                         FT_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( FT_Error )
  FT_Outline_Render( FT_Library         library,
                     FT_Outline*        outline,
                     FT_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_Outline_Decompose


  FT_EXPORT( FT_Error )
  FT_Outline_Decompose( FT_Outline*              outline,
                        const FT_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_Funcs


  typedef struct  FT_Outline_Funcs_
  {
    FT_Outline_MoveTo_Func   move_to;
    FT_Outline_LineTo_Func   line_to;
    FT_Outline_ConicTo_Func  conic_to;
    FT_Outline_CubicTo_Func  cubic_to;

    int                      shift;
    FT_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_MoveTo_Func


  typedef int
  (*FT_Outline_MoveTo_Func)( FT_Vector*  to,
                             void*       user );

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_LineTo_Func


  typedef int
  (*FT_Outline_LineTo_Func)( FT_Vector*  to,
                             void*       user );

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_ConicTo_Func


  typedef int
  (*FT_Outline_ConicTo_Func)( FT_Vector*  control,
                              FT_Vector*  to,
                              void*       user );

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_CubicTo_Func


  typedef int
  (*FT_Outline_CubicTo_Func)( FT_Vector*  control1,
                              FT_Vector*  control2,
                              FT_Vector*  to,
                              void*       user );

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.


generated on Sun Jun 23 13:01:54 2002