freetypy.LOAD¶
-
class
freetypy.
LOAD
¶ Indicates what to load for a 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).DEFAULT
: Corresponding to 0, this value is used as the default glyph load operation. In this case, the following happens:- FreeType looks for a bitmap for the glyph corresponding to the face’s current size. If one is found, the function returns. The bitmap data can be accessed from the glyph slot (see note below).
- If no embedded bitmap is searched or found, FreeType looks for a scalable outline. If one is found, it is loaded from the font file, scaled to device pixels, then ‘hinted’ to the pixel grid in order to optimize it. The outline data can be accessed from the glyph slot (see note below).
Note that by default, the glyph loader doesn’t render outlines into bitmaps. The following flags are used to modify this default behaviour to more specific and useful cases.
NO_SCALE
: Don’t scale the loaded outline glyph but keep it in font units.This flag implies
LOAD.NO_HINTING
andLOAD.NO_BITMAP
, and unsetsLOAD.RENDER
.If the font is ‘tricky’ (see
FACE_FLAG.TRICKY
for more), usingLOAD.NO_SCALE
usually yields meaningless outlines because the subglyphs must be scaled and positioned with hinting instructions. This can be solved by loading the font withoutLOAD.NO_SCALE
and setting the character size tounits_per_em
.NO_HINTING
: Disable hinting. This generally generates ‘blurrier’ bitmap glyphs when the glyph are rendered in any of the anti-aliased modes. See also the note below.This flag is implied by
LOAD.NO_SCALE
.RENDER
: Render after the glyph is loaded. By default, the glyph is rendered inRENDER_MODE.NORMAL
mode. This can be overridden byLOAD.TARGET_XXX
orLOAD.MONOCHROME
.This flag is unset by
LOAD.NO_SCALE
.NO_BITMAP
: Ignore bitmap strikes when loading. Bitmap-only fonts ignore this flag.LOAD.NO_SCALE
always sets this flag.VERTICAL_LAYOUT
: Load the glyph for vertical text layout. In particular, theadvance
value in theGlyph
object is set to thevert_advance
value of themetrics
field.In case
Face.has_vertical
doesn’t returnTrue
, you shouldn’t use this flag currently. Reason is that in this case vertical metrics get synthesized, and those values are not always consistent across various font formats.FORCE_AUTOHINT
: Indicates that the auto-hinter is preferred over the font’s native hinter. See also the note below.CROP_BITMAP
: Indicates that the font driver should crop the loaded bitmap glyph (i.e., remove all space around its black bits). Not all drivers implement this.PEDANTIC
: Indicates that the font driver should perform pedantic verifications during glyph loading. This is mostly used to detect broken glyphs in fonts. By default, FreeType tries to handle broken fonts also.In particular, errors from the TrueType bytecode engine are not passed to the application if this flag is not set; this might result in partially hinted or distorted glyphs in case a glyph’s bytecode is buggy.
NO_RECURSE
: This flag is only used internally. It merely indicates that the font driver should not load composite glyphs recursively. Instead, it should set thenum_subglyph
andsubglyphs
values of theGlyph
, and setGlyph.format
toGLYPH_FORMAT.COMPOSITE
.The description of sub-glyphs is not available to client applications for now.
This flag implies
LOAD.NO_SCALE
andLOAD.IGNORE_TRANSFORM
.IGNORE_TRANSFORM
: Indicates that the transform matrix set byFace.set_transform
should be ignored.MONOCHROME
: This flag is used withLOAD.RENDER
to indicate that you want to render an outline glyph to a 1-bit monochrome bitmap glyph, with 8 pixels packed into each byte of the bitmap data.Note that this has no effect on the hinting algorithm used. You should rather use
LOAD.TARGET_MONO
so that the monochrome-optimized hinting algorithm is used.LINEAR_DESIGN
: Indicates that thelinear_hori_advance
andlinear_vert_advance
fields ofGlyph
should be kept in font units. SeeGlyph
for details.NO_AUTOHINT
: Disable auto-hinter. See also the note below.
The following flags select a specific hinting algorithm to use by the hinter.
TARGET_NORMAL
: This corresponds to the default hinting algorithm, optimized for standard gray-level rendering. For monochrome output, useLOAD.TARGET_MONO
instead.TARGET_LIGHT
: A lighter hinting algorithm for non-monochrome modes. Many generated glyphs are more fuzzy but better resemble its original shape. A bit like rendering on Mac OS X.As a special exception, this target implies
LOAD.FORCE_AUTOHINT
.TARGET_MONO
: Strong hinting algorithm that should only be used for monochrome output. The result is probably unpleasant if the glyph is rendered in non-monochrome modes.TARGET_LCD
: A variant ofLOAD.TARGET_NORMAL
optimized for horizontally decimated LCD displays. On many FreeType builds, this functionality will be disabled due to patent restrictions, in which case the resulting bitmap will be grayscale.TARGET_LCD_V
: Strong hinting algorithm that should only be used for monochrome output. The result is probably unpleasant if the glyph is rendered in non-monochrome modes. On many freetype builds, this functionality will be disabled due to patent restrictions, in which case the resulting bitmap will be grayscale.
-
__init__
()¶ x.__init__(...) initializes x; see help(type(x)) for signature
Attributes