FreeType-2.2.1 API Reference

Incremental Loading

Synopsis

FT_IncrementalFT_Incremental_InterfaceRec
FT_Incremental_MetricsFT_Incremental_Interface
FT_Incremental_GetGlyphDataFuncFT_PARAM_TAG_INCREMENTAL
FT_Incremental_FreeGlyphDataFuncFT_Library_SetLcdFilter
FT_Incremental_GetGlyphMetricsFuncFT_LCD_FILTER_XXX
FT_Incremental_FuncsRec


This section contains various functions used to perform so-called ‘incremental’ glyph loading. This is a mode where all glyphs loaded from a given FT_Face are provided by the client application,

Apart from that, all other tables are loaded normally from the font file. This mode is useful when FreeType is used within another engine, e.g., a Postscript Imaging Processor.

To enable this mode, you must use FT_Open_Face, passing an FT_Parameter with the FT_PARAM_TAG_INCREMENTAL tag and an FT_Incremental_Interface value. See the comments for FT_Incremental_InterfaceRec for an example.


FT_Incremental


  typedef struct FT_IncrementalRec_*  FT_Incremental;


An opaque type describing a user-provided object used to implement ‘incremental’ glyph loading within FreeType. This is used to support embedded fonts in certain environments (e.g., Postscript interpreters), where the glyph data isn't in the font file, or must be overridden by different values.


note

It is up to client applications to create and implement FT_Incremental objects, as long as they provide implementations for the methods FT_Incremental_GetGlyphDataFunc, FT_Incremental_FreeGlyphDataFunc and FT_Incremental_GetGlyphMetricsFunc.

See the description of FT_Incremental_InterfaceRec to understand how to use incremental objects with FreeType.


[Index] [TOC]

FT_Incremental_Metrics


  typedef struct  FT_Incremental_MetricsRec_
  {
    FT_Long  bearing_x;
    FT_Long  bearing_y;
    FT_Long  advance;

  } FT_Incremental_MetricsRec, *FT_Incremental_Metrics;


A small structure used to contain the basic glyph metrics returned by the FT_Incremental_GetGlyphMetricsFunc method.


fields
bearing_x

Left bearing, in font units.

bearing_y

Top bearing, in font units.

advance

Glyph advance, in font units.

note

These correspond to horizontal or vertical metrics depending on the value of the ‘vertical’ argument to the function FT_Incremental_GetGlyphMetricsFunc.


[Index] [TOC]

FT_Incremental_GetGlyphDataFunc


  typedef FT_Error
  (*FT_Incremental_GetGlyphDataFunc)( FT_Incremental  incremental,
                                      FT_UInt         glyph_index,
                                      FT_Data*        adata );


A function called by FreeType to access a given glyph's data bytes during FT_Load_Glyph or FT_Load_Char if incremental loading is enabled.

Note that the format of the glyph's data bytes depends on the font file format. For TrueType, it must correspond to the raw bytes within the ‘glyf’ table. For Postscript formats, it must correspond to the unencrypted charstring bytes, without any ‘lenIV’ header. It is undefined for any other format.


input
incremental

Handle to an opaque FT_Incremental handle provided by the client application.

glyph_index

Index of relevant glyph.

output
adata

A structure describing the returned glyph data bytes (which will be accessed as a read-only byte block).

return

FreeType error code. 0 means success.

note

If this function returns succesfully the method FT_Incremental_FreeGlyphDataFunc will be called later to release the data bytes.

Nested calls to FT_Incremental_GetGlyphDataFunc can happen for compound glyphs.


[Index] [TOC]

FT_Incremental_FreeGlyphDataFunc


  typedef void
  (*FT_Incremental_FreeGlyphDataFunc)( FT_Incremental  incremental,
                                       FT_Data*        data );


A function used to release the glyph data bytes returned by a successful call to FT_Incremental_GetGlyphDataFunc.


input
incremental

A handle to an opaque FT_Incremental handle provided by the client application.

data

A structure describing the glyph data bytes (which will be accessed as a read-only byte block).


[Index] [TOC]

FT_Incremental_GetGlyphMetricsFunc


  typedef FT_Error
  (*FT_Incremental_GetGlyphMetricsFunc)
                      ( FT_Incremental              incremental,
                        FT_UInt                     glyph_index,
                        FT_Bool                     vertical,
                        FT_Incremental_MetricsRec  *ametrics );


A function used to retrieve the basic metrics of a given glyph index before accessing its data. This is necessary because, in certain formats like TrueType, the metrics are stored in a different place from the glyph images proper.


input
incremental

A handle to an opaque FT_Incremental handle provided by the client application.

glyph_index

Index of relevant glyph.

vertical

If true, return vertical metrics.

ametrics

This parameter is used for both input and output. The original glyph metrics, if any, in font units. If metrics are not available all the values must be set to zero.

output
ametrics

The replacement glyph metrics in font units.


[Index] [TOC]

