freetypy.LOAD¶
-
class
freetypy.LOAD¶ 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).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_HINTINGandLOAD.NO_BITMAP, and unsetsLOAD.RENDER.If the font is ‘tricky’ (see
FACE_FLAG.TRICKYfor more), usingLOAD.NO_SCALEusually yields meaningless outlines because the subglyphs must be scaled and positioned with hinting instructions. This can be solved by loading the font withoutLOAD.NO_SCALEand 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.NORMALmode. This can be overridden byLOAD.TARGET_XXXorLOAD.MONOCHROME.This flag is unset by
LOAD.NO_SCALE.NO_BITMAP: Ignore bitmap strikes when loading. Bitmap-only fonts ignore this flag.LOAD.NO_SCALEalways sets this flag.VERTICAL_LAYOUT: Load the glyph for vertical text layout. In particular, theadvancevalue in theGlyphobject is set to thevert_advancevalue of themetricsfield.In case
Face.has_verticaldoesn’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_subglyphandsubglyphsvalues of theGlyph, and setGlyph.formattoGLYPH_FORMAT.COMPOSITE.The description of sub-glyphs is not available to client applications for now.
This flag implies
LOAD.NO_SCALEandLOAD.IGNORE_TRANSFORM.IGNORE_TRANSFORM: Indicates that the transform matrix set byFace.set_transformshould be ignored.MONOCHROME: This flag is used withLOAD.RENDERto 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_MONOso that the monochrome-optimized hinting algorithm is used.LINEAR_DESIGN: Indicates that thelinear_hori_advanceandlinear_vert_advancefields ofGlyphshould be kept in font units. SeeGlyphfor 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_MONOinstead.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_NORMALoptimized 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.
Attributes
CROP_BITMAPDEFAULTFORCE_AUTOHINTIGNORE_GLOBAL_ADVANCE_WIDTHIGNORE_TRANSFORMLINEAR_DESIGNMONOCHROMENO_AUTOHINTNO_BITMAPNO_HINTINGNO_RECURSENO_SCALEPEDANTICRENDERTARGET_LCDTARGET_LCD_VTARGET_LIGHTTARGET_MONOTARGET_NORMALVERTICAL_LAYOUT