### Load Font and Get Bitmap Buffer with freetype-py Source: https://freetype-py.readthedocs.io/en/latest/_sources/usage.rst This snippet shows how to use the freetype-py library to open a TrueType font file, set the character size, load a specific character, and access its bitmap data. ```python import freetype face = freetype.Face("Vera.ttf") face.set_char_size( 48*64 ) face.load_char('S') bitmap = face.glyph.bitmap print bitmap.buffer ``` -------------------------------- ### freetype-py API Overview Source: https://freetype-py.readthedocs.io/en/latest/api This section outlines the primary components and constants available in the freetype-py library. ```APIDOC ## freetype-py API Overview ### Description This document outlines the primary components and constants available in the freetype-py library for font manipulation and rendering. ### Components - **Face**: Represents a font face. - **BBox**: Bounding box information. - **Size Metrics**: Font size metrics. - **Bitmap size**: Size of a bitmap. - **Bitmap**: Bitmap data. - **Charmap**: Character map. - **Outline**: Font outline data. - **Glyph**: Glyph information. - **Bitmap glyph**: Bitmap representation of a glyph. - **Glyph slot**: A slot for holding glyphs. - **SFNT name**: SFNT font name information. - **Stroker**: Outline stroking utility. ### Constants The library exposes numerous constants for various configurations and flags: - **FT_ENCODINGS**: Font encoding types. - **FT_FACE_FLAGS**: Flags for font face properties. - **FT_FSTYPES**: Font types. - **FT_GLYPH_BBOX_MODES**: Bounding box modes. - **FT_GLYPH_FORMATS**: Glyph formats. - **FT_KERNING_MODES**: Kerning modes. - **FT_LCD_FILTERS**: LCD filtering modes. - **FT_LOAD_FLAGS**: Flags for loading glyphs. - **FT_LOAD_TARGETS**: Targets for loading glyphs. - **FT_OPEN_MODES**: Modes for opening fonts. - **FT_OUTLINE_FLAGS**: Flags for outline data. - **FT_PIXEL_MODES**: Pixel modes for bitmaps. - **FT_RENDER_MODES**: Rendering modes. - **FT_STROKER_BORDERS**: Stroker border types. - **FT_STROKER_LINECAPS**: Stroker line cap styles. - **FT_STROKER_LINEJOINS**: Stroker line join styles. - **FT_STYLE_FLAGS**: Style flags for fonts. - **TT_ADOBE_IDS**: Adobe specific IDs. - **TT_APPLE_IDS**: Apple specific IDs. - **TT_MAC_IDS**: Macintosh specific IDs. - **TT_MAC_LANGIDS**: Macintosh language IDs. - **TT_MS_IDS**: Microsoft specific IDs. - **TT_MS_LANGIDS**: Microsoft language IDs. - **TT_NAME_IDS**: TrueType name IDs. - **TT_PLATFORMS**: Platform IDs for font names. ### Usage Refer to the 'Usage example' section for practical application of these components and constants. ``` -------------------------------- ### FT_OPEN_MODES Constants Source: https://freetype-py.readthedocs.io/en/latest/_sources/ft_open_modes.rst Details of the bit-field constants used within the 'flags' field of the FT_Open_Args structure. ```APIDOC ## FT_OPEN_MODES Constants ### Description A list of bit-field constants used within the 'flags' field of the FT_Open_Args structure. ### Parameters #### Query Parameters - **FT_OPEN_MEMORY** (constant) - Used to indicate a memory-based stream. - **FT_OPEN_STREAM** (constant) - Used to copy the stream from the 'stream' field. - **FT_OPEN_PATHNAME** (constant) - Used to create a new input stream from a C path name. - **FT_OPEN_DRIVER** (constant) - Used to specify the 'driver' field. - **FT_OPEN_PARAMS** (constant) - Used to specify the 'num_params' and 'params' fields. ### Request Example ```json { "flags": "FT_OPEN_MEMORY | FT_OPEN_STREAM" } ``` ### Response #### Success Response (200) This documentation describes constants and does not involve a direct API request/response. The constants are used as parameters in other FreeType API calls. #### Response Example N/A ``` -------------------------------- ### Face Class Documentation Source: https://freetype-py.readthedocs.io/en/latest/_sources/face.rst Provides documentation for the Face class, which represents a font face in FreeType. It includes information about its members and methods for font manipulation. ```APIDOC ## Face Class ### Description The `Face` class represents a font face in the FreeType library. It allows access to various font properties and glyph information. ### Members This class has members that provide access to font metrics, glyph data, and transformation matrices. Refer to the FreeType library documentation for specific member details. ### Methods The `Face` class provides methods for loading characters, rendering glyphs, and querying font metrics. Refer to the FreeType library documentation for specific method details. ``` -------------------------------- ### FT_RENDER_MODES Enumeration Source: https://freetype-py.readthedocs.io/en/latest/_sources/ft_render_modes.rst Overview of the FT_RENDER_MODES enumeration, which defines how glyph outlines are converted into bitmaps. It details the various modes and their characteristics, such as anti-aliasing levels and sub-pixel rendering support. ```APIDOC ## FT_RENDER_MODES Enumeration ### Description An enumeration type that lists the render modes supported by FreeType 2. Each mode corresponds to a specific type of scanline conversion performed on the outline. For bitmap fonts and embedded bitmaps, the 'bitmap->pixel_mode' field in the `FT_GlyphSlotRec` structure gives the format of the returned bitmap. All modes except `FT_RENDER_MODE_MONO` use 256 levels of opacity. ### Render Modes - **FT_RENDER_MODE_NORMAL** - **Description**: This is the default render mode; it corresponds to 8-bit anti-aliased bitmaps. - **FT_RENDER_MODE_LIGHT** - **Description**: This is equivalent to `FT_RENDER_MODE_NORMAL`. It is only defined as a separate value because render modes are also used indirectly to define hinting algorithm selectors. See `FT_LOAD_TARGET_XXX` for details. - **FT_RENDER_MODE_MONO** - **Description**: This mode corresponds to 1-bit bitmaps (with 2 levels of opacity). - **FT_RENDER_MODE_LCD** - **Description**: This mode corresponds to horizontal RGB and BGR sub-pixel displays like LCD screens. It produces 8-bit bitmaps that are 3 times the width of the original glyph outline in pixels, and which use the `FT_PIXEL_MODE_LCD` mode. - **FT_RENDER_MODE_LCD_V** - **Description**: This mode corresponds to vertical RGB and BGR sub-pixel displays (like PDA screens, rotated LCD displays, etc.). It produces 8-bit bitmaps that are 3 times the height of the original glyph outline in pixels and use the `FT_PIXEL_MODE_LCD_V` mode. ``` -------------------------------- ### FT_GLYPH_BBOX_MODES Source: https://freetype-py.readthedocs.io/en/latest/_sources/ft_glyph_bbox_modes.rst Describes the different modes for the FT_Glyph_Get_CBox function, specifying how the bounding box values are returned. ```APIDOC ## FT_GLYPH_BBOX_MODES ### Description Specifies the mode by which the values of `FT_Glyph_Get_CBox` are returned. ### Method N/A (Data Enum) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response #### Success Response (Enum Values) - **FT_GLYPH_BBOX_UNSCALED** (enum) - Returns unscaled font units. - **FT_GLYPH_BBOX_SUBPIXELS** (enum) - Returns unfitted 26.6 coordinates. - **FT_GLYPH_BBOX_GRIDFIT** (enum) - Returns grid-fitted 26.6 coordinates. - **FT_GLYPH_BBOX_TRUNCATE** (enum) - Returns coordinates in integer pixels. - **FT_GLYPH_BBOX_PIXELS** (enum) - Returns grid-fitted pixel coordinates. #### Response Example N/A ``` -------------------------------- ### FT_PIXEL_MODES Enumeration Details Source: https://freetype-py.readthedocs.io/en/latest/ft_pixel_modes This section describes the different pixel modes available in the FT_PIXEL_MODES enumeration. ```APIDOC ## FT_PIXEL_MODES Enumeration ### Description An enumeration type that lists the render modes supported by FreeType 2. Each mode corresponds to a specific type of scanline conversion performed on the outline. ### Enumeration Values - **FT_PIXEL_MODE_NONE** - Value: 0 - Description: Reserved. - **FT_PIXEL_MODE_MONO** - Description: A monochrome bitmap, using 1 bit per pixel. Pixels are stored in most-significant order (MSB), meaning the left-most pixel in a byte has value 128. - **FT_PIXEL_MODE_GRAY** - Description: An 8-bit bitmap, generally used to represent anti-aliased glyph images. Each pixel is stored in one byte. The number of gray levels is stored in the ‘num_grays’ field of the FT_Bitmap structure (typically 256). - **FT_PIXEL_MODE_GRAY2** - Description: A 2-bit per pixel bitmap, used for embedded anti-aliased bitmaps in font files according to the OpenType specification. Not commonly encountered. - **FT_PIXEL_MODE_GRAY4** - Description: A 4-bit per pixel bitmap, representing embedded anti-aliased bitmaps in font files according to the OpenType specification. Not commonly encountered. - **FT_PIXEL_MODE_LCD** - Description: An 8-bit bitmap, representing RGB or BGR decimated glyph images for LCD displays. The bitmap is three times wider than the original glyph image. See also FT_RENDER_MODE_LCD. - **FT_PIXEL_MODE_LCD_V** - Description: An 8-bit bitmap, representing RGB or BGR decimated glyph images for rotated LCD displays. The bitmap is three times taller than the original glyph image. See also FT_RENDER_MODE_LCD_V. ### No API Endpoints Found This section pertains to an enumeration and does not have direct API endpoints for request/response examples. ``` -------------------------------- ### SizeMetrics Class Source: https://freetype-py.readthedocs.io/en/latest/_sources/size_metrics.rst Details about the SizeMetrics class, including its members which represent various size metrics for fonts. ```APIDOC ## SizeMetrics Class ### Description The `SizeMetrics` class provides detailed metrics about the size of a font, including ascender, descender, and other relevant measurements. ### Members - **x_ppem** (int) - Horizontal resolution in pixels per em. - **y_ppem** (int) - Vertical resolution in pixels per em. - **x_scale** (int) - Horizontal scaling factor. - **y_scale** (int) - Vertical scaling factor. - **ascender** (int) - The ascender metric in 1/64th increments of pixels. - **descender** (int) - The descender metric in 1/64th increments of pixels. - **height** (int) - The height metric in 1/64th increments of pixels. - **max_advance_width** (int) - The maximum advance width metric in 1/64th increments of pixels. - **underline_position** (int) - The position of the underline in 1/64th increments of pixels. - **underline_thickness** (int) - The thickness of the underline in 1/64th increments of pixels. ``` -------------------------------- ### FT_OPEN_MODES Constants Source: https://freetype-py.readthedocs.io/en/latest/ft_open_modes Constants for specifying open modes in FreeType. ```APIDOC ## FT_OPEN_MODES Constants ### Description A list of bit-field constants used within the ‘flags’ field of the FT_Open_Args structure. ### Constants - **FT_OPEN_MEMORY** - Description: This is a memory-based stream. - **FT_OPEN_STREAM** - Description: Copy the stream from the ‘stream’ field. - **FT_OPEN_PATHNAME** - Description: Create a new input stream from a C path name. - **FT_OPEN_DRIVER** - Description: Use the ‘driver’ field. - **FT_OPEN_PARAMS** - Description: Use the ‘num_params’ and ‘params’ fields. ### Method N/A (Constants) ### Endpoint N/A (Constants) ### Parameters N/A (Constants) ### Request Example N/A (Constants) ### Response N/A (Constants) ``` -------------------------------- ### FT_LOAD_TARGETS Constants Source: https://freetype-py.readthedocs.io/en/latest/_sources/ft_load_targets.rst Overview of the FT_LOAD_TARGETS constants used for selecting hinting algorithms in FreeType. These constants are OR'd with 'load_flags' when calling FT_Load_Glyph. ```APIDOC ## FT_LOAD_TARGETS ### Description A list of values that are used to select a specific hinting algorithm to use by the hinter. You should OR one of these values to your 'load_flags' when calling FT_Load_Glyph. Note that font's native hinters may ignore the hinting algorithm you have specified (e.g., the TrueType bytecode interpreter). You can set ``FT_LOAD_FORCE_AUTOHINT`` to ensure that the auto-hinter is used. Also note that ``FT_LOAD_TARGET_LIGHT`` is an exception, in that it always implies ``FT_LOAD_FORCE_AUTOHINT``. ### Constants #### FT_LOAD_TARGET_NORMAL This corresponds to the default hinting algorithm, optimized for standard gray-level rendering. For monochrome output, use ``FT_LOAD_TARGET_MONO`` instead. #### FT_LOAD_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 ``FT_LOAD_FORCE_AUTOHINT``. #### FT_LOAD_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. #### FT_LOAD_TARGET_LCD A variant of ``FT_LOAD_TARGET_NORMAL`` optimized for horizontally decimated LCD displays. #### FT_LOAD_TARGET_LCD_V A variant of ``FT_LOAD_TARGET_NORMAL`` optimized for vertically decimated LCD displays. ``` -------------------------------- ### TT_PLATFORMS Constants Source: https://freetype-py.readthedocs.io/en/latest/tt_platforms This section details the various platform IDs used within FreeType font structures. ```APIDOC ## TT_PLATFORMS A list of valid values for the ‘platform_id’ identifier code in FT_CharMapRec and FT_SfntName structures. ### TT_PLATFORM_APPLE_UNICODE Used by Apple to indicate a Unicode character map and/or name entry. See TT_APPLE_ID_XXX for corresponding ‘encoding_id’ values. Note that name entries in this format are coded as big-endian UCS-2 character codes only. ### TT_PLATFORM_MACINTOSH Used by Apple to indicate a MacOS-specific charmap and/or name entry. See TT_MAC_ID_XXX for corresponding ‘encoding_id’ values. Note that most TrueType fonts contain an Apple roman charmap to be usable on MacOS systems (even if they contain a Microsoft charmap as well). ### TT_PLATFORM_ISO This value was used to specify ISO/IEC 10646 charmaps. It is however now deprecated. See TT_ISO_ID_XXX for a list of corresponding ‘encoding_id’ values. ### TT_PLATFORM_MICROSOFT Used by Microsoft to indicate Windows-specific charmaps. See TT_MS_ID_XXX for a list of corresponding ‘encoding_id’ values. Note that most fonts contain a Unicode charmap using (TT_PLATFORM_MICROSOFT, TT_MS_ID_UNICODE_CS). ### TT_PLATFORM_CUSTOM Used to indicate application-specific charmaps. ### TT_PLATFORM_ADOBE This value isn’t part of any font format specification, but is used by FreeType to report Adobe-specific charmaps in an FT_CharMapRec structure. See TT_ADOBE_ID_XXX. ``` -------------------------------- ### TT_APPLE_IDS Constants Source: https://freetype-py.readthedocs.io/en/latest/_sources/tt_apple_ids.rst This section details the constants available within TT_APPLE_IDS, which represent different versions and specifications of Unicode encoding for Apple platforms. ```APIDOC ## TT_APPLE_IDS Constants ### Description A list of valid values for the 'encoding_id' for TT_PLATFORM_APPLE_UNICODE charmaps and name entries. ### Method N/A (Constants) ### Endpoint N/A (Constants) ### Parameters N/A (Constants) ### Request Example N/A (Constants) ### Response #### Success Response (N/A) - **TT_APPLE_ID_DEFAULT** (constant) - Unicode version 1.0. - **TT_APPLE_ID_UNICODE_1_1** (constant) - Unicode 1.1; specifies Hangul characters starting at U+34xx. - **TT_APPLE_ID_ISO_10646** (constant) - Deprecated (identical to preceding). - **TT_APPLE_ID_UNICODE_2_0** (constant) - Unicode 2.0 and beyond (UTF-16 BMP only). - **TT_APPLE_ID_UNICODE_32** (constant) - Unicode 3.1 and beyond, using UTF-32. - **TT_APPLE_ID_VARIANT_SELECTOR** (constant) - From Adobe, not Apple. Not a normal cmap. Specifies variations on a real cmap. #### Response Example N/A (Constants) ``` -------------------------------- ### FT_LCD_FILTERS Constants Source: https://freetype-py.readthedocs.io/en/latest/_sources/ft_lcd_filters.rst This section details the available FT_LCD_FILTER constants, which are used to control LCD filtering for subpixel rendering in FreeType. Each constant offers a different trade-off between blurriness and color fringing. ```APIDOC ## FT_LCD_FILTERS Constants ### Description Constants to identify various types of LCD filters for subpixel rendering. ### Method N/A (Constants) ### Endpoint N/A (Constants) ### Parameters N/A ### Request Example N/A ### Response #### Success Response (N/A) N/A #### Response Example N/A ### Constants - **FT_LCD_FILTER_NONE** - Description: Do not perform filtering. Results in color fringes when used with subpixel rendering. - **FT_LCD_FILTER_DEFAULT** - Description: The default filter. Reduces color fringes but introduces slight blurriness. - **FT_LCD_FILTER_LIGHT** - Description: A lighter filter variant. Less blurry than default, but with slightly more color fringes. - **FT_LCD_FILTER_LEGACY** - Description: Corresponds to the original libXft color filter. High contrast but can have bad color fringes if glyphs are not well-hinted. Primarily for comparison, may be unsupported in the future. ``` -------------------------------- ### FT_PIXEL_MODES Enumeration Source: https://freetype-py.readthedocs.io/en/latest/_sources/ft_pixel_modes.rst Details the different pixel modes supported by FreeType 2 for rendering glyphs. ```APIDOC ## FT_PIXEL_MODES Enumeration ### Description An enumeration type that lists the render modes supported by FreeType 2. Each mode corresponds to a specific type of scanline conversion performed on the outline. ### Enumeration Values - **FT_PIXEL_MODE_NONE** (Value 0) - Reserved. - **FT_PIXEL_MODE_MONO** - A monochrome bitmap, using 1 bit per pixel. Pixels are stored in most-significant order (MSB). - **FT_PIXEL_MODE_GRAY** - An 8-bit bitmap, generally used for anti-aliased glyph images. Each pixel is stored in one byte. The number of 'gray' levels is stored in the 'num_grays' field of the FT_Bitmap structure (typically 256). - **FT_PIXEL_MODE_GRAY2** - A 2-bit per pixel bitmap, used for embedded anti-aliased bitmaps in font files according to the OpenType specification. Not commonly found in use. - **FT_PIXEL_MODE_GRAY4** - A 4-bit per pixel bitmap, representing embedded anti-aliased bitmaps in font files according to the OpenType specification. Not commonly found in use. - **FT_PIXEL_MODE_LCD** - An 8-bit bitmap, representing RGB or BGR decimated glyph images for LCD displays. The bitmap is three times wider than the original glyph image. See also FT_RENDER_MODE_LCD. - **FT_PIXEL_MODE_LCD_V** - An 8-bit bitmap, representing RGB or BGR decimated glyph images for rotated LCD displays. The bitmap is three times taller than the original glyph image. See also FT_RENDER_MODE_LCD_V. ``` -------------------------------- ### FT_ENCODINGS Enumeration Source: https://freetype-py.readthedocs.io/en/latest/_sources/ft_encodings.rst Details on the various character set encodings supported by FreeType Py. ```APIDOC ## FT_ENCODINGS Enumeration ### Description An enumeration used to specify character sets supported by charmaps. Used in the `FT_Select_Charmap` API function. ### Constants - **FT_ENCODING_NONE** - Description: The encoding value 0 is reserved. - **FT_ENCODING_UNICODE** - Description: Corresponds to the Unicode character set. This value covers all versions of the Unicode repertoire, including ASCII and Latin-1. Most fonts include a Unicode charmap, but not all of them. - Example: If you want to access Unicode value U+1F028 (and the font contains it), use value 0x1F028 as the input value for `FT_Get_Char_Index`. - **FT_ENCODING_MS_SYMBOL** - Description: Corresponds to the Microsoft Symbol encoding, used to encode mathematical symbols in the 32..255 character code range. For more information, see 'http://www.ceviz.net/symbol.htm'. - **FT_ENCODING_SJIS** - Description: Corresponds to Japanese SJIS encoding. More info at 'http://langsupport.japanreference.com/encoding.shtml'. See note on multi-byte encodings below. - **FT_ENCODING_PRC** - Description: Corresponds to an encoding system for Simplified Chinese as used in mainland China. - **FT_ENCODING_BIG5** - Description: Corresponds to an encoding system for Traditional Chinese as used in Taiwan and Hong Kong. - **FT_ENCODING_WANSUNG** - Description: Corresponds to the Korean encoding system known as Wansung. For more information see 'http://www.microsoft.com/typography/unicode/949.txt'. - **FT_ENCODING_JOHAB** - Description: The Korean standard character set (KS C 5601-1992), which corresponds to MS Windows code page 1361. This character set includes all possible Hangeul character combinations. - **FT_ENCODING_ADOBE_LATIN_1** - Description: Corresponds to a Latin-1 encoding as defined in a Type 1 PostScript font. It is limited to 256 character codes. - **FT_ENCODING_ADOBE_STANDARD** - Description: Corresponds to the Adobe Standard encoding, as found in Type 1, CFF, and OpenType/CFF fonts. It is limited to 256 character codes. - **FT_ENCODING_ADOBE_EXPERT** - Description: Corresponds to the Adobe Expert encoding, as found in Type 1, CFF, and OpenType/CFF fonts. It is limited to 256 character codes. - **FT_ENCODING_ADOBE_CUSTOM** - Description: Corresponds to a custom encoding, as found in Type 1, CFF, and OpenType/CFF fonts. It is limited to 256 character codes. - **FT_ENCODING_APPLE_ROMAN** - Description: Corresponds to the 8-bit Apple roman encoding. Many TrueType and OpenType fonts contain a charmap for this encoding, since older versions of Mac OS are able to use it. - **FT_ENCODING_OLD_LATIN_2** - Description: This value is deprecated and was never used nor reported by FreeType. Don't use or test for it. ``` -------------------------------- ### TT_MS_IDS Constants Source: https://freetype-py.readthedocs.io/en/latest/tt_ms_ids A list of valid values for the ‘encoding_id’ for TT_PLATFORM_MICROSOFT charmaps and name entries. ```APIDOC ## TT_MS_IDS Constants A list of valid values for the ‘encoding_id’ for TT_PLATFORM_MICROSOFT charmaps and name entries. ### TT_MS_ID_SYMBOL_CS Corresponds to Microsoft symbol encoding. See FT_ENCODING_MS_SYMBOL. ### TT_MS_ID_UNICODE_CS Corresponds to a Microsoft WGL4 charmap, matching Unicode. See FT_ENCODING_UNICODE. ### TT_MS_ID_SJIS Corresponds to SJIS Japanese encoding. See FT_ENCODING_SJIS. ### TT_MS_ID_PRC Corresponds to Simplified Chinese as used in Mainland China. See FT_ENCODING_PRC. ### TT_MS_ID_BIG_5 Corresponds to Traditional Chinese as used in Taiwan and Hong Kong. See FT_ENCODING_BIG5. ### TT_MS_ID_WANSUNG Corresponds to Korean Wansung encoding. See FT_ENCODING_WANSUNG. ### TT_MS_ID_JOHAB Corresponds to Johab encoding. See FT_ENCODING_JOHAB. ### TT_MS_ID_UCS_4 Corresponds to UCS-4 or UTF-32 charmaps. This has been added to the OpenType specification version 1.4 (mid-2001.) ``` -------------------------------- ### FT_FSTYPES Constants Source: https://freetype-py.readthedocs.io/en/latest/_sources/ft_fstypes.rst Details on the various FT_FSTYPES bit flags that define font embedding and subsetting permissions. ```APIDOC ## FT_FSTYPES Constants ### Description A list of bit flags that inform client applications of embedding and subsetting restrictions associated with a font. ### Method N/A (Constants definition) ### Endpoint N/A (Constants definition) ### Parameters N/A ### Request Example N/A ### Response #### Success Response (N/A) - **FT_FSTYPE_INSTALLABLE_EMBEDDING** (int) - Fonts with no fsType bit set may be embedded and permanently installed on the remote system by an application. - **FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING** (int) - Fonts that have only this bit set must not be modified, embedded or exchanged in any manner without first obtaining permission of the font software copyright owner. - **FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING** (int) - If this bit is set, the font may be embedded and temporarily loaded on the remote system. Documents containing Preview & Print fonts must be opened 'read-only'; no edits can be applied to the document. - **FT_FSTYPE_EDITABLE_EMBEDDING** (int) - If this bit is set, the font may be embedded but must only be installed temporarily on other systems. In contrast to Preview & Print fonts, documents containing editable fonts may be opened for reading, editing is permitted, and changes may be saved. - **FT_FSTYPE_NO_SUBSETTING** (int) - If this bit is set, the font may not be subsetted prior to embedding. - **FT_FSTYPE_BITMAP_EMBEDDING_ONLY** (int) - If this bit is set, only bitmaps contained in the font may be embedded; no outline data may be embedded. If there are no bitmaps available in the font, then the font is unembeddable. #### Response Example N/A ``` -------------------------------- ### FreeType Constants Source: https://freetype-py.readthedocs.io/en/latest/genindex This section lists various built-in variables and constants used within the FreeType library for configuration and operation. These constants define encoding types, face flags, font types, glyph formats, kerning modes, LCD filter settings, loading options, open driver types, outline properties, pixel modes, rendering modes, stroker line caps and joins, and style flags. ```APIDOC ## FreeType Constants Reference This document outlines the various constants and variables available in the freetype-py library, which correspond to the FreeType library's internal enumerations and flags. These are essential for configuring font loading, rendering, and manipulation. ### FT_ENCODING_* (Encoding Constants) Constants defining character set encodings. * **FT_ENCODING_ADOBE_CUSTOM** * **FT_ENCODING_ADOBE_EXPERT** * **FT_ENCODING_ADOBE_LATIN_1** * **FT_ENCODING_ADOBE_STANDARD** * **FT_ENCODING_APPLE_ROMAN** * **FT_ENCODING_BIG5** * **FT_ENCODING_JOHAB** * **FT_ENCODING_MS_SYMBOL** * **FT_ENCODING_NONE** * **FT_ENCODING_OLD_LATIN_2** * **FT_ENCODING_PRC** * **FT_ENCODING_SJIS** * **FT_ENCODING_UNICODE** * **FT_ENCODING_WANSUNG** ### FT_FACE_FLAG_* (Face Flags) Flags indicating properties of a font face. * **FT_FACE_FLAG_CID_KEYED** * **FT_FACE_FLAG_EXTERNAL_STREAM** * **FT_FACE_FLAG_FIXED_SIZES** * **FT_FACE_FLAG_FIXED_WIDTH** * **FT_FACE_FLAG_GLYPH_NAMES** * **FT_FACE_FLAG_HINTER** * **FT_FACE_FLAG_HORIZONTAL** * **FT_FACE_FLAG_KERNING** * **FT_FACE_FLAG_MULTIPLE_MASTERS** * **FT_FACE_FLAG_SCALABLE** * **FT_FACE_FLAG_SFNT** * **FT_FACE_FLAG_TRICKY** * **FT_FACE_FLAG_VERTICAL** ### FT_FSTYPE_* (Font Specific Type Flags) Flags related to font embedding permissions and types. * **FT_FSTYPE_BITMAP_EMBEDDING_ONLY** * **FT_FSTYPE_EDITABLE_EMBEDDING** * **FT_FSTYPE_INSTALLABLE_EMBEDDING** * **FT_FSTYPE_NO_SUBSETTING** * **FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING** * **FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING** ### FT_GLYPH_BBOX_* (Glyph Bounding Box Modes) Modes for calculating glyph bounding boxes. * **FT_GLYPH_BBOX_GRIDFIT** * **FT_GLYPH_BBOX_PIXELS** * **FT_GLYPH_BBOX_SUBPIXELS** * **FT_GLYPH_BBOX_TRUNCATE** * **FT_GLYPH_BBOX_UNSCALED** ### FT_GLYPH_FORMAT_* (Glyph Format Constants) Constants defining the format of glyph data. * **FT_GLYPH_FORMAT_BITMAP** * **FT_GLYPH_FORMAT_COMPOSITE** * **FT_GLYPH_FORMAT_NONE** * **FT_GLYPH_FORMAT_OUTLINE** * **FT_GLYPH_FORMAT_PLOTTER** ### FT_KERNING_* (Kerning Modes) Constants for kerning operations. * **FT_KERNING_DEFAULT** * **FT_KERNING_UNFITTED** * **FT_KERNING_UNSCALED** ### FT_LCD_FILTER_* (LCD Filter Constants) Constants for controlling Liquid Crystal Display (LCD) filtering. * **FT_LCD_FILTER_DEFAULT** * **FT_LCD_FILTER_LEGACY** * **FT_LCD_FILTER_LIGHT** * **FT_LCD_FILTER_NONE** ### FT_LOAD_* (Loading Flags) Flags controlling how a font face or glyph is loaded. * **FT_LOAD_CROP_BITMAP** * **FT_LOAD_DEFAULT** * **FT_LOAD_FORCE_AUTOHINT** * **FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH** * **FT_LOAD_IGNORE_TRANSFORM** * **FT_LOAD_LINEAR_DESIGN** * **FT_LOAD_MONOCHROME** * **FT_LOAD_NO_AUTOHINT** * **FT_LOAD_NO_BITMAP** * **FT_LOAD_NO_HINTING** * **FT_LOAD_NO_RECURSE** * **FT_LOAD_NO_SCALE** * **FT_LOAD_PEDANTIC** * **FT_LOAD_RENDER** * **FT_LOAD_TARGET_LCD** * **FT_LOAD_TARGET_LCD_V** * **FT_LOAD_TARGET_LIGHT** * **FT_LOAD_TARGET_MONO** * **FT_LOAD_TARGET_NORMAL** * **FT_LOAD_VERTICAL_LAYOUT** ### FT_OPEN_* (Open Mode Constants) Constants specifying how to open a font file or stream. * **FT_OPEN_DRIVER** * **FT_OPEN_MEMORY** * **FT_OPEN_PARAMS** * **FT_OPEN_PATHNAME** * **FT_OPEN_STREAM** ### FT_OUTLINE_* (Outline Flags) Flags related to font outline processing. * **FT_OUTLINE_EVEN_ODD_FILL** * **FT_OUTLINE_HIGH_PRECISION** * **FT_OUTLINE_IGNORE_DROPOUTS** * **FT_OUTLINE_INCLUDE_STUBS** * **FT_OUTLINE_NONE** * **FT_OUTLINE_OWNER** * **FT_OUTLINE_REVERSE_FILL** * **FT_OUTLINE_SINGLE_PASS** * **FT_OUTLINE_SMART_DROPOUTS** ### FT_PIXEL_MODE_* (Pixel Mode Constants) Constants defining the pixel format for bitmaps. * **FT_PIXEL_MODE_GRAY** * **FT_PIXEL_MODE_GRAY2** * **FT_PIXEL_MODE_GRAY4** * **FT_PIXEL_MODE_LCD** * **FT_PIXEL_MODE_LCD_V** * **FT_PIXEL_MODE_MONO** * **FT_PIXEL_MODE_NONE** ### FT_RENDER_MODE_* (Render Mode Constants) Constants specifying the rendering mode for glyphs. * **FT_RENDER_MODE_LCD** * **FT_RENDER_MODE_LCD_V** * **FT_RENDER_MODE_LIGHT** * **FT_RENDER_MODE_MONO** * **FT_RENDER_MODE_NORMAL** ### FT_STROKER_BORDER_* (Stroker Border Constants) Constants defining the border for stroker operations. * **FT_STROKER_BORDER_LEFT** * **FT_STROKER_BORDER_RIGHT** ### FT_STROKER_LINECAP_* (Stroker Line Cap Constants) Constants defining the line cap style for stroker operations. * **FT_STROKER_LINECAP_BUTT** * **FT_STROKER_LINECAP_ROUND** * **FT_STROKER_LINECAP_SQUARE** ### FT_STROKER_LINEJOIN_* (Stroker Line Join Constants) Constants defining the line join style for stroker operations. * **FT_STROKER_LINEJOIN_BEVEL** * **FT_STROKER_LINEJOIN_MITER** * **FT_STROKER_LINEJOIN_ROUND** ### FT_STYLE_FLAG_* (Style Flags) Flags indicating stylistic properties of a font, such as bold or italic. * **FT_STYLE_FLAG_BOLD** * **FT_STYLE_FLAG_ITALIC** ``` -------------------------------- ### FT_LOAD_FLAGS Constants Source: https://freetype-py.readthedocs.io/en/latest/_sources/ft_load_flags.rst This section details the available FT_LOAD_FLAGS constants and their impact on the FT_Load_Glyph function. These flags are bit-field constants used to customize glyph loading operations. ```APIDOC ## FT_LOAD_FLAGS Constants ### Description A list of bit-field constants used with FT_Load_Glyph to indicate what kind of operations to perform during glyph loading. ### Constants - **FT_LOAD_DEFAULT** (integer) - `0`. Default glyph load operation. Prioritizes embedded bitmaps, then scalable outlines scaled and hinted to device pixels. - **FT_LOAD_NO_SCALE** (integer) - Disables scaling of the outline glyph. Keeps glyphs in font units. Implies `FT_LOAD_NO_HINTING` and `FT_LOAD_NO_BITMAP`, and unsets `FT_LOAD_RENDER`. - **FT_LOAD_NO_HINTING** (integer) - Disables hinting. Can result in blurrier bitmaps in anti-aliased modes. Implied by `FT_LOAD_NO_SCALE`. - **FT_LOAD_RENDER** (integer) - Calls `FT_Render_Glyph` after loading. Defaults to `FT_RENDER_MODE_NORMAL`. Can be overridden by `FT_LOAD_TARGET_XXX` or `FT_LOAD_MONOCHROME`. Unset by `FT_LOAD_NO_SCALE`. - **FT_LOAD_NO_BITMAP** (integer) - Ignores bitmap strikes when loading. Bitmap-only fonts disregard this flag. Always set by `FT_LOAD_NO_SCALE`. - **FT_LOAD_VERTICAL_LAYOUT** (integer) - Loads glyph for vertical text layout. Currently has known issues. - **FT_LOAD_FORCE_AUTOHINT** (integer) - Prefers the auto-hinter over the font's native hinter. - **FT_LOAD_CROP_BITMAP** (integer) - Instructs the font driver to crop the loaded bitmap glyph, removing surrounding empty space. Not universally supported. - **FT_LOAD_PEDANTIC** (integer) - Enables pedantic verification during glyph loading to detect broken glyphs. FreeType typically attempts to handle broken fonts by default. - **FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH** (integer) - Ignores the global advance width defined in the font. Normally used when `FT_FACE_FLAG_FIXED_WIDTH` is set. Primarily for historical support of buggy CJK fonts. - **FT_LOAD_NO_RECURSE** (integer) - Internal use only. Prevents recursive loading of composite glyphs. Sets `num_subglyph` and `subglyphs` and `glyph->format` to `FT_GLYPH_FORMAT_COMPOSITE`. Implies `FT_LOAD_NO_SCALE` and `FT_LOAD_IGNORE_TRANSFORM`. - **FT_LOAD_IGNORE_TRANSFORM** (integer) - Ignores the transformation matrix set by `FT_Set_Transform`. - **FT_LOAD_MONOCHROME** (integer) - Used with `FT_LOAD_RENDER` to render an outline glyph to a 1-bit monochrome bitmap. Pixels are packed 8 per byte. Does not affect hinting; use `FT_LOAD_TARGET_MONO` for monochrome-optimized hinting. - **FT_LOAD_LINEAR_DESIGN** (integer) - Keeps `linearHoriAdvance` and `linearVertAdvance` fields of `FT_GlyphSlotRec` in font units. - **FT_LOAD_NO_AUTOHINT** (integer) - Disables the auto-hinter. ``` -------------------------------- ### FT_FACE_FLAGS Constants Source: https://freetype-py.readthedocs.io/en/latest/ft_face_flags This section details the FT_FACE_FLAGS constants, which are bit flags used in the FT_FaceRec structure. Each flag provides information about the properties of a font face. ```APIDOC ## FT_FACE_FLAGS Constants Documentation ### Description A list of bit flags used in the ‘face_flags’ field of the FT_FaceRec structure. They inform client applications of properties of the corresponding face. ### Flags - **FT_FACE_FLAG_SCALABLE** - Indicates that the face contains outline glyphs. This doesn’t prevent bitmap strikes, i.e., a face can have both this and and FT_FACE_FLAG_FIXED_SIZES set. - **FT_FACE_FLAG_FIXED_SIZES** - Indicates that the face contains bitmap strikes. See also the ‘num_fixed_sizes’ and ‘available_sizes’ fields of FT_FaceRec. - **FT_FACE_FLAG_FIXED_WIDTH** - Indicates that the face contains fixed-width characters (like Courier, Lucido, MonoType, etc.). - **FT_FACE_FLAG_SFNT** - Indicates that the face uses the ‘sfnt’ storage scheme. For now, this means TrueType and OpenType. - **FT_FACE_FLAG_HORIZONTAL** - Indicates that the face contains horizontal glyph metrics. This should be set for all common formats. - **FT_FACE_FLAG_VERTICAL** - Indicates that the face contains vertical glyph metrics. This is only available in some formats, not all of them. - **FT_FACE_FLAG_KERNING** - Indicates that the face contains kerning information. If set, the kerning distance can be retrieved through the function FT_Get_Kerning. Otherwise the function always return the vector (0,0). Note that FreeType doesn’t handle kerning data from the ‘GPOS’ table (as present in some OpenType fonts). - **FT_FACE_FLAG_MULTIPLE_MASTERS** - Indicates that the font contains multiple masters and is capable of interpolating between them. See the multiple-masters specific API for details. - **FT_FACE_FLAG_GLYPH_NAMES** - Indicates that the font contains glyph names that can be retrieved through FT_Get_Glyph_Name. Note that some TrueType fonts contain broken glyph name tables. Use the function FT_Has_PS_Glyph_Names when needed. - **FT_FACE_FLAG_EXTERNAL_STREAM** - Used internally by FreeType to indicate that a face’s stream was provided by the client application and should not be destroyed when FT_Done_Face is called. Don’t read or test this flag. - **FT_FACE_FLAG_HINTER** - Set if the font driver has a hinting machine of its own. For example, with TrueType fonts, it makes sense to use data from the SFNT ‘gasp’ table only if the native TrueType hinting engine (with the bytecode interpreter) is available and active. - **FT_FACE_FLAG_CID_KEYED** - Set if the font is CID-keyed. In that case, the font is not accessed by glyph indices but by CID values. For subsetted CID-keyed fonts this has the consequence that not all index values are a valid argument to FT_Load_Glyph. Only the CID values for which corresponding glyphs in the subsetted font exist make FT_Load_Glyph return successfully; in all other cases you get an ‘FT_Err_Invalid_Argument’ error. Note that CID-keyed fonts which are in an SFNT wrapper don’t have this flag set since the glyphs are accessed in the normal way (using contiguous indices); the ‘CID-ness’ isn’t visible to the application. - **FT_FACE_FLAG_TRICKY** - Set if the font is ‘tricky’, this is, it always needs the font format’s native hinting engine to get a reasonable result. A typical example is the Chinese font ‘mingli.ttf’ which uses TrueType bytecode instructions to move and scale all of its subglyphs. It is not possible to autohint such fonts using FT_LOAD_FORCE_AUTOHINT; it will also ignore FT_LOAD_NO_HINTING. You have to set both FT_LOAD_NO_HINTING and FT_LOAD_NO_AUTOHINT to really disable hinting; however, you probably never want this except for demonstration purposes. Currently, there are six TrueType fonts in the list of tricky fonts; they are hard-coded in file ‘ttobjs.c’. ### Related Topics - Documentation overview - API - Constants - Previous: FT_ENCODINGS - Next: FT_FSTYPES ``` -------------------------------- ### FT_OUTLINE_FLAGS Constants Source: https://freetype-py.readthedocs.io/en/latest/ft_outline_flags Constants that modify the behavior of font outlines. ```APIDOC ## FT_OUTLINE_FLAGS Constants ### Description Constants that modify the behavior of font outlines, affecting fill rules, dropout handling, and rendering precision. ### Parameters #### Constants - **FT_OUTLINE_NONE** (int) - Value 0 is reserved. - **FT_OUTLINE_OWNER** (int) - If set, indicates that the outline's field arrays are owned by the outline object and should be freed when it is destroyed. - **FT_OUTLINE_EVEN_ODD_FILL** (int) - If set to 1, the outline will be filled using the even-odd fill rule (works with the smooth rasterizer). - **FT_OUTLINE_REVERSE_FILL** (int) - If set, indicates the outline uses the opposite direction for contours (typically for Type 1 fonts). Ignored by the scan converter. - **FT_OUTLINE_IGNORE_DROPOUTS** (int) - If set, hints the scan-line converter to ignore drop-outs and correct the glyph bitmap for consistent shape continuity. - **FT_OUTLINE_SMART_DROPOUTS** (int) - Select smart dropout control. If unset, use simple dropout control. Ignored if FT_OUTLINE_IGNORE_DROPOUTS is set. - **FT_OUTLINE_INCLUDE_STUBS** (int) - If set, turn pixels on for 'stubs', otherwise exclude them. Ignored if FT_OUTLINE_IGNORE_DROPOUTS is set. - **FT_OUTLINE_HIGH_PRECISION** (int) - Indicates that the scan-line converter should try to convert this outline to bitmaps with the highest possible quality. Typically set for small character sizes. This is a hint that may be ignored. - **FT_OUTLINE_SINGLE_PASS** (int) - Forces a scan-converter to use a single pass over the outline to render a bitmap glyph image. Normally set for very large character sizes. This is a hint that may be ignored. ### Usage These constants are used within the 'flags' field of an outline object to customize its rendering and processing. ``` -------------------------------- ### FT_STYLE_FLAGS Source: https://freetype-py.readthedocs.io/en/latest/ft_style_flags A list of bit-flags used to indicate the style of a given face, used in the ‘style_flags’ field of FT_FaceRec. ```APIDOC ## FT_STYLE_FLAGS ### Description A list of bit-flags used to indicate the style of a given face. These are used in the ‘style_flags’ field of FT_FaceRec. ### Constants - **FT_STYLE_FLAG_ITALIC** - Indicates that a given face style is italic or oblique. - **FT_STYLE_FLAG_BOLD** - Indicates that a given face is bold. ``` -------------------------------- ### FT_GLYPH_FORMATS Enumeration Source: https://freetype-py.readthedocs.io/en/latest/_sources/ft_glyph_formats.rst Details the enumeration types for glyph image formats in FreeType. ```APIDOC ## FT_GLYPH_FORMATS Enumeration ### Description An enumeration type used to describe the format of a given glyph image. FreeType supports several image formats, with potential for future expansion. ### Enum Values - **FT_GLYPH_FORMAT_NONE** (0) - Reserved value. - **FT_GLYPH_FORMAT_COMPOSITE** - The glyph image is a composite of several other images. Used with FT_LOAD_NO_RECURSE for compound glyphs (e.g., accented characters). - **FT_GLYPH_FORMAT_BITMAP** - The glyph image is a bitmap, described as an FT_Bitmap. Typically accessed via the 'bitmap' field of the FT_GlyphSlotRec structure. - **FT_GLYPH_FORMAT_OUTLINE** - The glyph image is a vectorial outline (line segments and Bezier arcs), described as an FT_Outline. Typically accessed via the 'outline' field of the FT_GlyphSlotRec structure. - **FT_GLYPH_FORMAT_PLOTTER** - The glyph image is a vectorial path without distinct inside/outside contours. Used in some Type 1 fonts (e.g., Hershey family). Described as FT_Outline, but not currently rendered correctly by FreeType. ``` -------------------------------- ### FT_STROKER_BORDERS Source: https://freetype-py.readthedocs.io/en/latest/ft_stroker_borders These values are used to select a given stroke border in FT_Stroker_GetBorderCounts and FT_Stroker_ExportBorder. ```APIDOC ## FT_STROKER_BORDER_LEFT ### Description Select the left border, relative to the drawing direction. ### Method N/A (Constant) ### Endpoint N/A (Constant) ### Parameters N/A (Constant) ### Request Example N/A (Constant) ### Response N/A (Constant) ``` ```APIDOC ## FT_STROKER_BORDER_RIGHT ### Description Select the right border, relative to the drawing direction. Note: Applications are generally interested in the ‘inside’ and ‘outside’ borders. However, there is no direct mapping between these and the ‘left’ and ‘right’ ones, since this really depends on the glyph’s drawing orientation, which varies between font formats. You can however use FT_Outline_GetInsideBorder and FT_Outline_GetOutsideBorder to get these. ### Method N/A (Constant) ### Endpoint N/A (Constant) ### Parameters N/A (Constant) ### Request Example N/A (Constant) ### Response N/A (Constant) ``` -------------------------------- ### FT_STROKER_LINECAP_BUTT Source: https://freetype-py.readthedocs.io/en/latest/_sources/ft_stroker_linecaps.rst Defines the line cap style where the end of lines is rendered as a full stop on the last point itself. ```APIDOC ## FT_STROKER_LINECAP_BUTT ### Description The end of lines is rendered as a full stop on the last point itself. ### Method N/A (Constant Definition) ### Endpoint N/A (Constant Definition) ### Parameters N/A (Constant Definition) ### Request Example N/A (Constant Definition) ### Response N/A (Constant Definition) ### Response Example N/A (Constant Definition) ```