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:

    1. 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).
    2. 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 and LOAD.NO_BITMAP, and unsets LOAD.RENDER.

    If the font is ‘tricky’ (see FACE_FLAG.TRICKY for more), using LOAD.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 without LOAD.NO_SCALE and setting the character size to units_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 in RENDER_MODE.NORMAL mode. This can be overridden by LOAD.TARGET_XXX or LOAD.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, the advance value in the Glyph object is set to the vert_advance value of the metrics field.

    In case Face.has_vertical doesn’t return True, 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 the num_subglyph and subglyphs values of the Glyph, and set Glyph.format to GLYPH_FORMAT.COMPOSITE.

    The description of sub-glyphs is not available to client applications for now.

    This flag implies LOAD.NO_SCALE and LOAD.IGNORE_TRANSFORM.

  • IGNORE_TRANSFORM: Indicates that the transform matrix set by Face.set_transform should be ignored.

  • MONOCHROME: This flag is used with LOAD.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 the linear_hori_advance and linear_vert_advance fields of Glyph should be kept in font units. See Glyph 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, use LOAD.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 of LOAD.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

CROP_BITMAP
DEFAULT
FORCE_AUTOHINT
IGNORE_GLOBAL_ADVANCE_WIDTH
IGNORE_TRANSFORM
LINEAR_DESIGN
MONOCHROME
NO_AUTOHINT
NO_BITMAP
NO_HINTING
NO_RECURSE
NO_SCALE
PEDANTIC
RENDER
TARGET_LCD
TARGET_LCD_V
TARGET_LIGHT
TARGET_MONO
TARGET_NORMAL
VERTICAL_LAYOUT