1 /****************************************************************************
5 * FreeType high-level API and common types (specification only).
7 * Copyright (C) 1996-2020 by
8 * David Turner, Robert Wilhelm, and Werner Lemberg.
10 * This file is part of the FreeType project, and may only be used,
11 * modified, and distributed under the terms of the FreeType project
12 * license, LICENSE.TXT. By continuing to use, modify, or distribute
13 * this file you indicate that you have read the license and
14 * understand and accept it fully.
24 #include FT_CONFIG_CONFIG_H
25 #include <freetype/fttypes.h>
26 #include <freetype/fterrors.h>
33 /**************************************************************************
39 * FreeType's header inclusion scheme
42 * How client applications should include FreeType header files.
45 * To be as flexible as possible (and for historical reasons), you must
46 * load file `ft2build.h` first before other header files, for example
49 * #include <ft2build.h>
51 * #include <freetype/freetype.h>
52 * #include <freetype/ftoutln.h>
57 /**************************************************************************
66 * How client applications should allocate FreeType data structures.
69 * FreeType assumes that structures allocated by the user and passed as
70 * arguments are zeroed out except for the actual data. In other words,
71 * it is recommended to use `calloc` (or variants of it) instead of
72 * `malloc` for allocation.
78 /*************************************************************************/
79 /*************************************************************************/
81 /* B A S I C T Y P E S */
83 /*************************************************************************/
84 /*************************************************************************/
87 /**************************************************************************
96 * The FreeType~2 base font interface.
99 * This section describes the most important public high-level API
100 * functions of FreeType~2.
113 * FT_FACE_FLAG_SCALABLE
114 * FT_FACE_FLAG_FIXED_SIZES
115 * FT_FACE_FLAG_FIXED_WIDTH
116 * FT_FACE_FLAG_HORIZONTAL
117 * FT_FACE_FLAG_VERTICAL
120 * FT_FACE_FLAG_CID_KEYED
121 * FT_FACE_FLAG_TRICKY
122 * FT_FACE_FLAG_KERNING
123 * FT_FACE_FLAG_MULTIPLE_MASTERS
124 * FT_FACE_FLAG_VARIATION
125 * FT_FACE_FLAG_GLYPH_NAMES
126 * FT_FACE_FLAG_EXTERNAL_STREAM
127 * FT_FACE_FLAG_HINTER
135 * FT_HAS_MULTIPLE_MASTERS
142 * FT_IS_NAMED_INSTANCE
146 * FT_STYLE_FLAG_ITALIC
175 * FT_Size_Request_Type
195 * FT_LOAD_LINEAR_DESIGN
199 * FT_LOAD_NO_AUTOHINT
202 * FT_LOAD_VERTICAL_LAYOUT
203 * FT_LOAD_IGNORE_TRANSFORM
204 * FT_LOAD_FORCE_AUTOHINT
208 * FT_LOAD_TARGET_NORMAL
209 * FT_LOAD_TARGET_LIGHT
210 * FT_LOAD_TARGET_MONO
212 * FT_LOAD_TARGET_LCD_V
214 * FT_LOAD_TARGET_MODE
220 * FT_Get_Track_Kerning
222 * FT_Get_Postscript_Name
227 * FT_Get_Charmap_Index
229 * FT_Get_FSType_Flags
230 * FT_Get_SubGlyph_Info
241 * FT_SUBGLYPH_FLAG_XXX
249 /**************************************************************************
255 * A structure to model the metrics of a single glyph. The values are
256 * expressed in 26.6 fractional pixel format; if the flag
257 * @FT_LOAD_NO_SCALE has been used while loading the glyph, values are
258 * expressed in font units instead.
265 * The glyph's height.
268 * Left side bearing for horizontal layout.
271 * Top side bearing for horizontal layout.
274 * Advance width for horizontal layout.
277 * Left side bearing for vertical layout.
280 * Top side bearing for vertical layout. Larger positive values mean
281 * further below the vertical glyph origin.
284 * Advance height for vertical layout. Positive values mean the glyph
285 * has a positive advance downward.
288 * If not disabled with @FT_LOAD_NO_HINTING, the values represent
289 * dimensions of the hinted glyph (in case hinting is applicable).
291 * Stroking a glyph with an outside border does not increase
292 * `horiAdvance` or `vertAdvance`; you have to manually adjust these
293 * values to account for the added width and height.
295 * FreeType doesn't use the 'VORG' table data for CFF fonts because it
296 * doesn't have an interface to quickly retrieve the glyph height. The
297 * y~coordinate of the vertical origin can be simply computed as
298 * `vertBearingY + height` after loading a glyph.
300 typedef struct FT_Glyph_Metrics_
316 /**************************************************************************
322 * This structure models the metrics of a bitmap strike (i.e., a set of
323 * glyphs for a given point size and resolution) in a bitmap font. It is
324 * used for the `available_sizes` field of @FT_Face.
328 * The vertical distance, in pixels, between two consecutive baselines.
329 * It is always positive.
332 * The average width, in pixels, of all glyphs in the strike.
335 * The nominal size of the strike in 26.6 fractional points. This
336 * field is not very useful.
339 * The horizontal ppem (nominal width) in 26.6 fractional pixels.
342 * The vertical ppem (nominal height) in 26.6 fractional pixels.
346 * The nominal size given in a FNT font is not reliable. If the driver
347 * finds it incorrect, it sets `size` to some calculated values, and
348 * `x_ppem` and `y_ppem` to the pixel width and height given in the
349 * font, respectively.
351 * TrueType embedded bitmaps:
352 * `size`, `width`, and `height` values are not contained in the bitmap
353 * strike itself. They are computed from the global font parameters.
355 typedef struct FT_Bitmap_Size_
368 /*************************************************************************/
369 /*************************************************************************/
371 /* O B J E C T C L A S S E S */
373 /*************************************************************************/
374 /*************************************************************************/
376 /**************************************************************************
382 * A handle to a FreeType library instance. Each 'library' is completely
383 * independent from the others; it is the 'root' of a set of objects like
384 * fonts, faces, sizes, etc.
386 * It also embeds a memory manager (see @FT_Memory), as well as a
387 * scan-line converter object (see @FT_Raster).
389 * [Since 2.5.6] In multi-threaded applications it is easiest to use one
390 * `FT_Library` object per thread. In case this is too cumbersome, a
391 * single `FT_Library` object across threads is possible also, as long as
392 * a mutex lock is used around @FT_New_Face and @FT_Done_Face.
395 * Library objects are normally created by @FT_Init_FreeType, and
396 * destroyed with @FT_Done_FreeType. If you need reference-counting
397 * (cf. @FT_Reference_Library), use @FT_New_Library and @FT_Done_Library.
399 typedef struct FT_LibraryRec_ *FT_Library;
402 /**************************************************************************
409 /**************************************************************************
415 * A handle to a given FreeType module object. A module can be a font
416 * driver, a renderer, or anything else that provides services to the
419 typedef struct FT_ModuleRec_* FT_Module;
422 /**************************************************************************
428 * A handle to a given FreeType font driver object. A font driver is a
429 * module capable of creating faces from font files.
431 typedef struct FT_DriverRec_* FT_Driver;
434 /**************************************************************************
440 * A handle to a given FreeType renderer. A renderer is a module in
441 * charge of converting a glyph's outline image to a bitmap. It supports
442 * a single glyph image format, and one or more target surface depths.
444 typedef struct FT_RendererRec_* FT_Renderer;
447 /**************************************************************************
454 /**************************************************************************
460 * A handle to a typographic face object. A face object models a given
461 * typeface, in a given style.
464 * A face object also owns a single @FT_GlyphSlot object, as well as one
465 * or more @FT_Size objects.
467 * Use @FT_New_Face or @FT_Open_Face to create a new face object from a
468 * given filepath or a custom input stream.
470 * Use @FT_Done_Face to destroy it (along with its slot and sizes).
472 * An `FT_Face` object can only be safely used from one thread at a time.
473 * Similarly, creation and destruction of `FT_Face` with the same
474 * @FT_Library object can only be done from one thread at a time. On the
475 * other hand, functions like @FT_Load_Glyph and its siblings are
476 * thread-safe and do not need the lock to be held as long as the same
477 * `FT_Face` object is not used from multiple threads at the same time.
480 * See @FT_FaceRec for the publicly accessible fields of a given face
483 typedef struct FT_FaceRec_* FT_Face;
486 /**************************************************************************
492 * A handle to an object that models a face scaled to a given character
496 * An @FT_Face has one _active_ @FT_Size object that is used by functions
497 * like @FT_Load_Glyph to determine the scaling transformation that in
498 * turn is used to load and hint glyphs and metrics.
500 * You can use @FT_Set_Char_Size, @FT_Set_Pixel_Sizes, @FT_Request_Size
501 * or even @FT_Select_Size to change the content (i.e., the scaling
502 * values) of the active @FT_Size.
504 * You can use @FT_New_Size to create additional size objects for a given
505 * @FT_Face, but they won't be used by other functions until you activate
506 * it through @FT_Activate_Size. Only one size can be activated at any
507 * given time per face.
510 * See @FT_SizeRec for the publicly accessible fields of a given size
513 typedef struct FT_SizeRec_* FT_Size;
516 /**************************************************************************
522 * A handle to a given 'glyph slot'. A slot is a container that can hold
523 * any of the glyphs contained in its parent face.
525 * In other words, each time you call @FT_Load_Glyph or @FT_Load_Char,
526 * the slot's content is erased by the new glyph data, i.e., the glyph's
527 * metrics, its image (bitmap or outline), and other control information.
530 * See @FT_GlyphSlotRec for the publicly accessible glyph fields.
532 typedef struct FT_GlyphSlotRec_* FT_GlyphSlot;
535 /**************************************************************************
541 * A handle to a character map (usually abbreviated to 'charmap'). A
542 * charmap is used to translate character codes in a given encoding into
543 * glyph indexes for its parent's face. Some font formats may provide
544 * several charmaps per font.
546 * Each face object owns zero or more charmaps, but only one of them can
547 * be 'active', providing the data used by @FT_Get_Char_Index or
550 * The list of available charmaps in a face is available through the
551 * `face->num_charmaps` and `face->charmaps` fields of @FT_FaceRec.
553 * The currently active charmap is available as `face->charmap`. You
554 * should call @FT_Set_Charmap to change it.
557 * When a new face is created (either through @FT_New_Face or
558 * @FT_Open_Face), the library looks for a Unicode charmap within the
559 * list and automatically activates it. If there is no Unicode charmap,
560 * FreeType doesn't set an 'active' charmap.
563 * See @FT_CharMapRec for the publicly accessible fields of a given
566 typedef struct FT_CharMapRec_* FT_CharMap;
569 /**************************************************************************
575 * This macro converts four-letter tags into an unsigned long. It is
576 * used to define 'encoding' identifiers (see @FT_Encoding).
579 * Since many 16-bit compilers don't like 32-bit enumerations, you should
580 * redefine this macro in case of problems to something like this:
583 * #define FT_ENC_TAG( value, a, b, c, d ) value
586 * to get a simple enumeration without assigning special numbers.
590 #define FT_ENC_TAG( value, a, b, c, d ) \
591 value = ( ( (FT_UInt32)(a) << 24 ) | \
592 ( (FT_UInt32)(b) << 16 ) | \
593 ( (FT_UInt32)(c) << 8 ) | \
596 #endif /* FT_ENC_TAG */
599 /**************************************************************************
605 * An enumeration to specify character sets supported by charmaps. Used
606 * in the @FT_Select_Charmap API function.
609 * Despite the name, this enumeration lists specific character
610 * repertories (i.e., charsets), and not text encoding methods (e.g.,
611 * UTF-8, UTF-16, etc.).
613 * Other encodings might be defined in the future.
616 * FT_ENCODING_NONE ::
617 * The encoding value~0 is reserved for all formats except BDF, PCF,
618 * and Windows FNT; see below for more information.
620 * FT_ENCODING_UNICODE ::
621 * The Unicode character set. This value covers all versions of the
622 * Unicode repertoire, including ASCII and Latin-1. Most fonts include
623 * a Unicode charmap, but not all of them.
625 * For example, if you want to access Unicode value U+1F028 (and the
626 * font contains it), use value 0x1F028 as the input value for
627 * @FT_Get_Char_Index.
629 * FT_ENCODING_MS_SYMBOL ::
630 * Microsoft Symbol encoding, used to encode mathematical symbols and
631 * wingdings. For more information, see
632 * 'https://www.microsoft.com/typography/otspec/recom.htm#non-standard-symbol-fonts',
633 * 'http://www.kostis.net/charsets/symbol.htm', and
634 * 'http://www.kostis.net/charsets/wingding.htm'.
636 * This encoding uses character codes from the PUA (Private Unicode
637 * Area) in the range U+F020-U+F0FF.
639 * FT_ENCODING_SJIS ::
640 * Shift JIS encoding for Japanese. More info at
641 * 'https://en.wikipedia.org/wiki/Shift_JIS'. See note on multi-byte
645 * Corresponds to encoding systems mainly for Simplified Chinese as
646 * used in People's Republic of China (PRC). The encoding layout is
647 * based on GB~2312 and its supersets GBK and GB~18030.
649 * FT_ENCODING_BIG5 ::
650 * Corresponds to an encoding system for Traditional Chinese as used in
651 * Taiwan and Hong Kong.
653 * FT_ENCODING_WANSUNG ::
654 * Corresponds to the Korean encoding system known as Extended Wansung
655 * (MS Windows code page 949). For more information see
656 * 'https://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WindowsBestFit/bestfit949.txt'.
658 * FT_ENCODING_JOHAB ::
659 * The Korean standard character set (KS~C 5601-1992), which
660 * corresponds to MS Windows code page 1361. This character set
661 * includes all possible Hangul character combinations.
663 * FT_ENCODING_ADOBE_LATIN_1 ::
664 * Corresponds to a Latin-1 encoding as defined in a Type~1 PostScript
665 * font. It is limited to 256 character codes.
667 * FT_ENCODING_ADOBE_STANDARD ::
668 * Adobe Standard encoding, as found in Type~1, CFF, and OpenType/CFF
669 * fonts. It is limited to 256 character codes.
671 * FT_ENCODING_ADOBE_EXPERT ::
672 * Adobe Expert encoding, as found in Type~1, CFF, and OpenType/CFF
673 * fonts. It is limited to 256 character codes.
675 * FT_ENCODING_ADOBE_CUSTOM ::
676 * Corresponds to a custom encoding, as found in Type~1, CFF, and
677 * OpenType/CFF fonts. It is limited to 256 character codes.
679 * FT_ENCODING_APPLE_ROMAN ::
680 * Apple roman encoding. Many TrueType and OpenType fonts contain a
681 * charmap for this 8-bit encoding, since older versions of Mac OS are
684 * FT_ENCODING_OLD_LATIN_2 ::
685 * This value is deprecated and was neither used nor reported by
686 * FreeType. Don't use or test for it.
688 * FT_ENCODING_MS_SJIS ::
689 * Same as FT_ENCODING_SJIS. Deprecated.
691 * FT_ENCODING_MS_GB2312 ::
692 * Same as FT_ENCODING_PRC. Deprecated.
694 * FT_ENCODING_MS_BIG5 ::
695 * Same as FT_ENCODING_BIG5. Deprecated.
697 * FT_ENCODING_MS_WANSUNG ::
698 * Same as FT_ENCODING_WANSUNG. Deprecated.
700 * FT_ENCODING_MS_JOHAB ::
701 * Same as FT_ENCODING_JOHAB. Deprecated.
704 * By default, FreeType enables a Unicode charmap and tags it with
705 * `FT_ENCODING_UNICODE` when it is either provided or can be generated
706 * from PostScript glyph name dictionaries in the font file. All other
707 * encodings are considered legacy and tagged only if explicitly defined
708 * in the font file. Otherwise, `FT_ENCODING_NONE` is used.
710 * `FT_ENCODING_NONE` is set by the BDF and PCF drivers if the charmap is
711 * neither Unicode nor ISO-8859-1 (otherwise it is set to
712 * `FT_ENCODING_UNICODE`). Use @FT_Get_BDF_Charset_ID to find out which
713 * encoding is really present. If, for example, the `cs_registry` field
714 * is 'KOI8' and the `cs_encoding` field is 'R', the font is encoded in
717 * `FT_ENCODING_NONE` is always set (with a single exception) by the
718 * winfonts driver. Use @FT_Get_WinFNT_Header and examine the `charset`
719 * field of the @FT_WinFNT_HeaderRec structure to find out which encoding
720 * is really present. For example, @FT_WinFNT_ID_CP1251 (204) means
721 * Windows code page 1251 (for Russian).
723 * `FT_ENCODING_NONE` is set if `platform_id` is @TT_PLATFORM_MACINTOSH
724 * and `encoding_id` is not `TT_MAC_ID_ROMAN` (otherwise it is set to
725 * `FT_ENCODING_APPLE_ROMAN`).
727 * If `platform_id` is @TT_PLATFORM_MACINTOSH, use the function
728 * @FT_Get_CMap_Language_ID to query the Mac language ID that may be
729 * needed to be able to distinguish Apple encoding variants. See
731 * https://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/Readme.txt
733 * to get an idea how to do that. Basically, if the language ID is~0,
734 * don't use it, otherwise subtract 1 from the language ID. Then examine
735 * `encoding_id`. If, for example, `encoding_id` is `TT_MAC_ID_ROMAN`
736 * and the language ID (minus~1) is `TT_MAC_LANGID_GREEK`, it is the
737 * Greek encoding, not Roman. `TT_MAC_ID_ARABIC` with
738 * `TT_MAC_LANGID_FARSI` means the Farsi variant the Arabic encoding.
740 typedef enum FT_Encoding_
742 FT_ENC_TAG( FT_ENCODING_NONE, 0, 0, 0, 0 ),
744 FT_ENC_TAG( FT_ENCODING_MS_SYMBOL, 's', 'y', 'm', 'b' ),
745 FT_ENC_TAG( FT_ENCODING_UNICODE, 'u', 'n', 'i', 'c' ),
747 FT_ENC_TAG( FT_ENCODING_SJIS, 's', 'j', 'i', 's' ),
748 FT_ENC_TAG( FT_ENCODING_PRC, 'g', 'b', ' ', ' ' ),
749 FT_ENC_TAG( FT_ENCODING_BIG5, 'b', 'i', 'g', '5' ),
750 FT_ENC_TAG( FT_ENCODING_WANSUNG, 'w', 'a', 'n', 's' ),
751 FT_ENC_TAG( FT_ENCODING_JOHAB, 'j', 'o', 'h', 'a' ),
753 /* for backward compatibility */
754 FT_ENCODING_GB2312 = FT_ENCODING_PRC,
755 FT_ENCODING_MS_SJIS = FT_ENCODING_SJIS,
756 FT_ENCODING_MS_GB2312 = FT_ENCODING_PRC,
757 FT_ENCODING_MS_BIG5 = FT_ENCODING_BIG5,
758 FT_ENCODING_MS_WANSUNG = FT_ENCODING_WANSUNG,
759 FT_ENCODING_MS_JOHAB = FT_ENCODING_JOHAB,
761 FT_ENC_TAG( FT_ENCODING_ADOBE_STANDARD, 'A', 'D', 'O', 'B' ),
762 FT_ENC_TAG( FT_ENCODING_ADOBE_EXPERT, 'A', 'D', 'B', 'E' ),
763 FT_ENC_TAG( FT_ENCODING_ADOBE_CUSTOM, 'A', 'D', 'B', 'C' ),
764 FT_ENC_TAG( FT_ENCODING_ADOBE_LATIN_1, 'l', 'a', 't', '1' ),
766 FT_ENC_TAG( FT_ENCODING_OLD_LATIN_2, 'l', 'a', 't', '2' ),
768 FT_ENC_TAG( FT_ENCODING_APPLE_ROMAN, 'a', 'r', 'm', 'n' )
773 /* these constants are deprecated; use the corresponding `FT_Encoding` */
775 #define ft_encoding_none FT_ENCODING_NONE
776 #define ft_encoding_unicode FT_ENCODING_UNICODE
777 #define ft_encoding_symbol FT_ENCODING_MS_SYMBOL
778 #define ft_encoding_latin_1 FT_ENCODING_ADOBE_LATIN_1
779 #define ft_encoding_latin_2 FT_ENCODING_OLD_LATIN_2
780 #define ft_encoding_sjis FT_ENCODING_SJIS
781 #define ft_encoding_gb2312 FT_ENCODING_PRC
782 #define ft_encoding_big5 FT_ENCODING_BIG5
783 #define ft_encoding_wansung FT_ENCODING_WANSUNG
784 #define ft_encoding_johab FT_ENCODING_JOHAB
786 #define ft_encoding_adobe_standard FT_ENCODING_ADOBE_STANDARD
787 #define ft_encoding_adobe_expert FT_ENCODING_ADOBE_EXPERT
788 #define ft_encoding_adobe_custom FT_ENCODING_ADOBE_CUSTOM
789 #define ft_encoding_apple_roman FT_ENCODING_APPLE_ROMAN
792 /**************************************************************************
798 * The base charmap structure.
802 * A handle to the parent face object.
805 * An @FT_Encoding tag identifying the charmap. Use this with
806 * @FT_Select_Charmap.
809 * An ID number describing the platform for the following encoding ID.
810 * This comes directly from the TrueType specification and gets
811 * emulated for other formats.
814 * A platform-specific encoding number. This also comes from the
815 * TrueType specification and gets emulated similarly.
817 typedef struct FT_CharMapRec_
820 FT_Encoding encoding;
821 FT_UShort platform_id;
822 FT_UShort encoding_id;
827 /*************************************************************************/
828 /*************************************************************************/
830 /* B A S E O B J E C T C L A S S E S */
832 /*************************************************************************/
833 /*************************************************************************/
836 /**************************************************************************
842 * An opaque handle to an `FT_Face_InternalRec` structure that models the
843 * private data of a given @FT_Face object.
845 * This structure might change between releases of FreeType~2 and is not
846 * generally available to client applications.
848 typedef struct FT_Face_InternalRec_* FT_Face_Internal;
851 /**************************************************************************
857 * FreeType root face class structure. A face object models a typeface
862 * The number of faces in the font file. Some font formats can have
863 * multiple faces in a single font file.
866 * This field holds two different values. Bits 0-15 are the index of
867 * the face in the font file (starting with value~0). They are set
868 * to~0 if there is only one face in the font file.
870 * [Since 2.6.1] Bits 16-30 are relevant to GX and OpenType variation
871 * fonts only, holding the named instance index for the current face
872 * index (starting with value~1; value~0 indicates font access without
873 * a named instance). For non-variation fonts, bits 16-30 are ignored.
874 * If we have the third named instance of face~4, say, `face_index` is
877 * Bit 31 is always zero (this is, `face_index` is always a positive
880 * [Since 2.9] Changing the design coordinates with
881 * @FT_Set_Var_Design_Coordinates or @FT_Set_Var_Blend_Coordinates does
882 * not influence the named instance index value (only
883 * @FT_Set_Named_Instance does that).
886 * A set of bit flags that give important information about the face;
887 * see @FT_FACE_FLAG_XXX for the details.
890 * The lower 16~bits contain a set of bit flags indicating the style of
891 * the face; see @FT_STYLE_FLAG_XXX for the details.
893 * [Since 2.6.1] Bits 16-30 hold the number of named instances
894 * available for the current face if we have a GX or OpenType variation
895 * (sub)font. Bit 31 is always zero (this is, `style_flags` is always
896 * a positive value). Note that a variation font has always at least
897 * one named instance, namely the default instance.
900 * The number of glyphs in the face. If the face is scalable and has
901 * sbits (see `num_fixed_sizes`), it is set to the number of outline
904 * For CID-keyed fonts (not in an SFNT wrapper) this value gives the
905 * highest CID used in the font.
908 * The face's family name. This is an ASCII string, usually in
909 * English, that describes the typeface's family (like 'Times New
910 * Roman', 'Bodoni', 'Garamond', etc). This is a least common
911 * denominator used to list fonts. Some formats (TrueType & OpenType)
912 * provide localized and Unicode versions of this string. Applications
913 * should use the format-specific interface to access them. Can be
914 * `NULL` (e.g., in fonts embedded in a PDF file).
916 * In case the font doesn't provide a specific family name entry,
917 * FreeType tries to synthesize one, deriving it from other name
921 * The face's style name. This is an ASCII string, usually in English,
922 * that describes the typeface's style (like 'Italic', 'Bold',
923 * 'Condensed', etc). Not all font formats provide a style name, so
924 * this field is optional, and can be set to `NULL`. As for
925 * `family_name`, some formats provide localized and Unicode versions
926 * of this string. Applications should use the format-specific
927 * interface to access them.
930 * The number of bitmap strikes in the face. Even if the face is
931 * scalable, there might still be bitmap strikes, which are called
932 * 'sbits' in that case.
935 * An array of @FT_Bitmap_Size for all bitmap strikes in the face. It
936 * is set to `NULL` if there is no bitmap strike.
938 * Note that FreeType tries to sanitize the strike data since they are
939 * sometimes sloppy or incorrect, but this can easily fail.
942 * The number of charmaps in the face.
945 * An array of the charmaps of the face.
948 * A field reserved for client uses. See the @FT_Generic type
952 * The font bounding box. Coordinates are expressed in font units (see
953 * `units_per_EM`). The box is large enough to contain any glyph from
954 * the font. Thus, `bbox.yMax` can be seen as the 'maximum ascender',
955 * and `bbox.yMin` as the 'minimum descender'. Only relevant for
958 * Note that the bounding box might be off by (at least) one pixel for
959 * hinted fonts. See @FT_Size_Metrics for further discussion.
961 * Note that the bounding box does not vary in OpenType variable fonts
962 * and should only be used in relation to the default instance.
965 * The number of font units per EM square for this face. This is
966 * typically 2048 for TrueType fonts, and 1000 for Type~1 fonts. Only
967 * relevant for scalable formats.
970 * The typographic ascender of the face, expressed in font units. For
971 * font formats not having this information, it is set to `bbox.yMax`.
972 * Only relevant for scalable formats.
975 * The typographic descender of the face, expressed in font units. For
976 * font formats not having this information, it is set to `bbox.yMin`.
977 * Note that this field is negative for values below the baseline.
978 * Only relevant for scalable formats.
981 * This value is the vertical distance between two consecutive
982 * baselines, expressed in font units. It is always positive. Only
983 * relevant for scalable formats.
985 * If you want the global glyph height, use `ascender - descender`.
987 * max_advance_width ::
988 * The maximum advance width, in font units, for all glyphs in this
989 * face. This can be used to make word wrapping computations faster.
990 * Only relevant for scalable formats.
992 * max_advance_height ::
993 * The maximum advance height, in font units, for all glyphs in this
994 * face. This is only relevant for vertical layouts, and is set to
995 * `height` for fonts that do not provide vertical metrics. Only
996 * relevant for scalable formats.
998 * underline_position ::
999 * The position, in font units, of the underline line for this face.
1000 * It is the center of the underlining stem. Only relevant for
1003 * underline_thickness ::
1004 * The thickness, in font units, of the underline for this face. Only
1005 * relevant for scalable formats.
1008 * The face's associated glyph slot(s).
1011 * The current active size for this face.
1014 * The current active charmap for this face.
1017 * Fields may be changed after a call to @FT_Attach_File or
1018 * @FT_Attach_Stream.
1020 * For an OpenType variation font, the values of the following fields can
1021 * change after a call to @FT_Set_Var_Design_Coordinates (and friends) if
1022 * the font contains an 'MVAR' table: `ascender`, `descender`, `height`,
1023 * `underline_position`, and `underline_thickness`.
1025 * Especially for TrueType fonts see also the documentation for
1028 typedef struct FT_FaceRec_
1034 FT_Long style_flags;
1038 FT_String* family_name;
1039 FT_String* style_name;
1041 FT_Int num_fixed_sizes;
1042 FT_Bitmap_Size* available_sizes;
1044 FT_Int num_charmaps;
1045 FT_CharMap* charmaps;
1049 /*# The following member variables (down to `underline_thickness`) */
1050 /*# are only relevant to scalable outlines; cf. @FT_Bitmap_Size */
1051 /*# for bitmap fonts. */
1054 FT_UShort units_per_EM;
1059 FT_Short max_advance_width;
1060 FT_Short max_advance_height;
1062 FT_Short underline_position;
1063 FT_Short underline_thickness;
1075 FT_ListRec sizes_list;
1077 FT_Generic autohint; /* face-specific auto-hinter data */
1078 void* extensions; /* unused */
1080 FT_Face_Internal internal;
1087 /**************************************************************************
1093 * A list of bit flags used in the `face_flags` field of the @FT_FaceRec
1094 * structure. They inform client applications of properties of the
1095 * corresponding face.
1098 * FT_FACE_FLAG_SCALABLE ::
1099 * The face contains outline glyphs. Note that a face can contain
1100 * bitmap strikes also, i.e., a face can have both this flag and
1101 * @FT_FACE_FLAG_FIXED_SIZES set.
1103 * FT_FACE_FLAG_FIXED_SIZES ::
1104 * The face contains bitmap strikes. See also the `num_fixed_sizes`
1105 * and `available_sizes` fields of @FT_FaceRec.
1107 * FT_FACE_FLAG_FIXED_WIDTH ::
1108 * The face contains fixed-width characters (like Courier, Lucida,
1111 * FT_FACE_FLAG_SFNT ::
1112 * The face uses the SFNT storage scheme. For now, this means TrueType
1115 * FT_FACE_FLAG_HORIZONTAL ::
1116 * The face contains horizontal glyph metrics. This should be set for
1117 * all common formats.
1119 * FT_FACE_FLAG_VERTICAL ::
1120 * The face contains vertical glyph metrics. This is only available in
1121 * some formats, not all of them.
1123 * FT_FACE_FLAG_KERNING ::
1124 * The face contains kerning information. If set, the kerning distance
1125 * can be retrieved using the function @FT_Get_Kerning. Otherwise the
1126 * function always return the vector (0,0). Note that FreeType doesn't
1127 * handle kerning data from the SFNT 'GPOS' table (as present in many
1130 * FT_FACE_FLAG_FAST_GLYPHS ::
1131 * THIS FLAG IS DEPRECATED. DO NOT USE OR TEST IT.
1133 * FT_FACE_FLAG_MULTIPLE_MASTERS ::
1134 * The face contains multiple masters and is capable of interpolating
1135 * between them. Supported formats are Adobe MM, TrueType GX, and
1136 * OpenType variation fonts.
1138 * See section @multiple_masters for API details.
1140 * FT_FACE_FLAG_GLYPH_NAMES ::
1141 * The face contains glyph names, which can be retrieved using
1142 * @FT_Get_Glyph_Name. Note that some TrueType fonts contain broken
1143 * glyph name tables. Use the function @FT_Has_PS_Glyph_Names when
1146 * FT_FACE_FLAG_EXTERNAL_STREAM ::
1147 * Used internally by FreeType to indicate that a face's stream was
1148 * provided by the client application and should not be destroyed when
1149 * @FT_Done_Face is called. Don't read or test this flag.
1151 * FT_FACE_FLAG_HINTER ::
1152 * The font driver has a hinting machine of its own. For example, with
1153 * TrueType fonts, it makes sense to use data from the SFNT 'gasp'
1154 * table only if the native TrueType hinting engine (with the bytecode
1155 * interpreter) is available and active.
1157 * FT_FACE_FLAG_CID_KEYED ::
1158 * The face is CID-keyed. In that case, the face is not accessed by
1159 * glyph indices but by CID values. For subsetted CID-keyed fonts this
1160 * has the consequence that not all index values are a valid argument
1161 * to @FT_Load_Glyph. Only the CID values for which corresponding
1162 * glyphs in the subsetted font exist make `FT_Load_Glyph` return
1163 * successfully; in all other cases you get an
1164 * `FT_Err_Invalid_Argument` error.
1166 * Note that CID-keyed fonts that are in an SFNT wrapper (this is, all
1167 * OpenType/CFF fonts) don't have this flag set since the glyphs are
1168 * accessed in the normal way (using contiguous indices); the
1169 * 'CID-ness' isn't visible to the application.
1171 * FT_FACE_FLAG_TRICKY ::
1172 * The face is 'tricky', this is, it always needs the font format's
1173 * native hinting engine to get a reasonable result. A typical example
1174 * is the old Chinese font `mingli.ttf` (but not `mingliu.ttc`) that
1175 * uses TrueType bytecode instructions to move and scale all of its
1178 * It is not possible to auto-hint such fonts using
1179 * @FT_LOAD_FORCE_AUTOHINT; it will also ignore @FT_LOAD_NO_HINTING.
1180 * You have to set both @FT_LOAD_NO_HINTING and @FT_LOAD_NO_AUTOHINT to
1181 * really disable hinting; however, you probably never want this except
1182 * for demonstration purposes.
1184 * Currently, there are about a dozen TrueType fonts in the list of
1185 * tricky fonts; they are hard-coded in file `ttobjs.c`.
1187 * FT_FACE_FLAG_COLOR ::
1188 * [Since 2.5.1] The face has color glyph tables. See @FT_LOAD_COLOR
1189 * for more information.
1191 * FT_FACE_FLAG_VARIATION ::
1192 * [Since 2.9] Set if the current face (or named instance) has been
1193 * altered with @FT_Set_MM_Design_Coordinates,
1194 * @FT_Set_Var_Design_Coordinates, or @FT_Set_Var_Blend_Coordinates.
1195 * This flag is unset by a call to @FT_Set_Named_Instance.
1197 #define FT_FACE_FLAG_SCALABLE ( 1L << 0 )
1198 #define FT_FACE_FLAG_FIXED_SIZES ( 1L << 1 )
1199 #define FT_FACE_FLAG_FIXED_WIDTH ( 1L << 2 )
1200 #define FT_FACE_FLAG_SFNT ( 1L << 3 )
1201 #define FT_FACE_FLAG_HORIZONTAL ( 1L << 4 )
1202 #define FT_FACE_FLAG_VERTICAL ( 1L << 5 )
1203 #define FT_FACE_FLAG_KERNING ( 1L << 6 )
1204 #define FT_FACE_FLAG_FAST_GLYPHS ( 1L << 7 )
1205 #define FT_FACE_FLAG_MULTIPLE_MASTERS ( 1L << 8 )
1206 #define FT_FACE_FLAG_GLYPH_NAMES ( 1L << 9 )
1207 #define FT_FACE_FLAG_EXTERNAL_STREAM ( 1L << 10 )
1208 #define FT_FACE_FLAG_HINTER ( 1L << 11 )
1209 #define FT_FACE_FLAG_CID_KEYED ( 1L << 12 )
1210 #define FT_FACE_FLAG_TRICKY ( 1L << 13 )
1211 #define FT_FACE_FLAG_COLOR ( 1L << 14 )
1212 #define FT_FACE_FLAG_VARIATION ( 1L << 15 )
1215 /**************************************************************************
1221 * A macro that returns true whenever a face object contains horizontal
1222 * metrics (this is true for all font formats though).
1225 * @FT_HAS_VERTICAL can be used to check for vertical metrics.
1228 #define FT_HAS_HORIZONTAL( face ) \
1229 ( !!( (face)->face_flags & FT_FACE_FLAG_HORIZONTAL ) )
1232 /**************************************************************************
1238 * A macro that returns true whenever a face object contains real
1239 * vertical metrics (and not only synthesized ones).
1242 #define FT_HAS_VERTICAL( face ) \
1243 ( !!( (face)->face_flags & FT_FACE_FLAG_VERTICAL ) )
1246 /**************************************************************************
1252 * A macro that returns true whenever a face object contains kerning data
1253 * that can be accessed with @FT_Get_Kerning.
1256 #define FT_HAS_KERNING( face ) \
1257 ( !!( (face)->face_flags & FT_FACE_FLAG_KERNING ) )
1260 /**************************************************************************
1266 * A macro that returns true whenever a face object contains a scalable
1267 * font face (true for TrueType, Type~1, Type~42, CID, OpenType/CFF, and
1268 * PFR font formats).
1271 #define FT_IS_SCALABLE( face ) \
1272 ( !!( (face)->face_flags & FT_FACE_FLAG_SCALABLE ) )
1275 /**************************************************************************
1281 * A macro that returns true whenever a face object contains a font whose
1282 * format is based on the SFNT storage scheme. This usually means:
1283 * TrueType fonts, OpenType fonts, as well as SFNT-based embedded bitmap
1286 * If this macro is true, all functions defined in @FT_SFNT_NAMES_H and
1287 * @FT_TRUETYPE_TABLES_H are available.
1290 #define FT_IS_SFNT( face ) \
1291 ( !!( (face)->face_flags & FT_FACE_FLAG_SFNT ) )
1294 /**************************************************************************
1300 * A macro that returns true whenever a face object contains a font face
1301 * that contains fixed-width (or 'monospace', 'fixed-pitch', etc.)
1305 #define FT_IS_FIXED_WIDTH( face ) \
1306 ( !!( (face)->face_flags & FT_FACE_FLAG_FIXED_WIDTH ) )
1309 /**************************************************************************
1312 * FT_HAS_FIXED_SIZES
1315 * A macro that returns true whenever a face object contains some
1316 * embedded bitmaps. See the `available_sizes` field of the @FT_FaceRec
1320 #define FT_HAS_FIXED_SIZES( face ) \
1321 ( !!( (face)->face_flags & FT_FACE_FLAG_FIXED_SIZES ) )
1324 /**************************************************************************
1327 * FT_HAS_FAST_GLYPHS
1333 #define FT_HAS_FAST_GLYPHS( face ) 0
1336 /**************************************************************************
1339 * FT_HAS_GLYPH_NAMES
1342 * A macro that returns true whenever a face object contains some glyph
1343 * names that can be accessed through @FT_Get_Glyph_Name.
1346 #define FT_HAS_GLYPH_NAMES( face ) \
1347 ( !!( (face)->face_flags & FT_FACE_FLAG_GLYPH_NAMES ) )
1350 /**************************************************************************
1353 * FT_HAS_MULTIPLE_MASTERS
1356 * A macro that returns true whenever a face object contains some
1357 * multiple masters. The functions provided by @FT_MULTIPLE_MASTERS_H
1358 * are then available to choose the exact design you want.
1361 #define FT_HAS_MULTIPLE_MASTERS( face ) \
1362 ( !!( (face)->face_flags & FT_FACE_FLAG_MULTIPLE_MASTERS ) )
1365 /**************************************************************************
1368 * FT_IS_NAMED_INSTANCE
1371 * A macro that returns true whenever a face object is a named instance
1372 * of a GX or OpenType variation font.
1374 * [Since 2.9] Changing the design coordinates with
1375 * @FT_Set_Var_Design_Coordinates or @FT_Set_Var_Blend_Coordinates does
1376 * not influence the return value of this macro (only
1377 * @FT_Set_Named_Instance does that).
1383 #define FT_IS_NAMED_INSTANCE( face ) \
1384 ( !!( (face)->face_index & 0x7FFF0000L ) )
1387 /**************************************************************************
1393 * A macro that returns true whenever a face object has been altered by
1394 * @FT_Set_MM_Design_Coordinates, @FT_Set_Var_Design_Coordinates, or
1395 * @FT_Set_Var_Blend_Coordinates.
1401 #define FT_IS_VARIATION( face ) \
1402 ( !!( (face)->face_flags & FT_FACE_FLAG_VARIATION ) )
1405 /**************************************************************************
1411 * A macro that returns true whenever a face object contains a CID-keyed
1412 * font. See the discussion of @FT_FACE_FLAG_CID_KEYED for more details.
1414 * If this macro is true, all functions defined in @FT_CID_H are
1418 #define FT_IS_CID_KEYED( face ) \
1419 ( !!( (face)->face_flags & FT_FACE_FLAG_CID_KEYED ) )
1422 /**************************************************************************
1428 * A macro that returns true whenever a face represents a 'tricky' font.
1429 * See the discussion of @FT_FACE_FLAG_TRICKY for more details.
1432 #define FT_IS_TRICKY( face ) \
1433 ( !!( (face)->face_flags & FT_FACE_FLAG_TRICKY ) )
1436 /**************************************************************************
1442 * A macro that returns true whenever a face object contains tables for
1449 #define FT_HAS_COLOR( face ) \
1450 ( !!( (face)->face_flags & FT_FACE_FLAG_COLOR ) )
1453 /**************************************************************************
1459 * A list of bit flags to indicate the style of a given face. These are
1460 * used in the `style_flags` field of @FT_FaceRec.
1463 * FT_STYLE_FLAG_ITALIC ::
1464 * The face style is italic or oblique.
1466 * FT_STYLE_FLAG_BOLD ::
1470 * The style information as provided by FreeType is very basic. More
1471 * details are beyond the scope and should be done on a higher level (for
1472 * example, by analyzing various fields of the 'OS/2' table in SFNT based
1475 #define FT_STYLE_FLAG_ITALIC ( 1 << 0 )
1476 #define FT_STYLE_FLAG_BOLD ( 1 << 1 )
1479 /**************************************************************************
1485 * An opaque handle to an `FT_Size_InternalRec` structure, used to model
1486 * private data of a given @FT_Size object.
1488 typedef struct FT_Size_InternalRec_* FT_Size_Internal;
1491 /**************************************************************************
1497 * The size metrics structure gives the metrics of a size object.
1501 * The width of the scaled EM square in pixels, hence the term 'ppem'
1502 * (pixels per EM). It is also referred to as 'nominal width'.
1505 * The height of the scaled EM square in pixels, hence the term 'ppem'
1506 * (pixels per EM). It is also referred to as 'nominal height'.
1509 * A 16.16 fractional scaling value to convert horizontal metrics from
1510 * font units to 26.6 fractional pixels. Only relevant for scalable
1514 * A 16.16 fractional scaling value to convert vertical metrics from
1515 * font units to 26.6 fractional pixels. Only relevant for scalable
1519 * The ascender in 26.6 fractional pixels, rounded up to an integer
1520 * value. See @FT_FaceRec for the details.
1523 * The descender in 26.6 fractional pixels, rounded down to an integer
1524 * value. See @FT_FaceRec for the details.
1527 * The height in 26.6 fractional pixels, rounded to an integer value.
1528 * See @FT_FaceRec for the details.
1531 * The maximum advance width in 26.6 fractional pixels, rounded to an
1532 * integer value. See @FT_FaceRec for the details.
1535 * The scaling values, if relevant, are determined first during a size
1536 * changing operation. The remaining fields are then set by the driver.
1537 * For scalable formats, they are usually set to scaled values of the
1538 * corresponding fields in @FT_FaceRec. Some values like ascender or
1539 * descender are rounded for historical reasons; more precise values (for
1540 * outline fonts) can be derived by scaling the corresponding @FT_FaceRec
1541 * values manually, with code similar to the following.
1544 * scaled_ascender = FT_MulFix( face->ascender,
1545 * size_metrics->y_scale );
1548 * Note that due to glyph hinting and the selected rendering mode these
1549 * values are usually not exact; consequently, they must be treated as
1550 * unreliable with an error margin of at least one pixel!
1552 * Indeed, the only way to get the exact metrics is to render _all_
1553 * glyphs. As this would be a definite performance hit, it is up to
1554 * client applications to perform such computations.
1556 * The `FT_Size_Metrics` structure is valid for bitmap fonts also.
1559 * **TrueType fonts with native bytecode hinting**
1561 * All applications that handle TrueType fonts with native hinting must
1562 * be aware that TTFs expect different rounding of vertical font
1563 * dimensions. The application has to cater for this, especially if it
1564 * wants to rely on a TTF's vertical data (for example, to properly align
1565 * box characters vertically).
1567 * Only the application knows _in advance_ that it is going to use native
1568 * hinting for TTFs! FreeType, on the other hand, selects the hinting
1569 * mode not at the time of creating an @FT_Size object but much later,
1570 * namely while calling @FT_Load_Glyph.
1572 * Here is some pseudo code that illustrates a possible solution.
1575 * font_format = FT_Get_Font_Format( face );
1577 * if ( !strcmp( font_format, "TrueType" ) &&
1578 * do_native_bytecode_hinting )
1580 * ascender = ROUND( FT_MulFix( face->ascender,
1581 * size_metrics->y_scale ) );
1582 * descender = ROUND( FT_MulFix( face->descender,
1583 * size_metrics->y_scale ) );
1587 * ascender = size_metrics->ascender;
1588 * descender = size_metrics->descender;
1591 * height = size_metrics->height;
1592 * max_advance = size_metrics->max_advance;
1595 typedef struct FT_Size_Metrics_
1597 FT_UShort x_ppem; /* horizontal pixels per EM */
1598 FT_UShort y_ppem; /* vertical pixels per EM */
1600 FT_Fixed x_scale; /* scaling values used to convert font */
1601 FT_Fixed y_scale; /* units to 26.6 fractional pixels */
1603 FT_Pos ascender; /* ascender in 26.6 frac. pixels */
1604 FT_Pos descender; /* descender in 26.6 frac. pixels */
1605 FT_Pos height; /* text height in 26.6 frac. pixels */
1606 FT_Pos max_advance; /* max horizontal advance, in 26.6 pixels */
1611 /**************************************************************************
1617 * FreeType root size class structure. A size object models a face
1618 * object at a given size.
1622 * Handle to the parent face object.
1625 * A typeless pointer, unused by the FreeType library or any of its
1626 * drivers. It can be used by client applications to link their own
1627 * data to each size object.
1630 * Metrics for this size object. This field is read-only.
1632 typedef struct FT_SizeRec_
1634 FT_Face face; /* parent face object */
1635 FT_Generic generic; /* generic pointer for client uses */
1636 FT_Size_Metrics metrics; /* size metrics */
1637 FT_Size_Internal internal;
1642 /**************************************************************************
1648 * The subglyph structure is an internal object used to describe
1649 * subglyphs (for example, in the case of composites).
1652 * The subglyph implementation is not part of the high-level API, hence
1653 * the forward structure declaration.
1655 * You can however retrieve subglyph information with
1656 * @FT_Get_SubGlyph_Info.
1658 typedef struct FT_SubGlyphRec_* FT_SubGlyph;
1661 /**************************************************************************
1667 * An opaque handle to an `FT_Slot_InternalRec` structure, used to model
1668 * private data of a given @FT_GlyphSlot object.
1670 typedef struct FT_Slot_InternalRec_* FT_Slot_Internal;
1673 /**************************************************************************
1679 * FreeType root glyph slot class structure. A glyph slot is a container
1680 * where individual glyphs can be loaded, be they in outline or bitmap
1685 * A handle to the FreeType library instance this slot belongs to.
1688 * A handle to the parent face object.
1691 * In some cases (like some font tools), several glyph slots per face
1692 * object can be a good thing. As this is rare, the glyph slots are
1693 * listed through a direct, single-linked list using its `next` field.
1696 * [Since 2.10] The glyph index passed as an argument to @FT_Load_Glyph
1697 * while initializing the glyph slot.
1700 * A typeless pointer unused by the FreeType library or any of its
1701 * drivers. It can be used by client applications to link their own
1702 * data to each glyph slot object.
1705 * The metrics of the last loaded glyph in the slot. The returned
1706 * values depend on the last load flags (see the @FT_Load_Glyph API
1707 * function) and can be expressed either in 26.6 fractional pixels or
1710 * Note that even when the glyph image is transformed, the metrics are
1713 * linearHoriAdvance ::
1714 * The advance width of the unhinted glyph. Its value is expressed in
1715 * 16.16 fractional pixels, unless @FT_LOAD_LINEAR_DESIGN is set when
1716 * loading the glyph. This field can be important to perform correct
1717 * WYSIWYG layout. Only relevant for outline glyphs.
1719 * linearVertAdvance ::
1720 * The advance height of the unhinted glyph. Its value is expressed in
1721 * 16.16 fractional pixels, unless @FT_LOAD_LINEAR_DESIGN is set when
1722 * loading the glyph. This field can be important to perform correct
1723 * WYSIWYG layout. Only relevant for outline glyphs.
1726 * This shorthand is, depending on @FT_LOAD_IGNORE_TRANSFORM, the
1727 * transformed (hinted) advance width for the glyph, in 26.6 fractional
1728 * pixel format. As specified with @FT_LOAD_VERTICAL_LAYOUT, it uses
1729 * either the `horiAdvance` or the `vertAdvance` value of `metrics`
1733 * This field indicates the format of the image contained in the glyph
1734 * slot. Typically @FT_GLYPH_FORMAT_BITMAP, @FT_GLYPH_FORMAT_OUTLINE,
1735 * or @FT_GLYPH_FORMAT_COMPOSITE, but other values are possible.
1738 * This field is used as a bitmap descriptor. Note that the address
1739 * and content of the bitmap buffer can change between calls of
1740 * @FT_Load_Glyph and a few other functions.
1743 * The bitmap's left bearing expressed in integer pixels.
1746 * The bitmap's top bearing expressed in integer pixels. This is the
1747 * distance from the baseline to the top-most glyph scanline, upwards
1748 * y~coordinates being **positive**.
1751 * The outline descriptor for the current glyph image if its format is
1752 * @FT_GLYPH_FORMAT_OUTLINE. Once a glyph is loaded, `outline` can be
1753 * transformed, distorted, emboldened, etc. However, it must not be
1756 * [Since 2.10.1] If @FT_LOAD_NO_SCALE is set, outline coordinates of
1757 * OpenType variation fonts for a selected instance are internally
1758 * handled as 26.6 fractional font units but returned as (rounded)
1759 * integers, as expected. To get unrounded font units, don't use
1760 * @FT_LOAD_NO_SCALE but load the glyph with @FT_LOAD_NO_HINTING and
1761 * scale it, using the font's `units_per_EM` value as the ppem.
1764 * The number of subglyphs in a composite glyph. This field is only
1765 * valid for the composite glyph format that should normally only be
1766 * loaded with the @FT_LOAD_NO_RECURSE flag.
1769 * An array of subglyph descriptors for composite glyphs. There are
1770 * `num_subglyphs` elements in there. Currently internal to FreeType.
1773 * Certain font drivers can also return the control data for a given
1774 * glyph image (e.g. TrueType bytecode, Type~1 charstrings, etc.).
1775 * This field is a pointer to such data; it is currently internal to
1779 * This is the length in bytes of the control data. Currently internal
1786 * The difference between hinted and unhinted left side bearing while
1787 * auto-hinting is active. Zero otherwise.
1790 * The difference between hinted and unhinted right side bearing while
1791 * auto-hinting is active. Zero otherwise.
1794 * If @FT_Load_Glyph is called with default flags (see @FT_LOAD_DEFAULT)
1795 * the glyph image is loaded in the glyph slot in its native format
1796 * (e.g., an outline glyph for TrueType and Type~1 formats). [Since 2.9]
1797 * The prospective bitmap metrics are calculated according to
1798 * @FT_LOAD_TARGET_XXX and other flags even for the outline glyph, even
1799 * if @FT_LOAD_RENDER is not set.
1801 * This image can later be converted into a bitmap by calling
1802 * @FT_Render_Glyph. This function searches the current renderer for the
1803 * native image's format, then invokes it.
1805 * The renderer is in charge of transforming the native image through the
1806 * slot's face transformation fields, then converting it into a bitmap
1807 * that is returned in `slot->bitmap`.
1809 * Note that `slot->bitmap_left` and `slot->bitmap_top` are also used to
1810 * specify the position of the bitmap relative to the current pen
1811 * position (e.g., coordinates (0,0) on the baseline). Of course,
1812 * `slot->format` is also changed to @FT_GLYPH_FORMAT_BITMAP.
1814 * Here is a small pseudo code fragment that shows how to use `lsb_delta`
1815 * and `rsb_delta` to do fractional positioning of glyphs:
1818 * FT_GlyphSlot slot = face->glyph;
1819 * FT_Pos origin_x = 0;
1823 * <load glyph with `FT_Load_Glyph'>
1825 * FT_Outline_Translate( slot->outline, origin_x & 63, 0 );
1827 * <save glyph image, or render glyph, or ...>
1829 * <compute kern between current and next glyph
1830 * and add it to `origin_x'>
1832 * origin_x += slot->advance.x;
1833 * origin_x += slot->lsb_delta - slot->rsb_delta;
1837 * Here is another small pseudo code fragment that shows how to use
1838 * `lsb_delta` and `rsb_delta` to improve integer positioning of glyphs:
1841 * FT_GlyphSlot slot = face->glyph;
1842 * FT_Pos origin_x = 0;
1843 * FT_Pos prev_rsb_delta = 0;
1847 * <compute kern between current and previous glyph
1848 * and add it to `origin_x'>
1850 * <load glyph with `FT_Load_Glyph'>
1852 * if ( prev_rsb_delta - slot->lsb_delta > 32 )
1854 * else if ( prev_rsb_delta - slot->lsb_delta < -31 )
1857 * prev_rsb_delta = slot->rsb_delta;
1859 * <save glyph image, or render glyph, or ...>
1861 * origin_x += slot->advance.x;
1865 * If you use strong auto-hinting, you **must** apply these delta values!
1866 * Otherwise you will experience far too large inter-glyph spacing at
1867 * small rendering sizes in most cases. Note that it doesn't harm to use
1868 * the above code for other hinting modes also, since the delta values
1871 typedef struct FT_GlyphSlotRec_
1876 FT_UInt glyph_index; /* new in 2.10; was reserved previously */
1879 FT_Glyph_Metrics metrics;
1880 FT_Fixed linearHoriAdvance;
1881 FT_Fixed linearVertAdvance;
1884 FT_Glyph_Format format;
1892 FT_UInt num_subglyphs;
1893 FT_SubGlyph subglyphs;
1903 FT_Slot_Internal internal;
1908 /*************************************************************************/
1909 /*************************************************************************/
1911 /* F U N C T I O N S */
1913 /*************************************************************************/
1914 /*************************************************************************/
1917 /**************************************************************************
1923 * Initialize a new FreeType library object. The set of modules that are
1924 * registered by this function is determined at build time.
1928 * A handle to a new library object.
1931 * FreeType error code. 0~means success.
1934 * In case you want to provide your own memory allocating routines, use
1935 * @FT_New_Library instead, followed by a call to @FT_Add_Default_Modules
1936 * (or a series of calls to @FT_Add_Module) and
1937 * @FT_Set_Default_Properties.
1939 * See the documentation of @FT_Library and @FT_Face for multi-threading
1942 * If you need reference-counting (cf. @FT_Reference_Library), use
1943 * @FT_New_Library and @FT_Done_Library.
1945 * If compilation option `FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES` is
1946 * set, this function reads the `FREETYPE_PROPERTIES` environment
1947 * variable to control driver properties. See section @properties for
1950 FT_EXPORT( FT_Error )
1951 FT_Init_FreeType( FT_Library *alibrary );
1954 /**************************************************************************
1960 * Destroy a given FreeType library object and all of its children,
1961 * including resources, drivers, faces, sizes, etc.
1965 * A handle to the target library object.
1968 * FreeType error code. 0~means success.
1970 FT_EXPORT( FT_Error )
1971 FT_Done_FreeType( FT_Library library );
1974 /**************************************************************************
1980 * A list of bit field constants used within the `flags` field of the
1981 * @FT_Open_Args structure.
1985 * This is a memory-based stream.
1988 * Copy the stream from the `stream` field.
1990 * FT_OPEN_PATHNAME ::
1991 * Create a new input stream from a C~path name.
1994 * Use the `driver` field.
1997 * Use the `num_params` and `params` fields.
2000 * The `FT_OPEN_MEMORY`, `FT_OPEN_STREAM`, and `FT_OPEN_PATHNAME` flags
2001 * are mutually exclusive.
2003 #define FT_OPEN_MEMORY 0x1
2004 #define FT_OPEN_STREAM 0x2
2005 #define FT_OPEN_PATHNAME 0x4
2006 #define FT_OPEN_DRIVER 0x8
2007 #define FT_OPEN_PARAMS 0x10
2010 /* these constants are deprecated; use the corresponding `FT_OPEN_XXX` */
2011 /* values instead */
2012 #define ft_open_memory FT_OPEN_MEMORY
2013 #define ft_open_stream FT_OPEN_STREAM
2014 #define ft_open_pathname FT_OPEN_PATHNAME
2015 #define ft_open_driver FT_OPEN_DRIVER
2016 #define ft_open_params FT_OPEN_PARAMS
2019 /**************************************************************************
2025 * A simple structure to pass more or less generic parameters to
2026 * @FT_Open_Face and @FT_Face_Properties.
2030 * A four-byte identification tag.
2033 * A pointer to the parameter data.
2036 * The ID and function of parameters are driver-specific. See section
2037 * @parameter_tags for more information.
2039 typedef struct FT_Parameter_
2047 /**************************************************************************
2053 * A structure to indicate how to open a new font file or stream. A
2054 * pointer to such a structure can be used as a parameter for the
2055 * functions @FT_Open_Face and @FT_Attach_Stream.
2059 * A set of bit flags indicating how to use the structure.
2062 * The first byte of the file in memory.
2065 * The size in bytes of the file in memory.
2068 * A pointer to an 8-bit file pathname. The pointer is not owned by
2072 * A handle to a source stream object.
2075 * This field is exclusively used by @FT_Open_Face; it simply specifies
2076 * the font driver to use for opening the face. If set to `NULL`,
2077 * FreeType tries to load the face with each one of the drivers in its
2081 * The number of extra parameters.
2084 * Extra parameters passed to the font driver when opening a new face.
2087 * The stream type is determined by the contents of `flags` that are
2088 * tested in the following order by @FT_Open_Face:
2090 * If the @FT_OPEN_MEMORY bit is set, assume that this is a memory file
2091 * of `memory_size` bytes, located at `memory_address`. The data are not
2092 * copied, and the client is responsible for releasing and destroying
2093 * them _after_ the corresponding call to @FT_Done_Face.
2095 * Otherwise, if the @FT_OPEN_STREAM bit is set, assume that a custom
2096 * input stream `stream` is used.
2098 * Otherwise, if the @FT_OPEN_PATHNAME bit is set, assume that this is a
2099 * normal file and use `pathname` to open it.
2101 * If the @FT_OPEN_DRIVER bit is set, @FT_Open_Face only tries to open
2102 * the file with the driver whose handler is in `driver`.
2104 * If the @FT_OPEN_PARAMS bit is set, the parameters given by
2105 * `num_params` and `params` is used. They are ignored otherwise.
2107 * Ideally, both the `pathname` and `params` fields should be tagged as
2108 * 'const'; this is missing for API backward compatibility. In other
2109 * words, applications should treat them as read-only.
2111 typedef struct FT_Open_Args_
2114 const FT_Byte* memory_base;
2115 FT_Long memory_size;
2116 FT_String* pathname;
2120 FT_Parameter* params;
2125 /**************************************************************************
2131 * Call @FT_Open_Face to open a font by its pathname.
2135 * A handle to the library resource.
2139 * A path to the font file.
2142 * See @FT_Open_Face for a detailed description of this parameter.
2146 * A handle to a new face object. If `face_index` is greater than or
2147 * equal to zero, it must be non-`NULL`.
2150 * FreeType error code. 0~means success.
2153 * Use @FT_Done_Face to destroy the created @FT_Face object (along with
2154 * its slot and sizes).
2156 FT_EXPORT( FT_Error )
2157 FT_New_Face( FT_Library library,
2158 const char* filepathname,
2163 /**************************************************************************
2166 * FT_New_Memory_Face
2169 * Call @FT_Open_Face to open a font that has been loaded into memory.
2173 * A handle to the library resource.
2177 * A pointer to the beginning of the font data.
2180 * The size of the memory chunk used by the font data.
2183 * See @FT_Open_Face for a detailed description of this parameter.
2187 * A handle to a new face object. If `face_index` is greater than or
2188 * equal to zero, it must be non-`NULL`.
2191 * FreeType error code. 0~means success.
2194 * You must not deallocate the memory before calling @FT_Done_Face.
2196 FT_EXPORT( FT_Error )
2197 FT_New_Memory_Face( FT_Library library,
2198 const FT_Byte* file_base,
2204 /**************************************************************************
2210 * Create a face object from a given resource described by @FT_Open_Args.
2214 * A handle to the library resource.
2218 * A pointer to an `FT_Open_Args` structure that must be filled by the
2222 * This field holds two different values. Bits 0-15 are the index of
2223 * the face in the font file (starting with value~0). Set it to~0 if
2224 * there is only one face in the font file.
2226 * [Since 2.6.1] Bits 16-30 are relevant to GX and OpenType variation
2227 * fonts only, specifying the named instance index for the current face
2228 * index (starting with value~1; value~0 makes FreeType ignore named
2229 * instances). For non-variation fonts, bits 16-30 are ignored.
2230 * Assuming that you want to access the third named instance in face~4,
2231 * `face_index` should be set to 0x00030004. If you want to access
2232 * face~4 without variation handling, simply set `face_index` to
2235 * `FT_Open_Face` and its siblings can be used to quickly check whether
2236 * the font format of a given font resource is supported by FreeType.
2237 * In general, if the `face_index` argument is negative, the function's
2238 * return value is~0 if the font format is recognized, or non-zero
2239 * otherwise. The function allocates a more or less empty face handle
2240 * in `*aface` (if `aface` isn't `NULL`); the only two useful fields in
2241 * this special case are `face->num_faces` and `face->style_flags`.
2242 * For any negative value of `face_index`, `face->num_faces` gives the
2243 * number of faces within the font file. For the negative value
2244 * '-(N+1)' (with 'N' a non-negative 16-bit value), bits 16-30 in
2245 * `face->style_flags` give the number of named instances in face 'N'
2246 * if we have a variation font (or zero otherwise). After examination,
2247 * the returned @FT_Face structure should be deallocated with a call to
2252 * A handle to a new face object. If `face_index` is greater than or
2253 * equal to zero, it must be non-`NULL`.
2256 * FreeType error code. 0~means success.
2259 * Unlike FreeType 1.x, this function automatically creates a glyph slot
2260 * for the face object that can be accessed directly through
2263 * Each new face object created with this function also owns a default
2264 * @FT_Size object, accessible as `face->size`.
2266 * One @FT_Library instance can have multiple face objects, this is,
2267 * @FT_Open_Face and its siblings can be called multiple times using the
2268 * same `library` argument.
2270 * See the discussion of reference counters in the description of
2271 * @FT_Reference_Face.
2274 * To loop over all faces, use code similar to the following snippet
2275 * (omitting the error handling).
2280 * FT_Long i, num_faces;
2283 * error = FT_Open_Face( library, args, -1, &face );
2284 * if ( error ) { ... }
2286 * num_faces = face->num_faces;
2287 * FT_Done_Face( face );
2289 * for ( i = 0; i < num_faces; i++ )
2292 * error = FT_Open_Face( library, args, i, &face );
2294 * FT_Done_Face( face );
2299 * To loop over all valid values for `face_index`, use something similar
2300 * to the following snippet, again without error handling. The code
2301 * accesses all faces immediately (thus only a single call of
2302 * `FT_Open_Face` within the do-loop), with and without named instances.
2308 * FT_Long num_faces = 0;
2309 * FT_Long num_instances = 0;
2311 * FT_Long face_idx = 0;
2312 * FT_Long instance_idx = 0;
2317 * FT_Long id = ( instance_idx << 16 ) + face_idx;
2320 * error = FT_Open_Face( library, args, id, &face );
2321 * if ( error ) { ... }
2323 * num_faces = face->num_faces;
2324 * num_instances = face->style_flags >> 16;
2328 * FT_Done_Face( face );
2330 * if ( instance_idx < num_instances )
2338 * } while ( face_idx < num_faces )
2341 FT_EXPORT( FT_Error )
2342 FT_Open_Face( FT_Library library,
2343 const FT_Open_Args* args,
2348 /**************************************************************************
2354 * Call @FT_Attach_Stream to attach a file.
2358 * The target face object.
2365 * FreeType error code. 0~means success.
2367 FT_EXPORT( FT_Error )
2368 FT_Attach_File( FT_Face face,
2369 const char* filepathname );
2372 /**************************************************************************
2378 * 'Attach' data to a face object. Normally, this is used to read
2379 * additional information for the face object. For example, you can
2380 * attach an AFM file that comes with a Type~1 font to get the kerning
2381 * values and other metrics.
2385 * The target face object.
2389 * A pointer to @FT_Open_Args that must be filled by the caller.
2392 * FreeType error code. 0~means success.
2395 * The meaning of the 'attach' (i.e., what really happens when the new
2396 * file is read) is not fixed by FreeType itself. It really depends on
2397 * the font format (and thus the font driver).
2399 * Client applications are expected to know what they are doing when
2400 * invoking this function. Most drivers simply do not implement file or
2401 * stream attachments.
2403 FT_EXPORT( FT_Error )
2404 FT_Attach_Stream( FT_Face face,
2405 FT_Open_Args* parameters );
2408 /**************************************************************************
2414 * A counter gets initialized to~1 at the time an @FT_Face structure is
2415 * created. This function increments the counter. @FT_Done_Face then
2416 * only destroys a face if the counter is~1, otherwise it simply
2417 * decrements the counter.
2419 * This function helps in managing life-cycles of structures that
2420 * reference @FT_Face objects.
2424 * A handle to a target face object.
2427 * FreeType error code. 0~means success.
2432 FT_EXPORT( FT_Error )
2433 FT_Reference_Face( FT_Face face );
2436 /**************************************************************************
2442 * Discard a given face object, as well as all of its child slots and
2447 * A handle to a target face object.
2450 * FreeType error code. 0~means success.
2453 * See the discussion of reference counters in the description of
2454 * @FT_Reference_Face.
2456 FT_EXPORT( FT_Error )
2457 FT_Done_Face( FT_Face face );
2460 /**************************************************************************
2466 * Select a bitmap strike. To be more precise, this function sets the
2467 * scaling factors of the active @FT_Size object in a face so that
2468 * bitmaps from this particular strike are taken by @FT_Load_Glyph and
2473 * A handle to a target face object.
2477 * The index of the bitmap strike in the `available_sizes` field of
2478 * @FT_FaceRec structure.
2481 * FreeType error code. 0~means success.
2484 * For bitmaps embedded in outline fonts it is common that only a subset
2485 * of the available glyphs at a given ppem value is available. FreeType
2486 * silently uses outlines if there is no bitmap for a given glyph index.
2488 * For GX and OpenType variation fonts, a bitmap strike makes sense only
2489 * if the default instance is active (this is, no glyph variation takes
2490 * place); otherwise, FreeType simply ignores bitmap strikes. The same
2491 * is true for all named instances that are different from the default
2494 * Don't use this function if you are using the FreeType cache API.
2496 FT_EXPORT( FT_Error )
2497 FT_Select_Size( FT_Face face,
2498 FT_Int strike_index );
2501 /**************************************************************************
2504 * FT_Size_Request_Type
2507 * An enumeration type that lists the supported size request types, i.e.,
2508 * what input size (in font units) maps to the requested output size (in
2509 * pixels, as computed from the arguments of @FT_Size_Request).
2512 * FT_SIZE_REQUEST_TYPE_NOMINAL ::
2513 * The nominal size. The `units_per_EM` field of @FT_FaceRec is used
2514 * to determine both scaling values.
2516 * This is the standard scaling found in most applications. In
2517 * particular, use this size request type for TrueType fonts if they
2518 * provide optical scaling or something similar. Note, however, that
2519 * `units_per_EM` is a rather abstract value which bears no relation to
2520 * the actual size of the glyphs in a font.
2522 * FT_SIZE_REQUEST_TYPE_REAL_DIM ::
2523 * The real dimension. The sum of the `ascender` and (minus of) the
2524 * `descender` fields of @FT_FaceRec is used to determine both scaling
2527 * FT_SIZE_REQUEST_TYPE_BBOX ::
2528 * The font bounding box. The width and height of the `bbox` field of
2529 * @FT_FaceRec are used to determine the horizontal and vertical
2530 * scaling value, respectively.
2532 * FT_SIZE_REQUEST_TYPE_CELL ::
2533 * The `max_advance_width` field of @FT_FaceRec is used to determine
2534 * the horizontal scaling value; the vertical scaling value is
2535 * determined the same way as @FT_SIZE_REQUEST_TYPE_REAL_DIM does.
2536 * Finally, both scaling values are set to the smaller one. This type
2537 * is useful if you want to specify the font size for, say, a window of
2538 * a given dimension and 80x24 cells.
2540 * FT_SIZE_REQUEST_TYPE_SCALES ::
2541 * Specify the scaling values directly.
2544 * The above descriptions only apply to scalable formats. For bitmap
2545 * formats, the behaviour is up to the driver.
2547 * See the note section of @FT_Size_Metrics if you wonder how size
2548 * requesting relates to scaling values.
2550 typedef enum FT_Size_Request_Type_
2552 FT_SIZE_REQUEST_TYPE_NOMINAL,
2553 FT_SIZE_REQUEST_TYPE_REAL_DIM,
2554 FT_SIZE_REQUEST_TYPE_BBOX,
2555 FT_SIZE_REQUEST_TYPE_CELL,
2556 FT_SIZE_REQUEST_TYPE_SCALES,
2558 FT_SIZE_REQUEST_TYPE_MAX
2560 } FT_Size_Request_Type;
2563 /**************************************************************************
2566 * FT_Size_RequestRec
2569 * A structure to model a size request.
2573 * See @FT_Size_Request_Type.
2576 * The desired width, given as a 26.6 fractional point value (with 72pt
2580 * The desired height, given as a 26.6 fractional point value (with
2584 * The horizontal resolution (dpi, i.e., pixels per inch). If set to
2585 * zero, `width` is treated as a 26.6 fractional **pixel** value, which
2586 * gets internally rounded to an integer.
2589 * The vertical resolution (dpi, i.e., pixels per inch). If set to
2590 * zero, `height` is treated as a 26.6 fractional **pixel** value,
2591 * which gets internally rounded to an integer.
2594 * If `width` is zero, the horizontal scaling value is set equal to the
2595 * vertical scaling value, and vice versa.
2597 * If `type` is `FT_SIZE_REQUEST_TYPE_SCALES`, `width` and `height` are
2598 * interpreted directly as 16.16 fractional scaling values, without any
2599 * further modification, and both `horiResolution` and `vertResolution`
2602 typedef struct FT_Size_RequestRec_
2604 FT_Size_Request_Type type;
2607 FT_UInt horiResolution;
2608 FT_UInt vertResolution;
2610 } FT_Size_RequestRec;
2613 /**************************************************************************
2619 * A handle to a size request structure.
2621 typedef struct FT_Size_RequestRec_ *FT_Size_Request;
2624 /**************************************************************************
2630 * Resize the scale of the active @FT_Size object in a face.
2634 * A handle to a target face object.
2638 * A pointer to a @FT_Size_RequestRec.
2641 * FreeType error code. 0~means success.
2644 * Although drivers may select the bitmap strike matching the request,
2645 * you should not rely on this if you intend to select a particular
2646 * bitmap strike. Use @FT_Select_Size instead in that case.
2648 * The relation between the requested size and the resulting glyph size
2649 * is dependent entirely on how the size is defined in the source face.
2650 * The font designer chooses the final size of each glyph relative to
2651 * this size. For more information refer to
2652 * 'https://www.freetype.org/freetype2/docs/glyphs/glyphs-2.html'.
2654 * Contrary to @FT_Set_Char_Size, this function doesn't have special code
2655 * to normalize zero-valued widths, heights, or resolutions (which lead
2656 * to errors in most cases).
2658 * Don't use this function if you are using the FreeType cache API.
2660 FT_EXPORT( FT_Error )
2661 FT_Request_Size( FT_Face face,
2662 FT_Size_Request req );
2665 /**************************************************************************
2671 * Call @FT_Request_Size to request the nominal size (in points).
2675 * A handle to a target face object.
2679 * The nominal width, in 26.6 fractional points.
2682 * The nominal height, in 26.6 fractional points.
2684 * horz_resolution ::
2685 * The horizontal resolution in dpi.
2687 * vert_resolution ::
2688 * The vertical resolution in dpi.
2691 * FreeType error code. 0~means success.
2694 * While this function allows fractional points as input values, the
2695 * resulting ppem value for the given resolution is always rounded to the
2698 * If either the character width or height is zero, it is set equal to
2701 * If either the horizontal or vertical resolution is zero, it is set
2702 * equal to the other value.
2704 * A character width or height smaller than 1pt is set to 1pt; if both
2705 * resolution values are zero, they are set to 72dpi.
2707 * Don't use this function if you are using the FreeType cache API.
2709 FT_EXPORT( FT_Error )
2710 FT_Set_Char_Size( FT_Face face,
2711 FT_F26Dot6 char_width,
2712 FT_F26Dot6 char_height,
2713 FT_UInt horz_resolution,
2714 FT_UInt vert_resolution );
2717 /**************************************************************************
2720 * FT_Set_Pixel_Sizes
2723 * Call @FT_Request_Size to request the nominal size (in pixels).
2727 * A handle to the target face object.
2731 * The nominal width, in pixels.
2734 * The nominal height, in pixels.
2737 * FreeType error code. 0~means success.
2740 * You should not rely on the resulting glyphs matching or being
2741 * constrained to this pixel size. Refer to @FT_Request_Size to
2742 * understand how requested sizes relate to actual sizes.
2744 * Don't use this function if you are using the FreeType cache API.
2746 FT_EXPORT( FT_Error )
2747 FT_Set_Pixel_Sizes( FT_Face face,
2748 FT_UInt pixel_width,
2749 FT_UInt pixel_height );
2752 /**************************************************************************
2758 * Load a glyph into the glyph slot of a face object.
2762 * A handle to the target face object where the glyph is loaded.
2766 * The index of the glyph in the font file. For CID-keyed fonts
2767 * (either in PS or in CFF format) this argument specifies the CID
2771 * A flag indicating what to load for this glyph. The @FT_LOAD_XXX
2772 * constants can be used to control the glyph loading process (e.g.,
2773 * whether the outline should be scaled, whether to load bitmaps or
2774 * not, whether to hint the outline, etc).
2777 * FreeType error code. 0~means success.
2780 * The loaded glyph may be transformed. See @FT_Set_Transform for the
2783 * For subsetted CID-keyed fonts, `FT_Err_Invalid_Argument` is returned
2784 * for invalid CID values (this is, for CID values that don't have a
2785 * corresponding glyph in the font). See the discussion of the
2786 * @FT_FACE_FLAG_CID_KEYED flag for more details.
2788 * If you receive `FT_Err_Glyph_Too_Big`, try getting the glyph outline
2789 * at EM size, then scale it manually and fill it as a graphics
2792 FT_EXPORT( FT_Error )
2793 FT_Load_Glyph( FT_Face face,
2794 FT_UInt glyph_index,
2795 FT_Int32 load_flags );
2798 /**************************************************************************
2804 * Load a glyph into the glyph slot of a face object, accessed by its
2809 * A handle to a target face object where the glyph is loaded.
2813 * The glyph's character code, according to the current charmap used in
2817 * A flag indicating what to load for this glyph. The @FT_LOAD_XXX
2818 * constants can be used to control the glyph loading process (e.g.,
2819 * whether the outline should be scaled, whether to load bitmaps or
2820 * not, whether to hint the outline, etc).
2823 * FreeType error code. 0~means success.
2826 * This function simply calls @FT_Get_Char_Index and @FT_Load_Glyph.
2828 * Many fonts contain glyphs that can't be loaded by this function since
2829 * its glyph indices are not listed in any of the font's charmaps.
2831 * If no active cmap is set up (i.e., `face->charmap` is zero), the call
2832 * to @FT_Get_Char_Index is omitted, and the function behaves identically
2833 * to @FT_Load_Glyph.
2835 FT_EXPORT( FT_Error )
2836 FT_Load_Char( FT_Face face,
2838 FT_Int32 load_flags );
2841 /**************************************************************************
2847 * A list of bit field constants for @FT_Load_Glyph to indicate what kind
2848 * of operations to perform during glyph loading.
2851 * FT_LOAD_DEFAULT ::
2852 * Corresponding to~0, this value is used as the default glyph load
2853 * operation. In this case, the following happens:
2855 * 1. FreeType looks for a bitmap for the glyph corresponding to the
2856 * face's current size. If one is found, the function returns. The
2857 * bitmap data can be accessed from the glyph slot (see note below).
2859 * 2. If no embedded bitmap is searched for or found, FreeType looks
2860 * for a scalable outline. If one is found, it is loaded from the font
2861 * file, scaled to device pixels, then 'hinted' to the pixel grid in
2862 * order to optimize it. The outline data can be accessed from the
2863 * glyph slot (see note below).
2865 * Note that by default the glyph loader doesn't render outlines into
2866 * bitmaps. The following flags are used to modify this default
2867 * behaviour to more specific and useful cases.
2869 * FT_LOAD_NO_SCALE ::
2870 * Don't scale the loaded outline glyph but keep it in font units.
2872 * This flag implies @FT_LOAD_NO_HINTING and @FT_LOAD_NO_BITMAP, and
2873 * unsets @FT_LOAD_RENDER.
2875 * If the font is 'tricky' (see @FT_FACE_FLAG_TRICKY for more), using
2876 * `FT_LOAD_NO_SCALE` usually yields meaningless outlines because the
2877 * subglyphs must be scaled and positioned with hinting instructions.
2878 * This can be solved by loading the font without `FT_LOAD_NO_SCALE`
2879 * and setting the character size to `font->units_per_EM`.
2881 * FT_LOAD_NO_HINTING ::
2882 * Disable hinting. This generally generates 'blurrier' bitmap glyphs
2883 * when the glyph are rendered in any of the anti-aliased modes. See
2884 * also the note below.
2886 * This flag is implied by @FT_LOAD_NO_SCALE.
2889 * Call @FT_Render_Glyph after the glyph is loaded. By default, the
2890 * glyph is rendered in @FT_RENDER_MODE_NORMAL mode. This can be
2891 * overridden by @FT_LOAD_TARGET_XXX or @FT_LOAD_MONOCHROME.
2893 * This flag is unset by @FT_LOAD_NO_SCALE.
2895 * FT_LOAD_NO_BITMAP ::
2896 * Ignore bitmap strikes when loading. Bitmap-only fonts ignore this
2899 * @FT_LOAD_NO_SCALE always sets this flag.
2901 * FT_LOAD_VERTICAL_LAYOUT ::
2902 * Load the glyph for vertical text layout. In particular, the
2903 * `advance` value in the @FT_GlyphSlotRec structure is set to the
2904 * `vertAdvance` value of the `metrics` field.
2906 * In case @FT_HAS_VERTICAL doesn't return true, you shouldn't use this
2907 * flag currently. Reason is that in this case vertical metrics get
2908 * synthesized, and those values are not always consistent across
2909 * various font formats.
2911 * FT_LOAD_FORCE_AUTOHINT ::
2912 * Prefer the auto-hinter over the font's native hinter. See also the
2915 * FT_LOAD_PEDANTIC ::
2916 * Make the font driver perform pedantic verifications during glyph
2917 * loading and hinting. This is mostly used to detect broken glyphs in
2918 * fonts. By default, FreeType tries to handle broken fonts also.
2920 * In particular, errors from the TrueType bytecode engine are not
2921 * passed to the application if this flag is not set; this might result
2922 * in partially hinted or distorted glyphs in case a glyph's bytecode
2925 * FT_LOAD_NO_RECURSE ::
2926 * Don't load composite glyphs recursively. Instead, the font driver
2927 * fills the `num_subglyph` and `subglyphs` values of the glyph slot;
2928 * it also sets `glyph->format` to @FT_GLYPH_FORMAT_COMPOSITE. The
2929 * description of subglyphs can then be accessed with
2930 * @FT_Get_SubGlyph_Info.
2932 * Don't use this flag for retrieving metrics information since some
2933 * font drivers only return rudimentary data.
2935 * This flag implies @FT_LOAD_NO_SCALE and @FT_LOAD_IGNORE_TRANSFORM.
2937 * FT_LOAD_IGNORE_TRANSFORM ::
2938 * Ignore the transform matrix set by @FT_Set_Transform.
2940 * FT_LOAD_MONOCHROME ::
2941 * This flag is used with @FT_LOAD_RENDER to indicate that you want to
2942 * render an outline glyph to a 1-bit monochrome bitmap glyph, with
2943 * 8~pixels packed into each byte of the bitmap data.
2945 * Note that this has no effect on the hinting algorithm used. You
2946 * should rather use @FT_LOAD_TARGET_MONO so that the
2947 * monochrome-optimized hinting algorithm is used.
2949 * FT_LOAD_LINEAR_DESIGN ::
2950 * Keep `linearHoriAdvance` and `linearVertAdvance` fields of
2951 * @FT_GlyphSlotRec in font units. See @FT_GlyphSlotRec for details.
2953 * FT_LOAD_NO_AUTOHINT ::
2954 * Disable the auto-hinter. See also the note below.
2957 * Load colored glyphs. There are slight differences depending on the
2960 * [Since 2.5] Load embedded color bitmap images. The resulting color
2961 * bitmaps, if available, will have the @FT_PIXEL_MODE_BGRA format,
2962 * with pre-multiplied color channels. If the flag is not set and
2963 * color bitmaps are found, they are converted to 256-level gray
2964 * bitmaps, using the @FT_PIXEL_MODE_GRAY format.
2966 * [Since 2.10, experimental] If the glyph index contains an entry in
2967 * the face's 'COLR' table with a 'CPAL' palette table (as defined in
2968 * the OpenType specification), make @FT_Render_Glyph provide a default
2969 * blending of the color glyph layers associated with the glyph index,
2970 * using the same bitmap format as embedded color bitmap images. This
2971 * is mainly for convenience; for full control of color layers use
2972 * @FT_Get_Color_Glyph_Layer and FreeType's color functions like
2973 * @FT_Palette_Select instead of setting @FT_LOAD_COLOR for rendering
2974 * so that the client application can handle blending by itself.
2976 * FT_LOAD_COMPUTE_METRICS ::
2977 * [Since 2.6.1] Compute glyph metrics from the glyph data, without the
2978 * use of bundled metrics tables (for example, the 'hdmx' table in
2979 * TrueType fonts). This flag is mainly used by font validating or
2980 * font editing applications, which need to ignore, verify, or edit
2983 * Currently, this flag is only implemented for TrueType fonts.
2985 * FT_LOAD_BITMAP_METRICS_ONLY ::
2986 * [Since 2.7.1] Request loading of the metrics and bitmap image
2987 * information of a (possibly embedded) bitmap glyph without allocating
2988 * or copying the bitmap image data itself. No effect if the target
2989 * glyph is not a bitmap image.
2991 * This flag unsets @FT_LOAD_RENDER.
2993 * FT_LOAD_CROP_BITMAP ::
2994 * Ignored. Deprecated.
2996 * FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ::
2997 * Ignored. Deprecated.
3000 * By default, hinting is enabled and the font's native hinter (see
3001 * @FT_FACE_FLAG_HINTER) is preferred over the auto-hinter. You can
3002 * disable hinting by setting @FT_LOAD_NO_HINTING or change the
3003 * precedence by setting @FT_LOAD_FORCE_AUTOHINT. You can also set
3004 * @FT_LOAD_NO_AUTOHINT in case you don't want the auto-hinter to be used
3007 * See the description of @FT_FACE_FLAG_TRICKY for a special exception
3008 * (affecting only a handful of Asian fonts).
3010 * Besides deciding which hinter to use, you can also decide which
3011 * hinting algorithm to use. See @FT_LOAD_TARGET_XXX for details.
3013 * Note that the auto-hinter needs a valid Unicode cmap (either a native
3014 * one or synthesized by FreeType) for producing correct results. If a
3015 * font provides an incorrect mapping (for example, assigning the
3016 * character code U+005A, LATIN CAPITAL LETTER~Z, to a glyph depicting a
3017 * mathematical integral sign), the auto-hinter might produce useless
3021 #define FT_LOAD_DEFAULT 0x0
3022 #define FT_LOAD_NO_SCALE ( 1L << 0 )
3023 #define FT_LOAD_NO_HINTING ( 1L << 1 )
3024 #define FT_LOAD_RENDER ( 1L << 2 )
3025 #define FT_LOAD_NO_BITMAP ( 1L << 3 )
3026 #define FT_LOAD_VERTICAL_LAYOUT ( 1L << 4 )
3027 #define FT_LOAD_FORCE_AUTOHINT ( 1L << 5 )
3028 #define FT_LOAD_CROP_BITMAP ( 1L << 6 )
3029 #define FT_LOAD_PEDANTIC ( 1L << 7 )
3030 #define FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ( 1L << 9 )
3031 #define FT_LOAD_NO_RECURSE ( 1L << 10 )
3032 #define FT_LOAD_IGNORE_TRANSFORM ( 1L << 11 )
3033 #define FT_LOAD_MONOCHROME ( 1L << 12 )
3034 #define FT_LOAD_LINEAR_DESIGN ( 1L << 13 )
3035 #define FT_LOAD_NO_AUTOHINT ( 1L << 15 )
3036 /* Bits 16-19 are used by `FT_LOAD_TARGET_` */
3037 #define FT_LOAD_COLOR ( 1L << 20 )
3038 #define FT_LOAD_COMPUTE_METRICS ( 1L << 21 )
3039 #define FT_LOAD_BITMAP_METRICS_ONLY ( 1L << 22 )
3043 /* used internally only by certain font drivers */
3044 #define FT_LOAD_ADVANCE_ONLY ( 1L << 8 )
3045 #define FT_LOAD_SBITS_ONLY ( 1L << 14 )
3048 /**************************************************************************
3051 * FT_LOAD_TARGET_XXX
3054 * A list of values to select a specific hinting algorithm for the
3055 * hinter. You should OR one of these values to your `load_flags` when
3056 * calling @FT_Load_Glyph.
3058 * Note that a font's native hinters may ignore the hinting algorithm you
3059 * have specified (e.g., the TrueType bytecode interpreter). You can set
3060 * @FT_LOAD_FORCE_AUTOHINT to ensure that the auto-hinter is used.
3063 * FT_LOAD_TARGET_NORMAL ::
3064 * The default hinting algorithm, optimized for standard gray-level
3065 * rendering. For monochrome output, use @FT_LOAD_TARGET_MONO instead.
3067 * FT_LOAD_TARGET_LIGHT ::
3068 * A lighter hinting algorithm for gray-level modes. Many generated
3069 * glyphs are fuzzier but better resemble their original shape. This
3070 * is achieved by snapping glyphs to the pixel grid only vertically
3071 * (Y-axis), as is done by FreeType's new CFF engine or Microsoft's
3072 * ClearType font renderer. This preserves inter-glyph spacing in
3073 * horizontal text. The snapping is done either by the native font
3074 * driver, if the driver itself and the font support it, or by the
3077 * Advance widths are rounded to integer values; however, using the
3078 * `lsb_delta` and `rsb_delta` fields of @FT_GlyphSlotRec, it is
3079 * possible to get fractional advance widths for subpixel positioning
3080 * (which is recommended to use).
3082 * If configuration option `AF_CONFIG_OPTION_TT_SIZE_METRICS` is
3083 * active, TrueType-like metrics are used to make this mode behave
3084 * similarly as in unpatched FreeType versions between 2.4.6 and 2.7.1
3087 * FT_LOAD_TARGET_MONO ::
3088 * Strong hinting algorithm that should only be used for monochrome
3089 * output. The result is probably unpleasant if the glyph is rendered
3090 * in non-monochrome modes.
3092 * Note that for outline fonts only the TrueType font driver has proper
3093 * monochrome hinting support, provided the TTFs contain hints for B/W
3094 * rendering (which most fonts no longer provide). If these conditions
3095 * are not met it is very likely that you get ugly results at smaller
3098 * FT_LOAD_TARGET_LCD ::
3099 * A variant of @FT_LOAD_TARGET_LIGHT optimized for horizontally
3100 * decimated LCD displays.
3102 * FT_LOAD_TARGET_LCD_V ::
3103 * A variant of @FT_LOAD_TARGET_NORMAL optimized for vertically
3104 * decimated LCD displays.
3107 * You should use only _one_ of the `FT_LOAD_TARGET_XXX` values in your
3108 * `load_flags`. They can't be ORed.
3110 * If @FT_LOAD_RENDER is also set, the glyph is rendered in the
3111 * corresponding mode (i.e., the mode that matches the used algorithm
3112 * best). An exception is `FT_LOAD_TARGET_MONO` since it implies
3113 * @FT_LOAD_MONOCHROME.
3115 * You can use a hinting algorithm that doesn't correspond to the same
3116 * rendering mode. As an example, it is possible to use the 'light'
3117 * hinting algorithm and have the results rendered in horizontal LCD
3118 * pixel mode, with code like
3121 * FT_Load_Glyph( face, glyph_index,
3122 * load_flags | FT_LOAD_TARGET_LIGHT );
3124 * FT_Render_Glyph( face->glyph, FT_RENDER_MODE_LCD );
3127 * In general, you should stick with one rendering mode. For example,
3128 * switching between @FT_LOAD_TARGET_NORMAL and @FT_LOAD_TARGET_MONO
3129 * enforces a lot of recomputation for TrueType fonts, which is slow.
3130 * Another reason is caching: Selecting a different mode usually causes
3131 * changes in both the outlines and the rasterized bitmaps; it is thus
3132 * necessary to empty the cache after a mode switch to avoid false hits.
3135 #define FT_LOAD_TARGET_( x ) ( (FT_Int32)( (x) & 15 ) << 16 )
3137 #define FT_LOAD_TARGET_NORMAL FT_LOAD_TARGET_( FT_RENDER_MODE_NORMAL )
3138 #define FT_LOAD_TARGET_LIGHT FT_LOAD_TARGET_( FT_RENDER_MODE_LIGHT )
3139 #define FT_LOAD_TARGET_MONO FT_LOAD_TARGET_( FT_RENDER_MODE_MONO )
3140 #define FT_LOAD_TARGET_LCD FT_LOAD_TARGET_( FT_RENDER_MODE_LCD )
3141 #define FT_LOAD_TARGET_LCD_V FT_LOAD_TARGET_( FT_RENDER_MODE_LCD_V )
3144 /**************************************************************************
3147 * FT_LOAD_TARGET_MODE
3150 * Return the @FT_Render_Mode corresponding to a given
3151 * @FT_LOAD_TARGET_XXX value.
3154 #define FT_LOAD_TARGET_MODE( x ) ( (FT_Render_Mode)( ( (x) >> 16 ) & 15 ) )
3157 /**************************************************************************
3163 * Set the transformation that is applied to glyph images when they are
3164 * loaded into a glyph slot through @FT_Load_Glyph.
3168 * A handle to the source face object.
3172 * A pointer to the transformation's 2x2 matrix. Use `NULL` for the
3175 * A pointer to the translation vector. Use `NULL` for the null vector.
3178 * This function is provided as a convenience, but keep in mind that
3179 * @FT_Matrix coefficients are only 16.16 fixed point values, which can
3180 * limit the accuracy of the results. Using floating-point computations
3181 * to perform the transform directly in client code instead will always
3182 * yield better numbers.
3184 * The transformation is only applied to scalable image formats after the
3185 * glyph has been loaded. It means that hinting is unaltered by the
3186 * transformation and is performed on the character size given in the
3187 * last call to @FT_Set_Char_Size or @FT_Set_Pixel_Sizes.
3189 * Note that this also transforms the `face.glyph.advance` field, but
3190 * **not** the values in `face.glyph.metrics`.
3193 FT_Set_Transform( FT_Face face,
3198 /**************************************************************************
3204 * Render modes supported by FreeType~2. Each mode corresponds to a
3205 * specific type of scanline conversion performed on the outline.
3207 * For bitmap fonts and embedded bitmaps the `bitmap->pixel_mode` field
3208 * in the @FT_GlyphSlotRec structure gives the format of the returned
3211 * All modes except @FT_RENDER_MODE_MONO use 256 levels of opacity,
3212 * indicating pixel coverage. Use linear alpha blending and gamma
3213 * correction to correctly render non-monochrome glyph bitmaps onto a
3214 * surface; see @FT_Render_Glyph.
3217 * FT_RENDER_MODE_NORMAL ::
3218 * Default render mode; it corresponds to 8-bit anti-aliased bitmaps.
3220 * FT_RENDER_MODE_LIGHT ::
3221 * This is equivalent to @FT_RENDER_MODE_NORMAL. It is only defined as
3222 * a separate value because render modes are also used indirectly to
3223 * define hinting algorithm selectors. See @FT_LOAD_TARGET_XXX for
3226 * FT_RENDER_MODE_MONO ::
3227 * This mode corresponds to 1-bit bitmaps (with 2~levels of opacity).
3229 * FT_RENDER_MODE_LCD ::
3230 * This mode corresponds to horizontal RGB and BGR subpixel displays
3231 * like LCD screens. It produces 8-bit bitmaps that are 3~times the
3232 * width of the original glyph outline in pixels, and which use the
3233 * @FT_PIXEL_MODE_LCD mode.
3235 * FT_RENDER_MODE_LCD_V ::
3236 * This mode corresponds to vertical RGB and BGR subpixel displays
3237 * (like PDA screens, rotated LCD displays, etc.). It produces 8-bit
3238 * bitmaps that are 3~times the height of the original glyph outline in
3239 * pixels and use the @FT_PIXEL_MODE_LCD_V mode.
3242 * The selected render mode only affects vector glyphs of a font.
3243 * Embedded bitmaps often have a different pixel mode like
3244 * @FT_PIXEL_MODE_MONO. You can use @FT_Bitmap_Convert to transform them
3245 * into 8-bit pixmaps.
3247 typedef enum FT_Render_Mode_
3249 FT_RENDER_MODE_NORMAL = 0,
3250 FT_RENDER_MODE_LIGHT,
3251 FT_RENDER_MODE_MONO,
3253 FT_RENDER_MODE_LCD_V,
3260 /* these constants are deprecated; use the corresponding */
3261 /* `FT_Render_Mode` values instead */
3262 #define ft_render_mode_normal FT_RENDER_MODE_NORMAL
3263 #define ft_render_mode_mono FT_RENDER_MODE_MONO
3266 /**************************************************************************
3272 * Convert a given glyph image to a bitmap. It does so by inspecting the
3273 * glyph image format, finding the relevant renderer, and invoking it.
3277 * A handle to the glyph slot containing the image to convert.
3281 * The render mode used to render the glyph image into a bitmap. See
3282 * @FT_Render_Mode for a list of possible values.
3284 * If @FT_RENDER_MODE_NORMAL is used, a previous call of @FT_Load_Glyph
3285 * with flag @FT_LOAD_COLOR makes FT_Render_Glyph provide a default
3286 * blending of colored glyph layers associated with the current glyph
3287 * slot (provided the font contains such layers) instead of rendering
3288 * the glyph slot's outline. This is an experimental feature; see
3289 * @FT_LOAD_COLOR for more information.
3292 * FreeType error code. 0~means success.
3295 * To get meaningful results, font scaling values must be set with
3296 * functions like @FT_Set_Char_Size before calling `FT_Render_Glyph`.
3298 * When FreeType outputs a bitmap of a glyph, it really outputs an alpha
3299 * coverage map. If a pixel is completely covered by a filled-in
3300 * outline, the bitmap contains 0xFF at that pixel, meaning that
3301 * 0xFF/0xFF fraction of that pixel is covered, meaning the pixel is 100%
3302 * black (or 0% bright). If a pixel is only 50% covered (value 0x80),
3303 * the pixel is made 50% black (50% bright or a middle shade of grey).
3304 * 0% covered means 0% black (100% bright or white).
3306 * On high-DPI screens like on smartphones and tablets, the pixels are so
3307 * small that their chance of being completely covered and therefore
3308 * completely black are fairly good. On the low-DPI screens, however,
3309 * the situation is different. The pixels are too large for most of the
3310 * details of a glyph and shades of gray are the norm rather than the
3313 * This is relevant because all our screens have a second problem: they
3314 * are not linear. 1~+~1 is not~2. Twice the value does not result in
3315 * twice the brightness. When a pixel is only 50% covered, the coverage
3316 * map says 50% black, and this translates to a pixel value of 128 when
3317 * you use 8~bits per channel (0-255). However, this does not translate
3318 * to 50% brightness for that pixel on our sRGB and gamma~2.2 screens.
3319 * Due to their non-linearity, they dwell longer in the darks and only a
3320 * pixel value of about 186 results in 50% brightness -- 128 ends up too
3321 * dark on both bright and dark backgrounds. The net result is that dark
3322 * text looks burnt-out, pixely and blotchy on bright background, bright
3323 * text too frail on dark backgrounds, and colored text on colored
3324 * background (for example, red on green) seems to have dark halos or
3325 * 'dirt' around it. The situation is especially ugly for diagonal stems
3326 * like in 'w' glyph shapes where the quality of FreeType's anti-aliasing
3327 * depends on the correct display of grays. On high-DPI screens where
3328 * smaller, fully black pixels reign supreme, this doesn't matter, but on
3329 * our low-DPI screens with all the gray shades, it does. 0% and 100%
3330 * brightness are the same things in linear and non-linear space, just
3331 * all the shades in-between aren't.
3333 * The blending function for placing text over a background is
3336 * dst = alpha * src + (1 - alpha) * dst ,
3339 * which is known as the OVER operator.
3341 * To correctly composite an antialiased pixel of a glyph onto a surface,
3343 * 1. take the foreground and background colors (e.g., in sRGB space)
3344 * and apply gamma to get them in a linear space,
3346 * 2. use OVER to blend the two linear colors using the glyph pixel
3347 * as the alpha value (remember, the glyph bitmap is an alpha coverage
3350 * 3. apply inverse gamma to the blended pixel and write it back to
3353 * Internal testing at Adobe found that a target inverse gamma of~1.8 for
3354 * step~3 gives good results across a wide range of displays with an sRGB
3355 * gamma curve or a similar one.
3357 * This process can cost performance. There is an approximation that
3358 * does not need to know about the background color; see
3359 * https://bel.fi/alankila/lcd/ and
3360 * https://bel.fi/alankila/lcd/alpcor.html for details.
3362 * **ATTENTION**: Linear blending is even more important when dealing
3363 * with subpixel-rendered glyphs to prevent color-fringing! A
3364 * subpixel-rendered glyph must first be filtered with a filter that
3365 * gives equal weight to the three color primaries and does not exceed a
3366 * sum of 0x100, see section @lcd_rendering. Then the only difference to
3367 * gray linear blending is that subpixel-rendered linear blending is done
3368 * 3~times per pixel: red foreground subpixel to red background subpixel
3369 * and so on for green and blue.
3371 FT_EXPORT( FT_Error )
3372 FT_Render_Glyph( FT_GlyphSlot slot,
3373 FT_Render_Mode render_mode );
3376 /**************************************************************************
3382 * An enumeration to specify the format of kerning values returned by
3386 * FT_KERNING_DEFAULT ::
3387 * Return grid-fitted kerning distances in 26.6 fractional pixels.
3389 * FT_KERNING_UNFITTED ::
3390 * Return un-grid-fitted kerning distances in 26.6 fractional pixels.
3392 * FT_KERNING_UNSCALED ::
3393 * Return the kerning vector in original font units.
3396 * `FT_KERNING_DEFAULT` returns full pixel values; it also makes FreeType
3397 * heuristically scale down kerning distances at small ppem values so
3398 * that they don't become too big.
3400 * Both `FT_KERNING_DEFAULT` and `FT_KERNING_UNFITTED` use the current
3401 * horizontal scaling factor (as set e.g. with @FT_Set_Char_Size) to
3402 * convert font units to pixels.
3404 typedef enum FT_Kerning_Mode_
3406 FT_KERNING_DEFAULT = 0,
3407 FT_KERNING_UNFITTED,
3413 /* these constants are deprecated; use the corresponding */
3414 /* `FT_Kerning_Mode` values instead */
3415 #define ft_kerning_default FT_KERNING_DEFAULT
3416 #define ft_kerning_unfitted FT_KERNING_UNFITTED
3417 #define ft_kerning_unscaled FT_KERNING_UNSCALED
3420 /**************************************************************************
3426 * Return the kerning vector between two glyphs of the same face.
3430 * A handle to a source face object.
3433 * The index of the left glyph in the kern pair.
3436 * The index of the right glyph in the kern pair.
3439 * See @FT_Kerning_Mode for more information. Determines the scale and
3440 * dimension of the returned kerning vector.
3444 * The kerning vector. This is either in font units, fractional pixels
3445 * (26.6 format), or pixels for scalable formats, and in pixels for
3446 * fixed-sizes formats.
3449 * FreeType error code. 0~means success.
3452 * Only horizontal layouts (left-to-right & right-to-left) are supported
3453 * by this method. Other layouts, or more sophisticated kernings, are
3454 * out of the scope of this API function -- they can be implemented
3455 * through format-specific interfaces.
3457 * Kerning for OpenType fonts implemented in a 'GPOS' table is not
3458 * supported; use @FT_HAS_KERNING to find out whether a font has data
3459 * that can be extracted with `FT_Get_Kerning`.
3461 FT_EXPORT( FT_Error )
3462 FT_Get_Kerning( FT_Face face,
3464 FT_UInt right_glyph,
3466 FT_Vector *akerning );
3469 /**************************************************************************
3472 * FT_Get_Track_Kerning
3475 * Return the track kerning for a given face object at a given size.
3479 * A handle to a source face object.
3482 * The point size in 16.16 fractional points.
3485 * The degree of tightness. Increasingly negative values represent
3486 * tighter track kerning, while increasingly positive values represent
3487 * looser track kerning. Value zero means no track kerning.
3491 * The kerning in 16.16 fractional points, to be uniformly applied
3492 * between all glyphs.
3495 * FreeType error code. 0~means success.
3498 * Currently, only the Type~1 font driver supports track kerning, using
3499 * data from AFM files (if attached with @FT_Attach_File or
3500 * @FT_Attach_Stream).
3502 * Only very few AFM files come with track kerning data; please refer to
3503 * Adobe's AFM specification for more details.
3505 FT_EXPORT( FT_Error )
3506 FT_Get_Track_Kerning( FT_Face face,
3507 FT_Fixed point_size,
3509 FT_Fixed* akerning );
3512 /**************************************************************************
3518 * Retrieve the ASCII name of a given glyph in a face. This only works
3519 * for those faces where @FT_HAS_GLYPH_NAMES(face) returns~1.
3523 * A handle to a source face object.
3529 * The maximum number of bytes available in the buffer.
3533 * A pointer to a target buffer where the name is copied to.
3536 * FreeType error code. 0~means success.
3539 * An error is returned if the face doesn't provide glyph names or if the
3540 * glyph index is invalid. In all cases of failure, the first byte of
3541 * `buffer` is set to~0 to indicate an empty name.
3543 * The glyph name is truncated to fit within the buffer if it is too
3544 * long. The returned string is always zero-terminated.
3546 * Be aware that FreeType reorders glyph indices internally so that glyph
3547 * index~0 always corresponds to the 'missing glyph' (called '.notdef').
3549 * This function always returns an error if the config macro
3550 * `FT_CONFIG_OPTION_NO_GLYPH_NAMES` is not defined in `ftoption.h`.
3552 FT_EXPORT( FT_Error )
3553 FT_Get_Glyph_Name( FT_Face face,
3554 FT_UInt glyph_index,
3556 FT_UInt buffer_max );
3559 /**************************************************************************
3562 * FT_Get_Postscript_Name
3565 * Retrieve the ASCII PostScript name of a given face, if available.
3566 * This only works with PostScript, TrueType, and OpenType fonts.
3570 * A handle to the source face object.
3573 * A pointer to the face's PostScript name. `NULL` if unavailable.
3576 * The returned pointer is owned by the face and is destroyed with it.
3578 * For variation fonts, this string changes if you select a different
3579 * instance, and you have to call `FT_Get_PostScript_Name` again to
3580 * retrieve it. FreeType follows Adobe TechNote #5902, 'Generating
3581 * PostScript Names for Fonts Using OpenType Font Variations'.
3583 * https://download.macromedia.com/pub/developer/opentype/tech-notes/5902.AdobePSNameGeneration.html
3585 * [Since 2.9] Special PostScript names for named instances are only
3586 * returned if the named instance is set with @FT_Set_Named_Instance (and
3587 * the font has corresponding entries in its 'fvar' table). If
3588 * @FT_IS_VARIATION returns true, the algorithmically derived PostScript
3589 * name is provided, not looking up special entries for named instances.
3591 FT_EXPORT( const char* )
3592 FT_Get_Postscript_Name( FT_Face face );
3595 /**************************************************************************
3601 * Select a given charmap by its encoding tag (as listed in
3606 * A handle to the source face object.
3610 * A handle to the selected encoding.
3613 * FreeType error code. 0~means success.
3616 * This function returns an error if no charmap in the face corresponds
3617 * to the encoding queried here.
3619 * Because many fonts contain more than a single cmap for Unicode
3620 * encoding, this function has some special code to select the one that
3621 * covers Unicode best ('best' in the sense that a UCS-4 cmap is
3622 * preferred to a UCS-2 cmap). It is thus preferable to @FT_Set_Charmap
3625 FT_EXPORT( FT_Error )
3626 FT_Select_Charmap( FT_Face face,
3627 FT_Encoding encoding );
3630 /**************************************************************************
3636 * Select a given charmap for character code to glyph index mapping.
3640 * A handle to the source face object.
3644 * A handle to the selected charmap.
3647 * FreeType error code. 0~means success.
3650 * This function returns an error if the charmap is not part of the face
3651 * (i.e., if it is not listed in the `face->charmaps` table).
3653 * It also fails if an OpenType type~14 charmap is selected (which
3654 * doesn't map character codes to glyph indices at all).
3656 FT_EXPORT( FT_Error )
3657 FT_Set_Charmap( FT_Face face,
3658 FT_CharMap charmap );
3661 /**************************************************************************
3664 * FT_Get_Charmap_Index
3667 * Retrieve index of a given charmap.
3671 * A handle to a charmap.
3674 * The index into the array of character maps within the face to which
3675 * `charmap` belongs. If an error occurs, -1 is returned.
3679 FT_Get_Charmap_Index( FT_CharMap charmap );
3682 /**************************************************************************
3688 * Return the glyph index of a given character code. This function uses
3689 * the currently selected charmap to do the mapping.
3693 * A handle to the source face object.
3696 * The character code.
3699 * The glyph index. 0~means 'undefined character code'.
3702 * If you use FreeType to manipulate the contents of font files directly,
3703 * be aware that the glyph index returned by this function doesn't always
3704 * correspond to the internal indices used within the file. This is done
3705 * to ensure that value~0 always corresponds to the 'missing glyph'. If
3706 * the first glyph is not named '.notdef', then for Type~1 and Type~42
3707 * fonts, '.notdef' will be moved into the glyph ID~0 position, and
3708 * whatever was there will be moved to the position '.notdef' had. For
3709 * Type~1 fonts, if there is no '.notdef' glyph at all, then one will be
3710 * created at index~0 and whatever was there will be moved to the last
3711 * index -- Type~42 fonts are considered invalid under this condition.
3713 FT_EXPORT( FT_UInt )
3714 FT_Get_Char_Index( FT_Face face,
3715 FT_ULong charcode );
3718 /**************************************************************************
3724 * Return the first character code in the current charmap of a given
3725 * face, together with its corresponding glyph index.
3729 * A handle to the source face object.
3733 * Glyph index of first character code. 0~if charmap is empty.
3736 * The charmap's first character code.
3739 * You should use this function together with @FT_Get_Next_Char to parse
3740 * all character codes available in a given charmap. The code should
3744 * FT_ULong charcode;
3748 * charcode = FT_Get_First_Char( face, &gindex );
3749 * while ( gindex != 0 )
3751 * ... do something with (charcode,gindex) pair ...
3753 * charcode = FT_Get_Next_Char( face, charcode, &gindex );
3757 * Be aware that character codes can have values up to 0xFFFFFFFF; this
3758 * might happen for non-Unicode or malformed cmaps. However, even with
3759 * regular Unicode encoding, so-called 'last resort fonts' (using SFNT
3760 * cmap format 13, see function @FT_Get_CMap_Format) normally have
3761 * entries for all Unicode characters up to 0x1FFFFF, which can cause *a
3762 * lot* of iterations.
3764 * Note that `*agindex` is set to~0 if the charmap is empty. The result
3765 * itself can be~0 in two cases: if the charmap is empty or if the
3766 * value~0 is the first valid character code.
3768 FT_EXPORT( FT_ULong )
3769 FT_Get_First_Char( FT_Face face,
3773 /**************************************************************************
3779 * Return the next character code in the current charmap of a given face
3780 * following the value `char_code`, as well as the corresponding glyph
3785 * A handle to the source face object.
3788 * The starting character code.
3792 * Glyph index of next character code. 0~if charmap is empty.
3795 * The charmap's next character code.
3798 * You should use this function with @FT_Get_First_Char to walk over all
3799 * character codes available in a given charmap. See the note for that
3800 * function for a simple code example.
3802 * Note that `*agindex` is set to~0 when there are no more codes in the
3805 FT_EXPORT( FT_ULong )
3806 FT_Get_Next_Char( FT_Face face,
3811 /**************************************************************************
3814 * FT_Face_Properties
3817 * Set or override certain (library or module-wide) properties on a
3818 * face-by-face basis. Useful for finer-grained control and avoiding
3819 * locks on shared structures (threads can modify their own faces as they
3822 * Contrary to @FT_Property_Set, this function uses @FT_Parameter so that
3823 * you can pass multiple properties to the target face in one call. Note
3824 * that only a subset of the available properties can be controlled.
3826 * * @FT_PARAM_TAG_STEM_DARKENING (stem darkening, corresponding to the
3827 * property `no-stem-darkening` provided by the 'autofit', 'cff',
3828 * 'type1', and 't1cid' modules; see @no-stem-darkening).
3830 * * @FT_PARAM_TAG_LCD_FILTER_WEIGHTS (LCD filter weights, corresponding
3831 * to function @FT_Library_SetLcdFilterWeights).
3833 * * @FT_PARAM_TAG_RANDOM_SEED (seed value for the CFF, Type~1, and CID
3834 * 'random' operator, corresponding to the `random-seed` property
3835 * provided by the 'cff', 'type1', and 't1cid' modules; see
3838 * Pass `NULL` as `data` in @FT_Parameter for a given tag to reset the
3839 * option and use the library or module default again.
3843 * A handle to the source face object.
3846 * The number of properties that follow.
3849 * A handle to an @FT_Parameter array with `num_properties` elements.
3852 * FreeType error code. 0~means success.
3855 * Here is an example that sets three properties. You must define
3856 * `FT_CONFIG_OPTION_SUBPIXEL_RENDERING` to make the LCD filter examples
3860 * FT_Parameter property1;
3861 * FT_Bool darken_stems = 1;
3863 * FT_Parameter property2;
3864 * FT_LcdFiveTapFilter custom_weight =
3865 * { 0x11, 0x44, 0x56, 0x44, 0x11 };
3867 * FT_Parameter property3;
3868 * FT_Int32 random_seed = 314159265;
3870 * FT_Parameter properties[3] = { property1,
3875 * property1.tag = FT_PARAM_TAG_STEM_DARKENING;
3876 * property1.data = &darken_stems;
3878 * property2.tag = FT_PARAM_TAG_LCD_FILTER_WEIGHTS;
3879 * property2.data = custom_weight;
3881 * property3.tag = FT_PARAM_TAG_RANDOM_SEED;
3882 * property3.data = &random_seed;
3884 * FT_Face_Properties( face, 3, properties );
3887 * The next example resets a single property to its default value.
3890 * FT_Parameter property;
3893 * property.tag = FT_PARAM_TAG_LCD_FILTER_WEIGHTS;
3894 * property.data = NULL;
3896 * FT_Face_Properties( face, 1, &property );
3903 FT_EXPORT( FT_Error )
3904 FT_Face_Properties( FT_Face face,
3905 FT_UInt num_properties,
3906 FT_Parameter* properties );
3909 /**************************************************************************
3915 * Return the glyph index of a given glyph name.
3919 * A handle to the source face object.
3925 * The glyph index. 0~means 'undefined character code'.
3927 FT_EXPORT( FT_UInt )
3928 FT_Get_Name_Index( FT_Face face,
3929 const FT_String* glyph_name );
3932 /**************************************************************************
3935 * FT_SUBGLYPH_FLAG_XXX
3938 * A list of constants describing subglyphs. Please refer to the 'glyf'
3939 * table description in the OpenType specification for the meaning of the
3940 * various flags (which get synthesized for non-OpenType subglyphs).
3942 * https://docs.microsoft.com/en-us/typography/opentype/spec/glyf#composite-glyph-description
3945 * FT_SUBGLYPH_FLAG_ARGS_ARE_WORDS ::
3946 * FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES ::
3947 * FT_SUBGLYPH_FLAG_ROUND_XY_TO_GRID ::
3948 * FT_SUBGLYPH_FLAG_SCALE ::
3949 * FT_SUBGLYPH_FLAG_XY_SCALE ::
3950 * FT_SUBGLYPH_FLAG_2X2 ::
3951 * FT_SUBGLYPH_FLAG_USE_MY_METRICS ::
3954 #define FT_SUBGLYPH_FLAG_ARGS_ARE_WORDS 1
3955 #define FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES 2
3956 #define FT_SUBGLYPH_FLAG_ROUND_XY_TO_GRID 4
3957 #define FT_SUBGLYPH_FLAG_SCALE 8
3958 #define FT_SUBGLYPH_FLAG_XY_SCALE 0x40
3959 #define FT_SUBGLYPH_FLAG_2X2 0x80
3960 #define FT_SUBGLYPH_FLAG_USE_MY_METRICS 0x200
3963 /**************************************************************************
3966 * FT_Get_SubGlyph_Info
3969 * Retrieve a description of a given subglyph. Only use it if
3970 * `glyph->format` is @FT_GLYPH_FORMAT_COMPOSITE; an error is returned
3975 * The source glyph slot.
3978 * The index of the subglyph. Must be less than
3979 * `glyph->num_subglyphs`.
3983 * The glyph index of the subglyph.
3986 * The subglyph flags, see @FT_SUBGLYPH_FLAG_XXX.
3989 * The subglyph's first argument (if any).
3992 * The subglyph's second argument (if any).
3995 * The subglyph transformation (if any).
3998 * FreeType error code. 0~means success.
4001 * The values of `*p_arg1`, `*p_arg2`, and `*p_transform` must be
4002 * interpreted depending on the flags returned in `*p_flags`. See the
4003 * OpenType specification for details.
4005 * https://docs.microsoft.com/en-us/typography/opentype/spec/glyf#composite-glyph-description
4008 FT_EXPORT( FT_Error )
4009 FT_Get_SubGlyph_Info( FT_GlyphSlot glyph,
4015 FT_Matrix *p_transform );
4018 /**************************************************************************
4024 * Glyph Layer Management
4027 * Retrieving and manipulating OpenType's 'COLR' table data.
4030 * The functions described here allow access of colored glyph layer data
4031 * in OpenType's 'COLR' tables.
4035 /**************************************************************************
4041 * This iterator object is needed for @FT_Get_Color_Glyph_Layer.
4045 * The number of glyph layers for the requested glyph index. Will be
4046 * set by @FT_Get_Color_Glyph_Layer.
4049 * The current layer. Will be set by @FT_Get_Color_Glyph_Layer.
4052 * An opaque pointer into 'COLR' table data. The caller must set this
4053 * to `NULL` before the first call of @FT_Get_Color_Glyph_Layer.
4055 typedef struct FT_LayerIterator_
4064 /**************************************************************************
4067 * FT_Get_Color_Glyph_Layer
4070 * This is an interface to the 'COLR' table in OpenType fonts to
4071 * iteratively retrieve the colored glyph layers associated with the
4072 * current glyph slot.
4074 * https://docs.microsoft.com/en-us/typography/opentype/spec/colr
4076 * The glyph layer data for a given glyph index, if present, provides an
4077 * alternative, multi-color glyph representation: Instead of rendering
4078 * the outline or bitmap with the given glyph index, glyphs with the
4079 * indices and colors returned by this function are rendered layer by
4082 * The returned elements are ordered in the z~direction from bottom to
4083 * top; the 'n'th element should be rendered with the associated palette
4084 * color and blended on top of the already rendered layers (elements 0,
4089 * A handle to the parent face object.
4092 * The glyph index the colored glyph layers are associated with.
4096 * An @FT_LayerIterator object. For the first call you should set
4097 * `iterator->p` to `NULL`. For all following calls, simply use the
4098 * same object again.
4102 * The glyph index of the current layer.
4105 * The color index into the font face's color palette of the current
4106 * layer. The value 0xFFFF is special; it doesn't reference a palette
4107 * entry but indicates that the text foreground color should be used
4108 * instead (to be set up by the application outside of FreeType).
4110 * The color palette can be retrieved with @FT_Palette_Select.
4113 * Value~1 if everything is OK. If there are no more layers (or if there
4114 * are no layers at all), value~0 gets returned. In case of an error,
4115 * value~0 is returned also.
4118 * This function is necessary if you want to handle glyph layers by
4119 * yourself. In particular, functions that operate with @FT_GlyphRec
4120 * objects (like @FT_Get_Glyph or @FT_Glyph_To_Bitmap) don't have access
4121 * to this information.
4123 * Note that @FT_Render_Glyph is able to handle colored glyph layers
4124 * automatically if the @FT_LOAD_COLOR flag is passed to a previous call
4125 * to @FT_Load_Glyph. [This is an experimental feature.]
4129 * FT_Color* palette;
4130 * FT_LayerIterator iterator;
4132 * FT_Bool have_layers;
4133 * FT_UInt layer_glyph_index;
4134 * FT_UInt layer_color_index;
4137 * error = FT_Palette_Select( face, palette_index, &palette );
4141 * iterator.p = NULL;
4142 * have_layers = FT_Get_Color_Glyph_Layer( face,
4144 * &layer_glyph_index,
4145 * &layer_color_index,
4148 * if ( palette && have_layers )
4152 * FT_Color layer_color;
4155 * if ( layer_color_index == 0xFFFF )
4156 * layer_color = text_foreground_color;
4158 * layer_color = palette[layer_color_index];
4160 * // Load and render glyph `layer_glyph_index', then
4161 * // blend resulting pixmap (using color `layer_color')
4162 * // with previously created pixmaps.
4164 * } while ( FT_Get_Color_Glyph_Layer( face,
4166 * &layer_glyph_index,
4167 * &layer_color_index,
4172 FT_EXPORT( FT_Bool )
4173 FT_Get_Color_Glyph_Layer( FT_Face face,
4175 FT_UInt *aglyph_index,
4176 FT_UInt *acolor_index,
4177 FT_LayerIterator* iterator );
4180 /**************************************************************************
4187 /**************************************************************************
4193 * A list of bit flags used in the `fsType` field of the OS/2 table in a
4194 * TrueType or OpenType font and the `FSType` entry in a PostScript font.
4195 * These bit flags are returned by @FT_Get_FSType_Flags; they inform
4196 * client applications of embedding and subsetting restrictions
4197 * associated with a font.
4200 * https://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/FontPolicies.pdf
4204 * FT_FSTYPE_INSTALLABLE_EMBEDDING ::
4205 * Fonts with no fsType bit set may be embedded and permanently
4206 * installed on the remote system by an application.
4208 * FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING ::
4209 * Fonts that have only this bit set must not be modified, embedded or
4210 * exchanged in any manner without first obtaining permission of the
4211 * font software copyright owner.
4213 * FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING ::
4214 * The font may be embedded and temporarily loaded on the remote
4215 * system. Documents containing Preview & Print fonts must be opened
4216 * 'read-only'; no edits can be applied to the document.
4218 * FT_FSTYPE_EDITABLE_EMBEDDING ::
4219 * The font may be embedded but must only be installed temporarily on
4220 * other systems. In contrast to Preview & Print fonts, documents
4221 * containing editable fonts may be opened for reading, editing is
4222 * permitted, and changes may be saved.
4224 * FT_FSTYPE_NO_SUBSETTING ::
4225 * The font may not be subsetted prior to embedding.
4227 * FT_FSTYPE_BITMAP_EMBEDDING_ONLY ::
4228 * Only bitmaps contained in the font may be embedded; no outline data
4229 * may be embedded. If there are no bitmaps available in the font,
4230 * then the font is unembeddable.
4233 * The flags are ORed together, thus more than a single value can be
4236 * While the `fsType` flags can indicate that a font may be embedded, a
4237 * license with the font vendor may be separately required to use the
4240 #define FT_FSTYPE_INSTALLABLE_EMBEDDING 0x0000
4241 #define FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING 0x0002
4242 #define FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING 0x0004
4243 #define FT_FSTYPE_EDITABLE_EMBEDDING 0x0008
4244 #define FT_FSTYPE_NO_SUBSETTING 0x0100
4245 #define FT_FSTYPE_BITMAP_EMBEDDING_ONLY 0x0200
4248 /**************************************************************************
4251 * FT_Get_FSType_Flags
4254 * Return the `fsType` flags for a font.
4258 * A handle to the source face object.
4261 * The `fsType` flags, see @FT_FSTYPE_XXX.
4264 * Use this function rather than directly reading the `fs_type` field in
4265 * the @PS_FontInfoRec structure, which is only guaranteed to return the
4266 * correct results for Type~1 fonts.
4271 FT_EXPORT( FT_UShort )
4272 FT_Get_FSType_Flags( FT_Face face );
4275 /**************************************************************************
4281 * Unicode Variation Sequences
4284 * The FreeType~2 interface to Unicode Variation Sequences (UVS), using
4285 * the SFNT cmap format~14.
4288 * Many characters, especially for CJK scripts, have variant forms. They
4289 * are a sort of grey area somewhere between being totally irrelevant and
4290 * semantically distinct; for this reason, the Unicode consortium decided
4291 * to introduce Variation Sequences (VS), consisting of a Unicode base
4292 * character and a variation selector instead of further extending the
4293 * already huge number of characters.
4295 * Unicode maintains two different sets, namely 'Standardized Variation
4296 * Sequences' and registered 'Ideographic Variation Sequences' (IVS),
4297 * collected in the 'Ideographic Variation Database' (IVD).
4299 * https://unicode.org/Public/UCD/latest/ucd/StandardizedVariants.txt
4300 * https://unicode.org/reports/tr37/ https://unicode.org/ivd/
4302 * To date (January 2017), the character with the most ideographic
4303 * variations is U+9089, having 32 such IVS.
4305 * Three Mongolian Variation Selectors have the values U+180B-U+180D; 256
4306 * generic Variation Selectors are encoded in the ranges U+FE00-U+FE0F
4307 * and U+E0100-U+E01EF. IVS currently use Variation Selectors from the
4308 * range U+E0100-U+E01EF only.
4310 * A VS consists of the base character value followed by a single
4311 * Variation Selector. For example, to get the first variation of
4312 * U+9089, you have to write the character sequence `U+9089 U+E0100`.
4314 * Adobe and MS decided to support both standardized and ideographic VS
4315 * with a new cmap subtable (format~14). It is an odd subtable because
4316 * it is not a mapping of input code points to glyphs, but contains lists
4317 * of all variations supported by the font.
4319 * A variation may be either 'default' or 'non-default' for a given font.
4320 * A default variation is the one you will get for that code point if you
4321 * look it up in the standard Unicode cmap. A non-default variation is a
4327 /**************************************************************************
4330 * FT_Face_GetCharVariantIndex
4333 * Return the glyph index of a given character code as modified by the
4334 * variation selector.
4338 * A handle to the source face object.
4341 * The character code point in Unicode.
4343 * variantSelector ::
4344 * The Unicode code point of the variation selector.
4347 * The glyph index. 0~means either 'undefined character code', or
4348 * 'undefined selector code', or 'no variation selector cmap subtable',
4349 * or 'current CharMap is not Unicode'.
4352 * If you use FreeType to manipulate the contents of font files directly,
4353 * be aware that the glyph index returned by this function doesn't always
4354 * correspond to the internal indices used within the file. This is done
4355 * to ensure that value~0 always corresponds to the 'missing glyph'.
4357 * This function is only meaningful if
4358 * a) the font has a variation selector cmap sub table, and
4359 * b) the current charmap has a Unicode encoding.
4364 FT_EXPORT( FT_UInt )
4365 FT_Face_GetCharVariantIndex( FT_Face face,
4367 FT_ULong variantSelector );
4370 /**************************************************************************
4373 * FT_Face_GetCharVariantIsDefault
4376 * Check whether this variation of this Unicode character is the one to
4377 * be found in the charmap.
4381 * A handle to the source face object.
4384 * The character codepoint in Unicode.
4386 * variantSelector ::
4387 * The Unicode codepoint of the variation selector.
4390 * 1~if found in the standard (Unicode) cmap, 0~if found in the variation
4391 * selector cmap, or -1 if it is not a variation.
4394 * This function is only meaningful if the font has a variation selector
4401 FT_Face_GetCharVariantIsDefault( FT_Face face,
4403 FT_ULong variantSelector );
4406 /**************************************************************************
4409 * FT_Face_GetVariantSelectors
4412 * Return a zero-terminated list of Unicode variation selectors found in
4417 * A handle to the source face object.
4420 * A pointer to an array of selector code points, or `NULL` if there is
4421 * no valid variation selector cmap subtable.
4424 * The last item in the array is~0; the array is owned by the @FT_Face
4425 * object but can be overwritten or released on the next call to a
4426 * FreeType function.
4431 FT_EXPORT( FT_UInt32* )
4432 FT_Face_GetVariantSelectors( FT_Face face );
4435 /**************************************************************************
4438 * FT_Face_GetVariantsOfChar
4441 * Return a zero-terminated list of Unicode variation selectors found for
4442 * the specified character code.
4446 * A handle to the source face object.
4449 * The character codepoint in Unicode.
4452 * A pointer to an array of variation selector code points that are
4453 * active for the given character, or `NULL` if the corresponding list is
4457 * The last item in the array is~0; the array is owned by the @FT_Face
4458 * object but can be overwritten or released on the next call to a
4459 * FreeType function.
4464 FT_EXPORT( FT_UInt32* )
4465 FT_Face_GetVariantsOfChar( FT_Face face,
4466 FT_ULong charcode );
4469 /**************************************************************************
4472 * FT_Face_GetCharsOfVariant
4475 * Return a zero-terminated list of Unicode character codes found for the
4476 * specified variation selector.
4480 * A handle to the source face object.
4482 * variantSelector ::
4483 * The variation selector code point in Unicode.
4486 * A list of all the code points that are specified by this selector
4487 * (both default and non-default codes are returned) or `NULL` if there
4488 * is no valid cmap or the variation selector is invalid.
4491 * The last item in the array is~0; the array is owned by the @FT_Face
4492 * object but can be overwritten or released on the next call to a
4493 * FreeType function.
4498 FT_EXPORT( FT_UInt32* )
4499 FT_Face_GetCharsOfVariant( FT_Face face,
4500 FT_ULong variantSelector );
4503 /**************************************************************************
4512 * Crunching fixed numbers and vectors.
4515 * This section contains various functions used to perform computations
4516 * on 16.16 fixed-float numbers or 2d vectors.
4518 * **Attention**: Most arithmetic functions take `FT_Long` as arguments.
4519 * For historical reasons, FreeType was designed under the assumption
4520 * that `FT_Long` is a 32-bit integer; results can thus be undefined if
4521 * the arguments don't fit into 32 bits.
4530 * FT_Vector_Transform
4531 * FT_Matrix_Multiply
4537 /**************************************************************************
4543 * Compute `(a*b)/c` with maximum accuracy, using a 64-bit intermediate
4544 * integer whenever necessary.
4546 * This function isn't necessarily as fast as some processor-specific
4547 * operations, but is at least completely portable.
4551 * The first multiplier.
4554 * The second multiplier.
4560 * The result of `(a*b)/c`. This function never traps when trying to
4561 * divide by zero; it simply returns 'MaxInt' or 'MinInt' depending on
4562 * the signs of `a` and `b`.
4564 FT_EXPORT( FT_Long )
4565 FT_MulDiv( FT_Long a,
4570 /**************************************************************************
4576 * Compute `(a*b)/0x10000` with maximum accuracy. Its main use is to
4577 * multiply a given value by a 16.16 fixed-point factor.
4581 * The first multiplier.
4584 * The second multiplier. Use a 16.16 factor here whenever possible
4588 * The result of `(a*b)/0x10000`.
4591 * This function has been optimized for the case where the absolute value
4592 * of `a` is less than 2048, and `b` is a 16.16 scaling factor. As this
4593 * happens mainly when scaling from notional units to fractional pixels
4594 * in FreeType, it resulted in noticeable speed improvements between
4595 * versions 2.x and 1.x.
4597 * As a conclusion, always try to place a 16.16 factor as the _second_
4598 * argument of this function; this can make a great difference.
4600 FT_EXPORT( FT_Long )
4601 FT_MulFix( FT_Long a,
4605 /**************************************************************************
4611 * Compute `(a*0x10000)/b` with maximum accuracy. Its main use is to
4612 * divide a given value by a 16.16 fixed-point factor.
4619 * The denominator. Use a 16.16 factor here.
4622 * The result of `(a*0x10000)/b`.
4624 FT_EXPORT( FT_Long )
4625 FT_DivFix( FT_Long a,
4629 /**************************************************************************
4635 * Round a 16.16 fixed number.
4639 * The number to be rounded.
4642 * `a` rounded to the nearest 16.16 fixed integer, halfway cases away
4646 * The function uses wrap-around arithmetic.
4648 FT_EXPORT( FT_Fixed )
4649 FT_RoundFix( FT_Fixed a );
4652 /**************************************************************************
4658 * Compute the smallest following integer of a 16.16 fixed number.
4662 * The number for which the ceiling function is to be computed.
4665 * `a` rounded towards plus infinity.
4668 * The function uses wrap-around arithmetic.
4670 FT_EXPORT( FT_Fixed )
4671 FT_CeilFix( FT_Fixed a );
4674 /**************************************************************************
4680 * Compute the largest previous integer of a 16.16 fixed number.
4684 * The number for which the floor function is to be computed.
4687 * `a` rounded towards minus infinity.
4689 FT_EXPORT( FT_Fixed )
4690 FT_FloorFix( FT_Fixed a );
4693 /**************************************************************************
4696 * FT_Vector_Transform
4699 * Transform a single vector through a 2x2 matrix.
4703 * The target vector to transform.
4707 * A pointer to the source 2x2 matrix.
4710 * The result is undefined if either `vector` or `matrix` is invalid.
4713 FT_Vector_Transform( FT_Vector* vector,
4714 const FT_Matrix* matrix );
4717 /**************************************************************************
4726 * Functions and macros related to FreeType versions.
4729 * Note that those functions and macros are of limited use because even a
4730 * new release of FreeType with only documentation changes increases the
4734 * FT_Library_Version
4740 * FT_Face_CheckTrueTypePatents
4741 * FT_Face_SetUnpatentedHinting
4746 /**************************************************************************
4752 * These three macros identify the FreeType source code version. Use
4753 * @FT_Library_Version to access them at runtime.
4757 * The major version number.
4759 * The minor version number.
4764 * The version number of FreeType if built as a dynamic link library with
4765 * the 'libtool' package is _not_ controlled by these three macros.
4768 #define FREETYPE_MAJOR 2
4769 #define FREETYPE_MINOR 10
4770 #define FREETYPE_PATCH 4
4773 /**************************************************************************
4776 * FT_Library_Version
4779 * Return the version of the FreeType library being used. This is useful
4780 * when dynamically linking to the library, since one cannot use the
4781 * macros @FREETYPE_MAJOR, @FREETYPE_MINOR, and @FREETYPE_PATCH.
4785 * A source library handle.
4789 * The major version number.
4792 * The minor version number.
4795 * The patch version number.
4798 * The reason why this function takes a `library` argument is because
4799 * certain programs implement library initialization in a custom way that
4800 * doesn't use @FT_Init_FreeType.
4802 * In such cases, the library version might not be available before the
4803 * library object has been created.
4806 FT_Library_Version( FT_Library library,
4812 /**************************************************************************
4815 * FT_Face_CheckTrueTypePatents
4818 * Deprecated, does nothing.
4825 * Always returns false.
4828 * Since May 2010, TrueType hinting is no longer patented.
4833 FT_EXPORT( FT_Bool )
4834 FT_Face_CheckTrueTypePatents( FT_Face face );
4837 /**************************************************************************
4840 * FT_Face_SetUnpatentedHinting
4843 * Deprecated, does nothing.
4850 * New boolean setting.
4853 * Always returns false.
4856 * Since May 2010, TrueType hinting is no longer patented.
4861 FT_EXPORT( FT_Bool )
4862 FT_Face_SetUnpatentedHinting( FT_Face face,
4870 #endif /* FREETYPE_H_ */