Experimental only
The auto-hinter provides various script modules to hint glyphs. Examples of supported scripts are Latin or CJK. Before a glyph is auto-hinted, the Unicode character map of the font gets examined, and the script is then determined based on Unicode character ranges, see below.
OpenType fonts, however, often provide much more glyphs than character codes (small caps, superscripts, ligatures, swashes, etc.), to be controlled by so-called ‘features’. Handling OpenType features can be quite complicated and thus needs a separate library on top of FreeType.
The mapping between glyph indices and scripts (in the auto-hinter sense, see the FT_AUTOHINTER_SCRIPT_XXX values) is stored as an array with ‘num_glyphs’ elements, as found in the font's FT_Face structure. The ‘glyph-to-script-map’ property returns a pointer to this array which can be modified as needed. Note that the modification should happen before the first glyph gets processed by the auto-hinter so that the global analysis of the font shapes actually uses the modified mapping.
The following example code demonstrates how to access it (omitting the error handling).
FT_Library library;
FT_Face face;
FT_Prop_GlyphToScriptMap prop;
FT_Init_FreeType( &library );
FT_New_Face( library, "foo.ttf", 0, &face );
prop.face = face;
FT_Property_Get( library, "autofitter",
"glyph-to-script-map", &prop );
// adjust `prop.map' as needed right here
FT_Load_Glyph( face, ..., FT_LOAD_FORCE_AUTOHINT );
|