freetypy.Face.load_glyph¶
-
Face.load_glyph()¶ Load a single glyph.
Parameters: glyph_index : int
The index of the glyph in the font file. For CID-keyed fonts (either in PS or in CFF format) this argument specifies the CID value.
load_flags : int, optional
A flag indicating what to load for this glyph. The
LOADconstants can be used to control the glyph loading process (e.g., whether the outline should be scaled, whether to load bitmaps or not, whether to hint the outline, etc).Returns: glyph : Glyph
The loaded
Glyph.Notes
By default, hinting is enabled and the font’s native hinter (see
FACE_FLAG.HINTER) is preferred over the auto-hinter. You can disable hinting by settingLOAD.NO_HINTINGor change the precedence by settingLOAD.FORCE_AUTOHINT. You can also setLOAD.NO_AUTOHINTin case you don’t want the auto-hinter to be used at all.See the description of
FACE_FLAG.TRICKYfor a special exception (affecting only a handful of Asian fonts).Besides deciding which hinter to use, you can also decide which hinting algorithm to use. See
LOAD’sTARGET_XXXconstants for details.Note that the auto-hinter needs a valid Unicode cmap (either a native one or synthesized by FreeType) for producing correct results. If a font provides an incorrect mapping (for example, assigning the character code U+005A, LATIN CAPITAL LETTER Z, to a glyph depicting a mathematical integral sign), the auto-hinter might produce useless results.
The loaded glyph may be transformed. See
set_transformfor the details.For subsetted CID-keyed fonts, a
ValueErrorexception is thrown for invalid CID values (this is, for CID values which don’t have a corresponding glyph in the font). See the discussion of theFACE_FLAG.CID_KEYEDflag for more details.You should use only one of the
LOADTARGET_XXXvalues in yourload_flags. They can’t be OR’ed.If
LOAD.RENDERis also set, the glyph is rendered in the corresponding mode (i.e., the mode which matches the used algorithm best). An exception isLOAD.TARGET_MONOsince it impliesLOAD.MONOCHROME.