FT_Incremental_FuncsRec


  typedef struct  FT_Incremental_FuncsRec_
  {
    FT_Incremental_GetGlyphDataFunc     get_glyph_data;
    FT_Incremental_FreeGlyphDataFunc    free_glyph_data;
    FT_Incremental_GetGlyphMetricsFunc  get_glyph_metrics;

  } FT_Incremental_FuncsRec;


A table of functions for accessing fonts that load data incrementally. Used in FT_Incremental_InterfaceRec.


fields
get_glyph_data

The function to get glyph data. Must not be null.

free_glyph_data

The function to release glyph data. Must not be null.

get_glyph_metrics

The function to get glyph metrics. May be null if the font does not provide overriding glyph metrics.


[Index] [TOC]

FT_Incremental_InterfaceRec


  typedef struct  FT_Incremental_InterfaceRec_
  {
    const FT_Incremental_FuncsRec*  funcs;
    FT_Incremental                  object;
  
  } FT_Incremental_InterfaceRec;


A structure to be used with FT_Open_Face to indicate that the user wants to support incremental glyph loading. You should use it with FT_PARAM_TAG_INCREMENTAL as in the following example:

  FT_Incremental_InterfaceRec  inc_int;
  FT_Parameter                 parameter;
  FT_Open_Args                 open_args;


  // set up incremental descriptor
  inc_int.funcs  = my_funcs;
  inc_int.object = my_object;

  // set up optional parameter
  parameter.tag  = FT_PARAM_TAG_INCREMENTAL;
  parameter.data = &inc_int;

  // set up FT_Open_Args structure
  open_args.flags      = FT_OPEN_PATHNAME | FT_OPEN_PARAMS;
  open_args.pathname   = my_font_pathname;
  open_args.num_params = 1;
  open_args.params     = &parameter; // we use one optional argument

  // open the font
  error = FT_Open_Face( library, &open_args, index, &face );
  ...


[Index] [TOC]

FT_Incremental_Interface


  typedef FT_Incremental_InterfaceRec*   FT_Incremental_Interface;


A pointer to an FT_Incremental_InterfaceRec structure.



[Index] [TOC]

FT_PARAM_TAG_INCREMENTAL


#define FT_PARAM_TAG_INCREMENTAL  FT_MAKE_TAG( 'i', 'n', 'c', 'r' )


A constant used as the tag of FT_Parameter structures to indicate an incremental loading object to be used by FreeType.



[Index] [TOC]

FT_Library_SetLcdFilter


  FT_EXPORT( FT_Error )
  FT_Library_SetLcdFilter( FT_Library      library,
                           const FT_Byte*  filter_weights );


This function is used to apply color filtering to LCD decimated bitmaps, like the ones used when calling FT_Render_Glyph with FT_RENDER_MODE_LCD or FT_RENDER_MODE_LCD_V.


input
library

A handle to the target library instance.

filter_weights

A pointer to an array of 5 bytes corresponding to the weights of a 5-tap FIR filter. Each weight must be positive, and their sum should be at least 256 to avoid loss of darkness in the rendered glyphs. The sum can be greater than 256 to darken the glyphs (‘el-cheapo gamma’).

You can use FT_LCD_FILTER_NONE here to disable this feature, or FT_LCD_FILTER_DEFAULT to use a default filter that should work well on most LCD screens.

return

FreeType error code. 0 means success.

note

This feature is always disabled by default. Clients must make an explicit call to this function with a ‘filter_weights’ value other than FT_LCD_FILTER_NONE in order to enable it.

Due to PATENTS covering subpixel rendering, this function doesn't do anything except returning ?FT_Err_Unimplemented_Feature? if the configuration macro FT_CONFIG_OPTION_SUBPIXEL_RENDERING is not defined in your build of the library, which should correspond to all default builds of the library.

The filter affects glyph bitmaps rendered through FT_Render_Glyph, ??@FT_Glyph_Get_Bitmap, FT_Load_Glyph, and FT_Load_Char.

It does not affect the output of FT_Outline_Render and FT_Outline_Get_Bitmap.

If this feature is activated, the dimensions of LCD glyph bitmaps are either larger or taller than the dimensions of the corresponding outline with regards to the pixel grid. For example, for FT_RENDER_MODE_LCD, the filter adds up to 3 pixels to the left, and up to 3 pixels to the right.

The bitmap offset values are adjusted correctly, so clients shouldn't need to modify their layout and glyph positioning code when enabling the filter.


[Index] [TOC]

FT_LCD_FILTER_XXX


#define FT_LCD_FILTER_NONE     ( (const FT_Byte*)NULL )
 
#define FT_LCD_FILTER_DEFAULT  ( (const FT_Byte*)(void*)(ft_ptrdiff_t)1 )


A list of constants which correspond to useful lcd filter settings for the FT_Library_SetLcdFilter function.


values
FT_LCD_FILTER_NONE

The value NULL is reserved to indicate that LCD color filtering should be disabled.

FT_LCD_FILTER_DEFAULT

This value is reserved to indicate a default FIR filter that should work well on most LCD screen. It corresponds to the array 0x10, 0x40, 0x70, 0x40, 0x10.


[Index] [TOC]