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
LOAD
constants 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 – The loaded
Glyph
.Return type: 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_HINTING
or change the precedence by settingLOAD.FORCE_AUTOHINT
. You can also setLOAD.NO_AUTOHINT
in case you don’t want the auto-hinter to be used at all.See the description of
FACE_FLAG.TRICKY
for 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_XXX
constants 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 char 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_transform
for the details.For subsetted CID-keyed fonts, a
ValueError
exception 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_KEYED
flag for more details.You should use only one of the
LOAD
TARGET_XXX
values in yourload_flags
. They can’t be OR’ed.If
LOAD.RENDER
is also set, the glyph is rendered in the corresponding mode (i.e., the mode which matches the used algorithm best). An exception isLOAD.TARGET_MONO
since it impliesLOAD.MONOCHROME
.