1 /****************************************************************************
5 * FreeType high-level API and common types (specification only).
7 * Copyright (C) 1996-2023 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 /**************************************************************************
42 * What FreeType is and isn't
45 * FreeType is a library that provides access to glyphs in font files. It
46 * scales the glyph images and their metrics to a requested size, and it
47 * rasterizes the glyph images to produce pixel or subpixel alpha coverage
50 * Note that FreeType is _not_ a text layout engine. You have to use
51 * higher-level libraries like HarfBuzz, Pango, or ICU for that.
53 * Note also that FreeType does _not_ perform alpha blending or
54 * compositing the resulting bitmaps or pixmaps by itself. Use your
55 * favourite graphics library (for example, Cairo or Skia) to further
56 * process FreeType's output.
61 /**************************************************************************
67 * FreeType's header inclusion scheme
70 * How client applications should include FreeType header files.
73 * To be as flexible as possible (and for historical reasons), you must
74 * load file `ft2build.h` first before other header files, for example
77 * #include <ft2build.h>
79 * #include <freetype/freetype.h>
80 * #include <freetype/ftoutln.h>
85 /**************************************************************************
94 * How client applications should allocate FreeType data structures.
97 * FreeType assumes that structures allocated by the user and passed as
98 * arguments are zeroed out except for the actual data. In other words,
99 * it is recommended to use `calloc` (or variants of it) instead of
100 * `malloc` for allocation.
105 /**************************************************************************
108 * font_testing_macros
111 * Font Testing Macros
114 * Macros to test various properties of fonts.
117 * Macros to test the most important font properties.
119 * It is recommended to use these high-level macros instead of directly
120 * testing the corresponding flags, which are scattered over various
130 * FT_HAS_MULTIPLE_MASTERS
133 * FT_HAS_SBIX_OVERLAY
140 * FT_IS_NAMED_INSTANCE
146 /**************************************************************************
155 * Functions to start and end the usage of the FreeType library.
158 * Functions to start and end the usage of the FreeType library.
160 * Note that @FT_Library_Version and @FREETYPE_XXX are of limited use
161 * because even a new release of FreeType with only documentation
162 * changes increases the version number.
175 /**************************************************************************
184 * Functions to manage fonts.
187 * The functions and structures collected in this section operate on
211 /**************************************************************************
220 * Functions to manage font sizes.
223 * The functions and structures collected in this section are related to
224 * selecting and manipulating the size of a font globally.
237 * FT_Size_Request_Type
247 /**************************************************************************
256 * Functions to manage glyphs.
259 * The functions and structures collected in this section operate on
260 * single glyphs, of which @FT_Load_Glyph is most important.
269 * FT_LOAD_TARGET_MODE
276 * FT_Get_Track_Kerning
281 /**************************************************************************
290 * Functions to manage character-to-glyph maps.
293 * This section holds functions and structures that are related to
294 * mapping character input codes to glyph indices.
296 * Note that for many scripts the simplistic approach used by FreeType
297 * of mapping a single character to a single glyph is not valid or
298 * possible! In general, a higher-level library like HarfBuzz or ICU
299 * should be used for handling text strings.
309 * FT_Get_Charmap_Index
319 /**************************************************************************
322 * information_retrieval
325 * Information Retrieval
328 * Functions to retrieve font and glyph information.
331 * Functions to retrieve font and glyph information. Only some very
332 * basic data is covered; see also the chapter on the format-specific
339 * FT_Get_Postscript_Name
340 * FT_Get_FSType_Flags
342 * FT_Get_SubGlyph_Info
343 * FT_SUBGLYPH_FLAG_XXX
348 /**************************************************************************
357 * Other structures, enumerations, and macros.
360 * Other structures, enumerations, and macros. Deprecated functions are
371 * FT_Face_CheckTrueTypePatents
372 * FT_Face_SetUnpatentedHinting
377 /*************************************************************************/
378 /*************************************************************************/
380 /* B A S I C T Y P E S */
382 /*************************************************************************/
383 /*************************************************************************/
386 /**************************************************************************
393 /**************************************************************************
399 * A structure to model the metrics of a single glyph. The values are
400 * expressed in 26.6 fractional pixel format; if the flag
401 * @FT_LOAD_NO_SCALE has been used while loading the glyph, values are
402 * expressed in font units instead.
409 * The glyph's height.
412 * Left side bearing for horizontal layout.
415 * Top side bearing for horizontal layout.
418 * Advance width for horizontal layout.
421 * Left side bearing for vertical layout.
424 * Top side bearing for vertical layout. Larger positive values mean
425 * further below the vertical glyph origin.
428 * Advance height for vertical layout. Positive values mean the glyph
429 * has a positive advance downward.
432 * If not disabled with @FT_LOAD_NO_HINTING, the values represent
433 * dimensions of the hinted glyph (in case hinting is applicable).
435 * Stroking a glyph with an outside border does not increase
436 * `horiAdvance` or `vertAdvance`; you have to manually adjust these
437 * values to account for the added width and height.
439 * FreeType doesn't use the 'VORG' table data for CFF fonts because it
440 * doesn't have an interface to quickly retrieve the glyph height. The
441 * y~coordinate of the vertical origin can be simply computed as
442 * `vertBearingY + height` after loading a glyph.
444 typedef struct FT_Glyph_Metrics_
460 /**************************************************************************
467 /**************************************************************************
473 * This structure models the metrics of a bitmap strike (i.e., a set of
474 * glyphs for a given point size and resolution) in a bitmap font. It is
475 * used for the `available_sizes` field of @FT_Face.
479 * The vertical distance, in pixels, between two consecutive baselines.
480 * It is always positive.
483 * The average width, in pixels, of all glyphs in the strike.
486 * The nominal size of the strike in 26.6 fractional points. This
487 * field is not very useful.
490 * The horizontal ppem (nominal width) in 26.6 fractional pixels.
493 * The vertical ppem (nominal height) in 26.6 fractional pixels.
497 * The nominal size given in a FNT font is not reliable. If the driver
498 * finds it incorrect, it sets `size` to some calculated values, and
499 * `x_ppem` and `y_ppem` to the pixel width and height given in the
500 * font, respectively.
502 * TrueType embedded bitmaps:
503 * `size`, `width`, and `height` values are not contained in the bitmap
504 * strike itself. They are computed from the global font parameters.
506 typedef struct FT_Bitmap_Size_
519 /*************************************************************************/
520 /*************************************************************************/
522 /* O B J E C T C L A S S E S */
524 /*************************************************************************/
525 /*************************************************************************/
527 /**************************************************************************
534 /**************************************************************************
540 * A handle to a FreeType library instance. Each 'library' is completely
541 * independent from the others; it is the 'root' of a set of objects like
542 * fonts, faces, sizes, etc.
544 * It also embeds a memory manager (see @FT_Memory), as well as a
545 * scan-line converter object (see @FT_Raster).
547 * [Since 2.5.6] In multi-threaded applications it is easiest to use one
548 * `FT_Library` object per thread. In case this is too cumbersome, a
549 * single `FT_Library` object across threads is possible also, as long as
550 * a mutex lock is used around @FT_New_Face and @FT_Done_Face.
553 * Library objects are normally created by @FT_Init_FreeType, and
554 * destroyed with @FT_Done_FreeType. If you need reference-counting
555 * (cf. @FT_Reference_Library), use @FT_New_Library and @FT_Done_Library.
557 typedef struct FT_LibraryRec_ *FT_Library;
560 /**************************************************************************
567 /**************************************************************************
573 * A handle to a given FreeType module object. A module can be a font
574 * driver, a renderer, or anything else that provides services to the
577 typedef struct FT_ModuleRec_* FT_Module;
580 /**************************************************************************
586 * A handle to a given FreeType font driver object. A font driver is a
587 * module capable of creating faces from font files.
589 typedef struct FT_DriverRec_* FT_Driver;
592 /**************************************************************************
598 * A handle to a given FreeType renderer. A renderer is a module in
599 * charge of converting a glyph's outline image to a bitmap. It supports
600 * a single glyph image format, and one or more target surface depths.
602 typedef struct FT_RendererRec_* FT_Renderer;
605 /**************************************************************************
612 /**************************************************************************
618 * A handle to a typographic face object. A face object models a given
619 * typeface, in a given style.
622 * A face object also owns a single @FT_GlyphSlot object, as well as one
623 * or more @FT_Size objects.
625 * Use @FT_New_Face or @FT_Open_Face to create a new face object from a
626 * given filepath or a custom input stream.
628 * Use @FT_Done_Face to destroy it (along with its slot and sizes).
630 * An `FT_Face` object can only be safely used from one thread at a time.
631 * Similarly, creation and destruction of `FT_Face` with the same
632 * @FT_Library object can only be done from one thread at a time. On the
633 * other hand, functions like @FT_Load_Glyph and its siblings are
634 * thread-safe and do not need the lock to be held as long as the same
635 * `FT_Face` object is not used from multiple threads at the same time.
638 * See @FT_FaceRec for the publicly accessible fields of a given face
641 typedef struct FT_FaceRec_* FT_Face;
644 /**************************************************************************
651 /**************************************************************************
657 * A handle to an object that models a face scaled to a given character
661 * An @FT_Face has one _active_ `FT_Size` object that is used by
662 * functions like @FT_Load_Glyph to determine the scaling transformation
663 * that in turn is used to load and hint glyphs and metrics.
665 * A newly created `FT_Size` object contains only meaningless zero values.
666 * You must use @FT_Set_Char_Size, @FT_Set_Pixel_Sizes, @FT_Request_Size
667 * or even @FT_Select_Size to change the content (i.e., the scaling
668 * values) of the active `FT_Size`. Otherwise, the scaling and hinting
669 * will not be performed.
671 * You can use @FT_New_Size to create additional size objects for a given
672 * @FT_Face, but they won't be used by other functions until you activate
673 * it through @FT_Activate_Size. Only one size can be activated at any
674 * given time per face.
677 * See @FT_SizeRec for the publicly accessible fields of a given size
680 typedef struct FT_SizeRec_* FT_Size;
683 /**************************************************************************
690 /**************************************************************************
696 * A handle to a given 'glyph slot'. A slot is a container that can hold
697 * any of the glyphs contained in its parent face.
699 * In other words, each time you call @FT_Load_Glyph or @FT_Load_Char,
700 * the slot's content is erased by the new glyph data, i.e., the glyph's
701 * metrics, its image (bitmap or outline), and other control information.
704 * See @FT_GlyphSlotRec for the publicly accessible glyph fields.
706 typedef struct FT_GlyphSlotRec_* FT_GlyphSlot;
709 /**************************************************************************
716 /**************************************************************************
722 * A handle to a character map (usually abbreviated to 'charmap'). A
723 * charmap is used to translate character codes in a given encoding into
724 * glyph indexes for its parent's face. Some font formats may provide
725 * several charmaps per font.
727 * Each face object owns zero or more charmaps, but only one of them can
728 * be 'active', providing the data used by @FT_Get_Char_Index or
731 * The list of available charmaps in a face is available through the
732 * `face->num_charmaps` and `face->charmaps` fields of @FT_FaceRec.
734 * The currently active charmap is available as `face->charmap`. You
735 * should call @FT_Set_Charmap to change it.
738 * When a new face is created (either through @FT_New_Face or
739 * @FT_Open_Face), the library looks for a Unicode charmap within the
740 * list and automatically activates it. If there is no Unicode charmap,
741 * FreeType doesn't set an 'active' charmap.
744 * See @FT_CharMapRec for the publicly accessible fields of a given
747 typedef struct FT_CharMapRec_* FT_CharMap;
750 /**************************************************************************
756 * This macro converts four-letter tags into an unsigned long. It is
757 * used to define 'encoding' identifiers (see @FT_Encoding).
760 * Since many 16-bit compilers don't like 32-bit enumerations, you should
761 * redefine this macro in case of problems to something like this:
764 * #define FT_ENC_TAG( value, a, b, c, d ) value
767 * to get a simple enumeration without assigning special numbers.
772 #define FT_ENC_TAG( value, a, b, c, d ) \
773 value = ( ( FT_STATIC_BYTE_CAST( FT_UInt32, a ) << 24 ) | \
774 ( FT_STATIC_BYTE_CAST( FT_UInt32, b ) << 16 ) | \
775 ( FT_STATIC_BYTE_CAST( FT_UInt32, c ) << 8 ) | \
776 FT_STATIC_BYTE_CAST( FT_UInt32, d ) )
778 #endif /* FT_ENC_TAG */
781 /**************************************************************************
787 * An enumeration to specify character sets supported by charmaps. Used
788 * in the @FT_Select_Charmap API function.
791 * Despite the name, this enumeration lists specific character
792 * repertoires (i.e., charsets), and not text encoding methods (e.g.,
793 * UTF-8, UTF-16, etc.).
795 * Other encodings might be defined in the future.
798 * FT_ENCODING_NONE ::
799 * The encoding value~0 is reserved for all formats except BDF, PCF,
800 * and Windows FNT; see below for more information.
802 * FT_ENCODING_UNICODE ::
803 * The Unicode character set. This value covers all versions of the
804 * Unicode repertoire, including ASCII and Latin-1. Most fonts include
805 * a Unicode charmap, but not all of them.
807 * For example, if you want to access Unicode value U+1F028 (and the
808 * font contains it), use value 0x1F028 as the input value for
809 * @FT_Get_Char_Index.
811 * FT_ENCODING_MS_SYMBOL ::
812 * Microsoft Symbol encoding, used to encode mathematical symbols and
813 * wingdings. For more information, see
814 * 'https://www.microsoft.com/typography/otspec/recom.htm#non-standard-symbol-fonts',
815 * 'http://www.kostis.net/charsets/symbol.htm', and
816 * 'http://www.kostis.net/charsets/wingding.htm'.
818 * This encoding uses character codes from the PUA (Private Unicode
819 * Area) in the range U+F020-U+F0FF.
821 * FT_ENCODING_SJIS ::
822 * Shift JIS encoding for Japanese. More info at
823 * 'https://en.wikipedia.org/wiki/Shift_JIS'. See note on multi-byte
827 * Corresponds to encoding systems mainly for Simplified Chinese as
828 * used in People's Republic of China (PRC). The encoding layout is
829 * based on GB~2312 and its supersets GBK and GB~18030.
831 * FT_ENCODING_BIG5 ::
832 * Corresponds to an encoding system for Traditional Chinese as used in
833 * Taiwan and Hong Kong.
835 * FT_ENCODING_WANSUNG ::
836 * Corresponds to the Korean encoding system known as Extended Wansung
837 * (MS Windows code page 949). For more information see
838 * 'https://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WindowsBestFit/bestfit949.txt'.
840 * FT_ENCODING_JOHAB ::
841 * The Korean standard character set (KS~C 5601-1992), which
842 * corresponds to MS Windows code page 1361. This character set
843 * includes all possible Hangul character combinations.
845 * FT_ENCODING_ADOBE_LATIN_1 ::
846 * Corresponds to a Latin-1 encoding as defined in a Type~1 PostScript
847 * font. It is limited to 256 character codes.
849 * FT_ENCODING_ADOBE_STANDARD ::
850 * Adobe Standard encoding, as found in Type~1, CFF, and OpenType/CFF
851 * fonts. It is limited to 256 character codes.
853 * FT_ENCODING_ADOBE_EXPERT ::
854 * Adobe Expert encoding, as found in Type~1, CFF, and OpenType/CFF
855 * fonts. It is limited to 256 character codes.
857 * FT_ENCODING_ADOBE_CUSTOM ::
858 * Corresponds to a custom encoding, as found in Type~1, CFF, and
859 * OpenType/CFF fonts. It is limited to 256 character codes.
861 * FT_ENCODING_APPLE_ROMAN ::
862 * Apple roman encoding. Many TrueType and OpenType fonts contain a
863 * charmap for this 8-bit encoding, since older versions of Mac OS are
866 * FT_ENCODING_OLD_LATIN_2 ::
867 * This value is deprecated and was neither used nor reported by
868 * FreeType. Don't use or test for it.
870 * FT_ENCODING_MS_SJIS ::
871 * Same as FT_ENCODING_SJIS. Deprecated.
873 * FT_ENCODING_MS_GB2312 ::
874 * Same as FT_ENCODING_PRC. Deprecated.
876 * FT_ENCODING_MS_BIG5 ::
877 * Same as FT_ENCODING_BIG5. Deprecated.
879 * FT_ENCODING_MS_WANSUNG ::
880 * Same as FT_ENCODING_WANSUNG. Deprecated.
882 * FT_ENCODING_MS_JOHAB ::
883 * Same as FT_ENCODING_JOHAB. Deprecated.
886 * When loading a font, FreeType makes a Unicode charmap active if
887 * possible (either if the font provides such a charmap, or if FreeType
888 * can synthesize one from PostScript glyph name dictionaries; in either
889 * case, the charmap is tagged with `FT_ENCODING_UNICODE`). If such a
890 * charmap is synthesized, it is placed at the first position of the
893 * All other encodings are considered legacy and tagged only if
894 * explicitly defined in the font file. Otherwise, `FT_ENCODING_NONE` is
897 * `FT_ENCODING_NONE` is set by the BDF and PCF drivers if the charmap is
898 * neither Unicode nor ISO-8859-1 (otherwise it is set to
899 * `FT_ENCODING_UNICODE`). Use @FT_Get_BDF_Charset_ID to find out which
900 * encoding is really present. If, for example, the `cs_registry` field
901 * is 'KOI8' and the `cs_encoding` field is 'R', the font is encoded in
904 * `FT_ENCODING_NONE` is always set (with a single exception) by the
905 * winfonts driver. Use @FT_Get_WinFNT_Header and examine the `charset`
906 * field of the @FT_WinFNT_HeaderRec structure to find out which encoding
907 * is really present. For example, @FT_WinFNT_ID_CP1251 (204) means
908 * Windows code page 1251 (for Russian).
910 * `FT_ENCODING_NONE` is set if `platform_id` is @TT_PLATFORM_MACINTOSH
911 * and `encoding_id` is not `TT_MAC_ID_ROMAN` (otherwise it is set to
912 * `FT_ENCODING_APPLE_ROMAN`).
914 * If `platform_id` is @TT_PLATFORM_MACINTOSH, use the function
915 * @FT_Get_CMap_Language_ID to query the Mac language ID that may be
916 * needed to be able to distinguish Apple encoding variants. See
918 * https://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/Readme.txt
920 * to get an idea how to do that. Basically, if the language ID is~0,
921 * don't use it, otherwise subtract 1 from the language ID. Then examine
922 * `encoding_id`. If, for example, `encoding_id` is `TT_MAC_ID_ROMAN`
923 * and the language ID (minus~1) is `TT_MAC_LANGID_GREEK`, it is the
924 * Greek encoding, not Roman. `TT_MAC_ID_ARABIC` with
925 * `TT_MAC_LANGID_FARSI` means the Farsi variant of the Arabic encoding.
927 typedef enum FT_Encoding_
929 FT_ENC_TAG( FT_ENCODING_NONE, 0, 0, 0, 0 ),
931 FT_ENC_TAG( FT_ENCODING_MS_SYMBOL, 's', 'y', 'm', 'b' ),
932 FT_ENC_TAG( FT_ENCODING_UNICODE, 'u', 'n', 'i', 'c' ),
934 FT_ENC_TAG( FT_ENCODING_SJIS, 's', 'j', 'i', 's' ),
935 FT_ENC_TAG( FT_ENCODING_PRC, 'g', 'b', ' ', ' ' ),
936 FT_ENC_TAG( FT_ENCODING_BIG5, 'b', 'i', 'g', '5' ),
937 FT_ENC_TAG( FT_ENCODING_WANSUNG, 'w', 'a', 'n', 's' ),
938 FT_ENC_TAG( FT_ENCODING_JOHAB, 'j', 'o', 'h', 'a' ),
940 /* for backward compatibility */
941 FT_ENCODING_GB2312 = FT_ENCODING_PRC,
942 FT_ENCODING_MS_SJIS = FT_ENCODING_SJIS,
943 FT_ENCODING_MS_GB2312 = FT_ENCODING_PRC,
944 FT_ENCODING_MS_BIG5 = FT_ENCODING_BIG5,
945 FT_ENCODING_MS_WANSUNG = FT_ENCODING_WANSUNG,
946 FT_ENCODING_MS_JOHAB = FT_ENCODING_JOHAB,
948 FT_ENC_TAG( FT_ENCODING_ADOBE_STANDARD, 'A', 'D', 'O', 'B' ),
949 FT_ENC_TAG( FT_ENCODING_ADOBE_EXPERT, 'A', 'D', 'B', 'E' ),
950 FT_ENC_TAG( FT_ENCODING_ADOBE_CUSTOM, 'A', 'D', 'B', 'C' ),
951 FT_ENC_TAG( FT_ENCODING_ADOBE_LATIN_1, 'l', 'a', 't', '1' ),
953 FT_ENC_TAG( FT_ENCODING_OLD_LATIN_2, 'l', 'a', 't', '2' ),
955 FT_ENC_TAG( FT_ENCODING_APPLE_ROMAN, 'a', 'r', 'm', 'n' )
960 /* these constants are deprecated; use the corresponding `FT_Encoding` */
962 #define ft_encoding_none FT_ENCODING_NONE
963 #define ft_encoding_unicode FT_ENCODING_UNICODE
964 #define ft_encoding_symbol FT_ENCODING_MS_SYMBOL
965 #define ft_encoding_latin_1 FT_ENCODING_ADOBE_LATIN_1
966 #define ft_encoding_latin_2 FT_ENCODING_OLD_LATIN_2
967 #define ft_encoding_sjis FT_ENCODING_SJIS
968 #define ft_encoding_gb2312 FT_ENCODING_PRC
969 #define ft_encoding_big5 FT_ENCODING_BIG5
970 #define ft_encoding_wansung FT_ENCODING_WANSUNG
971 #define ft_encoding_johab FT_ENCODING_JOHAB
973 #define ft_encoding_adobe_standard FT_ENCODING_ADOBE_STANDARD
974 #define ft_encoding_adobe_expert FT_ENCODING_ADOBE_EXPERT
975 #define ft_encoding_adobe_custom FT_ENCODING_ADOBE_CUSTOM
976 #define ft_encoding_apple_roman FT_ENCODING_APPLE_ROMAN
979 /**************************************************************************
985 * The base charmap structure.
989 * A handle to the parent face object.
992 * An @FT_Encoding tag identifying the charmap. Use this with
993 * @FT_Select_Charmap.
996 * An ID number describing the platform for the following encoding ID.
997 * This comes directly from the TrueType specification and gets
998 * emulated for other formats.
1001 * A platform-specific encoding number. This also comes from the
1002 * TrueType specification and gets emulated similarly.
1004 typedef struct FT_CharMapRec_
1007 FT_Encoding encoding;
1008 FT_UShort platform_id;
1009 FT_UShort encoding_id;
1014 /*************************************************************************/
1015 /*************************************************************************/
1017 /* B A S E O B J E C T C L A S S E S */
1019 /*************************************************************************/
1020 /*************************************************************************/
1023 /**************************************************************************
1030 /**************************************************************************
1036 * An opaque handle to an `FT_Face_InternalRec` structure that models the
1037 * private data of a given @FT_Face object.
1039 * This structure might change between releases of FreeType~2 and is not
1040 * generally available to client applications.
1042 typedef struct FT_Face_InternalRec_* FT_Face_Internal;
1045 /**************************************************************************
1052 /**************************************************************************
1058 * FreeType root face class structure. A face object models a typeface
1063 * The number of faces in the font file. Some font formats can have
1064 * multiple faces in a single font file.
1067 * This field holds two different values. Bits 0-15 are the index of
1068 * the face in the font file (starting with value~0). They are set
1069 * to~0 if there is only one face in the font file.
1071 * [Since 2.6.1] Bits 16-30 are relevant to GX and OpenType variation
1072 * fonts only, holding the named instance index for the current face
1073 * index (starting with value~1; value~0 indicates font access without
1074 * a named instance). For non-variation fonts, bits 16-30 are ignored.
1075 * If we have the third named instance of face~4, say, `face_index` is
1076 * set to 0x00030004.
1078 * Bit 31 is always zero (that is, `face_index` is always a positive
1081 * [Since 2.9] Changing the design coordinates with
1082 * @FT_Set_Var_Design_Coordinates or @FT_Set_Var_Blend_Coordinates does
1083 * not influence the named instance index value (only
1084 * @FT_Set_Named_Instance does that).
1087 * A set of bit flags that give important information about the face;
1088 * see @FT_FACE_FLAG_XXX for the details.
1091 * The lower 16~bits contain a set of bit flags indicating the style of
1092 * the face; see @FT_STYLE_FLAG_XXX for the details.
1094 * [Since 2.6.1] Bits 16-30 hold the number of named instances
1095 * available for the current face if we have a GX or OpenType variation
1096 * (sub)font. Bit 31 is always zero (that is, `style_flags` is always
1097 * a positive value). Note that a variation font has always at least
1098 * one named instance, namely the default instance.
1101 * The number of glyphs in the face. If the face is scalable and has
1102 * sbits (see `num_fixed_sizes`), it is set to the number of outline
1105 * For CID-keyed fonts (not in an SFNT wrapper) this value gives the
1106 * highest CID used in the font.
1109 * The face's family name. This is an ASCII string, usually in
1110 * English, that describes the typeface's family (like 'Times New
1111 * Roman', 'Bodoni', 'Garamond', etc). This is a least common
1112 * denominator used to list fonts. Some formats (TrueType & OpenType)
1113 * provide localized and Unicode versions of this string. Applications
1114 * should use the format-specific interface to access them. Can be
1115 * `NULL` (e.g., in fonts embedded in a PDF file).
1117 * In case the font doesn't provide a specific family name entry,
1118 * FreeType tries to synthesize one, deriving it from other name
1122 * The face's style name. This is an ASCII string, usually in English,
1123 * that describes the typeface's style (like 'Italic', 'Bold',
1124 * 'Condensed', etc). Not all font formats provide a style name, so
1125 * this field is optional, and can be set to `NULL`. As for
1126 * `family_name`, some formats provide localized and Unicode versions
1127 * of this string. Applications should use the format-specific
1128 * interface to access them.
1130 * num_fixed_sizes ::
1131 * The number of bitmap strikes in the face. Even if the face is
1132 * scalable, there might still be bitmap strikes, which are called
1133 * 'sbits' in that case.
1135 * available_sizes ::
1136 * An array of @FT_Bitmap_Size for all bitmap strikes in the face. It
1137 * is set to `NULL` if there is no bitmap strike.
1139 * Note that FreeType tries to sanitize the strike data since they are
1140 * sometimes sloppy or incorrect, but this can easily fail.
1143 * The number of charmaps in the face.
1146 * An array of the charmaps of the face.
1149 * A field reserved for client uses. See the @FT_Generic type
1153 * The font bounding box. Coordinates are expressed in font units (see
1154 * `units_per_EM`). The box is large enough to contain any glyph from
1155 * the font. Thus, `bbox.yMax` can be seen as the 'maximum ascender',
1156 * and `bbox.yMin` as the 'minimum descender'. Only relevant for
1159 * Note that the bounding box might be off by (at least) one pixel for
1160 * hinted fonts. See @FT_Size_Metrics for further discussion.
1162 * Note that the bounding box does not vary in OpenType variation fonts
1163 * and should only be used in relation to the default instance.
1166 * The number of font units per EM square for this face. This is
1167 * typically 2048 for TrueType fonts, and 1000 for Type~1 fonts. Only
1168 * relevant for scalable formats.
1171 * The typographic ascender of the face, expressed in font units. For
1172 * font formats not having this information, it is set to `bbox.yMax`.
1173 * Only relevant for scalable formats.
1176 * The typographic descender of the face, expressed in font units. For
1177 * font formats not having this information, it is set to `bbox.yMin`.
1178 * Note that this field is negative for values below the baseline.
1179 * Only relevant for scalable formats.
1182 * This value is the vertical distance between two consecutive
1183 * baselines, expressed in font units. It is always positive. Only
1184 * relevant for scalable formats.
1186 * If you want the global glyph height, use `ascender - descender`.
1188 * max_advance_width ::
1189 * The maximum advance width, in font units, for all glyphs in this
1190 * face. This can be used to make word wrapping computations faster.
1191 * Only relevant for scalable formats.
1193 * max_advance_height ::
1194 * The maximum advance height, in font units, for all glyphs in this
1195 * face. This is only relevant for vertical layouts, and is set to
1196 * `height` for fonts that do not provide vertical metrics. Only
1197 * relevant for scalable formats.
1199 * underline_position ::
1200 * The position, in font units, of the underline line for this face.
1201 * It is the center of the underlining stem. Only relevant for
1204 * underline_thickness ::
1205 * The thickness, in font units, of the underline for this face. Only
1206 * relevant for scalable formats.
1209 * The face's associated glyph slot(s).
1212 * The current active size for this face.
1215 * The current active charmap for this face.
1218 * Fields may be changed after a call to @FT_Attach_File or
1219 * @FT_Attach_Stream.
1221 * For an OpenType variation font, the values of the following fields can
1222 * change after a call to @FT_Set_Var_Design_Coordinates (and friends) if
1223 * the font contains an 'MVAR' table: `ascender`, `descender`, `height`,
1224 * `underline_position`, and `underline_thickness`.
1226 * Especially for TrueType fonts see also the documentation for
1229 typedef struct FT_FaceRec_
1235 FT_Long style_flags;
1239 FT_String* family_name;
1240 FT_String* style_name;
1242 FT_Int num_fixed_sizes;
1243 FT_Bitmap_Size* available_sizes;
1245 FT_Int num_charmaps;
1246 FT_CharMap* charmaps;
1250 /* The following member variables (down to `underline_thickness`) */
1251 /* are only relevant to scalable outlines; cf. @FT_Bitmap_Size */
1252 /* for bitmap fonts. */
1255 FT_UShort units_per_EM;
1260 FT_Short max_advance_width;
1261 FT_Short max_advance_height;
1263 FT_Short underline_position;
1264 FT_Short underline_thickness;
1270 /* private fields, internal to FreeType */
1276 FT_ListRec sizes_list;
1278 FT_Generic autohint; /* face-specific auto-hinter data */
1279 void* extensions; /* unused */
1281 FT_Face_Internal internal;
1286 /**************************************************************************
1292 * A list of bit flags used in the `face_flags` field of the @FT_FaceRec
1293 * structure. They inform client applications of properties of the
1294 * corresponding face.
1297 * FT_FACE_FLAG_SCALABLE ::
1298 * The face contains outline glyphs. Note that a face can contain
1299 * bitmap strikes also, i.e., a face can have both this flag and
1300 * @FT_FACE_FLAG_FIXED_SIZES set.
1302 * FT_FACE_FLAG_FIXED_SIZES ::
1303 * The face contains bitmap strikes. See also the `num_fixed_sizes`
1304 * and `available_sizes` fields of @FT_FaceRec.
1306 * FT_FACE_FLAG_FIXED_WIDTH ::
1307 * The face contains fixed-width characters (like Courier, Lucida,
1310 * FT_FACE_FLAG_SFNT ::
1311 * The face uses the SFNT storage scheme. For now, this means TrueType
1314 * FT_FACE_FLAG_HORIZONTAL ::
1315 * The face contains horizontal glyph metrics. This should be set for
1316 * all common formats.
1318 * FT_FACE_FLAG_VERTICAL ::
1319 * The face contains vertical glyph metrics. This is only available in
1320 * some formats, not all of them.
1322 * FT_FACE_FLAG_KERNING ::
1323 * The face contains kerning information. If set, the kerning distance
1324 * can be retrieved using the function @FT_Get_Kerning. Otherwise the
1325 * function always returns the vector (0,0). Note that FreeType
1326 * doesn't handle kerning data from the SFNT 'GPOS' table (as present
1327 * in many OpenType fonts).
1329 * FT_FACE_FLAG_FAST_GLYPHS ::
1330 * THIS FLAG IS DEPRECATED. DO NOT USE OR TEST IT.
1332 * FT_FACE_FLAG_MULTIPLE_MASTERS ::
1333 * The face contains multiple masters and is capable of interpolating
1334 * between them. Supported formats are Adobe MM, TrueType GX, and
1335 * OpenType variation fonts.
1337 * See section @multiple_masters for API details.
1339 * FT_FACE_FLAG_GLYPH_NAMES ::
1340 * The face contains glyph names, which can be retrieved using
1341 * @FT_Get_Glyph_Name. Note that some TrueType fonts contain broken
1342 * glyph name tables. Use the function @FT_Has_PS_Glyph_Names when
1345 * FT_FACE_FLAG_EXTERNAL_STREAM ::
1346 * Used internally by FreeType to indicate that a face's stream was
1347 * provided by the client application and should not be destroyed when
1348 * @FT_Done_Face is called. Don't read or test this flag.
1350 * FT_FACE_FLAG_HINTER ::
1351 * The font driver has a hinting machine of its own. For example, with
1352 * TrueType fonts, it makes sense to use data from the SFNT 'gasp'
1353 * table only if the native TrueType hinting engine (with the bytecode
1354 * interpreter) is available and active.
1356 * FT_FACE_FLAG_CID_KEYED ::
1357 * The face is CID-keyed. In that case, the face is not accessed by
1358 * glyph indices but by CID values. For subsetted CID-keyed fonts this
1359 * has the consequence that not all index values are a valid argument
1360 * to @FT_Load_Glyph. Only the CID values for which corresponding
1361 * glyphs in the subsetted font exist make `FT_Load_Glyph` return
1362 * successfully; in all other cases you get an
1363 * `FT_Err_Invalid_Argument` error.
1365 * Note that CID-keyed fonts that are in an SFNT wrapper (that is, all
1366 * OpenType/CFF fonts) don't have this flag set since the glyphs are
1367 * accessed in the normal way (using contiguous indices); the
1368 * 'CID-ness' isn't visible to the application.
1370 * FT_FACE_FLAG_TRICKY ::
1371 * The face is 'tricky', that is, it always needs the font format's
1372 * native hinting engine to get a reasonable result. A typical example
1373 * is the old Chinese font `mingli.ttf` (but not `mingliu.ttc`) that
1374 * uses TrueType bytecode instructions to move and scale all of its
1377 * It is not possible to auto-hint such fonts using
1378 * @FT_LOAD_FORCE_AUTOHINT; it will also ignore @FT_LOAD_NO_HINTING.
1379 * You have to set both @FT_LOAD_NO_HINTING and @FT_LOAD_NO_AUTOHINT to
1380 * really disable hinting; however, you probably never want this except
1381 * for demonstration purposes.
1383 * Currently, there are about a dozen TrueType fonts in the list of
1384 * tricky fonts; they are hard-coded in file `ttobjs.c`.
1386 * FT_FACE_FLAG_COLOR ::
1387 * [Since 2.5.1] The face has color glyph tables. See @FT_LOAD_COLOR
1388 * for more information.
1390 * FT_FACE_FLAG_VARIATION ::
1391 * [Since 2.9] Set if the current face (or named instance) has been
1392 * altered with @FT_Set_MM_Design_Coordinates,
1393 * @FT_Set_Var_Design_Coordinates, @FT_Set_Var_Blend_Coordinates, or
1394 * @FT_Set_MM_WeightVector to select a non-default instance.
1396 * FT_FACE_FLAG_SVG ::
1397 * [Since 2.12] The face has an 'SVG~' OpenType table.
1399 * FT_FACE_FLAG_SBIX ::
1400 * [Since 2.12] The face has an 'sbix' OpenType table *and* outlines.
1401 * For such fonts, @FT_FACE_FLAG_SCALABLE is not set by default to
1402 * retain backward compatibility.
1404 * FT_FACE_FLAG_SBIX_OVERLAY ::
1405 * [Since 2.12] The face has an 'sbix' OpenType table where outlines
1406 * should be drawn on top of bitmap strikes.
1409 #define FT_FACE_FLAG_SCALABLE ( 1L << 0 )
1410 #define FT_FACE_FLAG_FIXED_SIZES ( 1L << 1 )
1411 #define FT_FACE_FLAG_FIXED_WIDTH ( 1L << 2 )
1412 #define FT_FACE_FLAG_SFNT ( 1L << 3 )
1413 #define FT_FACE_FLAG_HORIZONTAL ( 1L << 4 )
1414 #define FT_FACE_FLAG_VERTICAL ( 1L << 5 )
1415 #define FT_FACE_FLAG_KERNING ( 1L << 6 )
1416 #define FT_FACE_FLAG_FAST_GLYPHS ( 1L << 7 )
1417 #define FT_FACE_FLAG_MULTIPLE_MASTERS ( 1L << 8 )
1418 #define FT_FACE_FLAG_GLYPH_NAMES ( 1L << 9 )
1419 #define FT_FACE_FLAG_EXTERNAL_STREAM ( 1L << 10 )
1420 #define FT_FACE_FLAG_HINTER ( 1L << 11 )
1421 #define FT_FACE_FLAG_CID_KEYED ( 1L << 12 )
1422 #define FT_FACE_FLAG_TRICKY ( 1L << 13 )
1423 #define FT_FACE_FLAG_COLOR ( 1L << 14 )
1424 #define FT_FACE_FLAG_VARIATION ( 1L << 15 )
1425 #define FT_FACE_FLAG_SVG ( 1L << 16 )
1426 #define FT_FACE_FLAG_SBIX ( 1L << 17 )
1427 #define FT_FACE_FLAG_SBIX_OVERLAY ( 1L << 18 )
1430 /**************************************************************************
1433 * font_testing_macros
1437 /**************************************************************************
1443 * A macro that returns true whenever a face object contains horizontal
1444 * metrics (this is true for all font formats though).
1447 * @FT_HAS_VERTICAL can be used to check for vertical metrics.
1450 #define FT_HAS_HORIZONTAL( face ) \
1451 ( !!( (face)->face_flags & FT_FACE_FLAG_HORIZONTAL ) )
1454 /**************************************************************************
1460 * A macro that returns true whenever a face object contains real
1461 * vertical metrics (and not only synthesized ones).
1464 #define FT_HAS_VERTICAL( face ) \
1465 ( !!( (face)->face_flags & FT_FACE_FLAG_VERTICAL ) )
1468 /**************************************************************************
1474 * A macro that returns true whenever a face object contains kerning data
1475 * that can be accessed with @FT_Get_Kerning.
1478 #define FT_HAS_KERNING( face ) \
1479 ( !!( (face)->face_flags & FT_FACE_FLAG_KERNING ) )
1482 /**************************************************************************
1488 * A macro that returns true whenever a face object contains a scalable
1489 * font face (true for TrueType, Type~1, Type~42, CID, OpenType/CFF, and
1490 * PFR font formats).
1493 #define FT_IS_SCALABLE( face ) \
1494 ( !!( (face)->face_flags & FT_FACE_FLAG_SCALABLE ) )
1497 /**************************************************************************
1503 * A macro that returns true whenever a face object contains a font whose
1504 * format is based on the SFNT storage scheme. This usually means:
1505 * TrueType fonts, OpenType fonts, as well as SFNT-based embedded bitmap
1508 * If this macro is true, all functions defined in @FT_SFNT_NAMES_H and
1509 * @FT_TRUETYPE_TABLES_H are available.
1512 #define FT_IS_SFNT( face ) \
1513 ( !!( (face)->face_flags & FT_FACE_FLAG_SFNT ) )
1516 /**************************************************************************
1522 * A macro that returns true whenever a face object contains a font face
1523 * that contains fixed-width (or 'monospace', 'fixed-pitch', etc.)
1527 #define FT_IS_FIXED_WIDTH( face ) \
1528 ( !!( (face)->face_flags & FT_FACE_FLAG_FIXED_WIDTH ) )
1531 /**************************************************************************
1534 * FT_HAS_FIXED_SIZES
1537 * A macro that returns true whenever a face object contains some
1538 * embedded bitmaps. See the `available_sizes` field of the @FT_FaceRec
1542 #define FT_HAS_FIXED_SIZES( face ) \
1543 ( !!( (face)->face_flags & FT_FACE_FLAG_FIXED_SIZES ) )
1546 /**************************************************************************
1553 /**************************************************************************
1556 * FT_HAS_FAST_GLYPHS
1562 #define FT_HAS_FAST_GLYPHS( face ) 0
1565 /**************************************************************************
1568 * font_testing_macros
1572 /**************************************************************************
1575 * FT_HAS_GLYPH_NAMES
1578 * A macro that returns true whenever a face object contains some glyph
1579 * names that can be accessed through @FT_Get_Glyph_Name.
1582 #define FT_HAS_GLYPH_NAMES( face ) \
1583 ( !!( (face)->face_flags & FT_FACE_FLAG_GLYPH_NAMES ) )
1586 /**************************************************************************
1589 * FT_HAS_MULTIPLE_MASTERS
1592 * A macro that returns true whenever a face object contains some
1593 * multiple masters. The functions provided by @FT_MULTIPLE_MASTERS_H
1594 * are then available to choose the exact design you want.
1597 #define FT_HAS_MULTIPLE_MASTERS( face ) \
1598 ( !!( (face)->face_flags & FT_FACE_FLAG_MULTIPLE_MASTERS ) )
1601 /**************************************************************************
1604 * FT_IS_NAMED_INSTANCE
1607 * A macro that returns true whenever a face object is a named instance
1608 * of a GX or OpenType variation font.
1610 * [Since 2.9] Changing the design coordinates with
1611 * @FT_Set_Var_Design_Coordinates or @FT_Set_Var_Blend_Coordinates does
1612 * not influence the return value of this macro (only
1613 * @FT_Set_Named_Instance does that).
1619 #define FT_IS_NAMED_INSTANCE( face ) \
1620 ( !!( (face)->face_index & 0x7FFF0000L ) )
1623 /**************************************************************************
1629 * A macro that returns true whenever a face object has been altered by
1630 * @FT_Set_MM_Design_Coordinates, @FT_Set_Var_Design_Coordinates,
1631 * @FT_Set_Var_Blend_Coordinates, or @FT_Set_MM_WeightVector.
1637 #define FT_IS_VARIATION( face ) \
1638 ( !!( (face)->face_flags & FT_FACE_FLAG_VARIATION ) )
1641 /**************************************************************************
1647 * A macro that returns true whenever a face object contains a CID-keyed
1648 * font. See the discussion of @FT_FACE_FLAG_CID_KEYED for more details.
1650 * If this macro is true, all functions defined in @FT_CID_H are
1654 #define FT_IS_CID_KEYED( face ) \
1655 ( !!( (face)->face_flags & FT_FACE_FLAG_CID_KEYED ) )
1658 /**************************************************************************
1664 * A macro that returns true whenever a face represents a 'tricky' font.
1665 * See the discussion of @FT_FACE_FLAG_TRICKY for more details.
1668 #define FT_IS_TRICKY( face ) \
1669 ( !!( (face)->face_flags & FT_FACE_FLAG_TRICKY ) )
1672 /**************************************************************************
1678 * A macro that returns true whenever a face object contains tables for
1685 #define FT_HAS_COLOR( face ) \
1686 ( !!( (face)->face_flags & FT_FACE_FLAG_COLOR ) )
1689 /**************************************************************************
1695 * A macro that returns true whenever a face object contains an 'SVG~'
1701 #define FT_HAS_SVG( face ) \
1702 ( !!( (face)->face_flags & FT_FACE_FLAG_SVG ) )
1705 /**************************************************************************
1711 * A macro that returns true whenever a face object contains an 'sbix'
1712 * OpenType table *and* outline glyphs.
1714 * Currently, FreeType only supports bitmap glyphs in PNG format for this
1715 * table (i.e., JPEG and TIFF formats are unsupported, as are
1716 * Apple-specific formats not part of the OpenType specification).
1719 * For backward compatibility, a font with an 'sbix' table is treated as
1720 * a bitmap-only face. Using @FT_Open_Face with
1721 * @FT_PARAM_TAG_IGNORE_SBIX, an application can switch off 'sbix'
1722 * handling so that the face is treated as an ordinary outline font with
1723 * scalable outlines.
1725 * Here is some pseudo code that roughly illustrates how to implement
1726 * 'sbix' handling according to the OpenType specification.
1729 * if ( FT_HAS_SBIX( face ) )
1731 * // open font as a scalable one without sbix handling
1733 * FT_Parameter param = { FT_PARAM_TAG_IGNORE_SBIX, NULL };
1734 * FT_Open_Args args = { FT_OPEN_PARAMS | ...,
1739 * FT_Open_Face( library, &args, 0, &face2 );
1741 * <sort `face->available_size` as necessary into
1742 * `preferred_sizes`[*]>
1744 * for ( i = 0; i < face->num_fixed_sizes; i++ )
1746 * size = preferred_sizes[i].size;
1748 * error = FT_Set_Pixel_Sizes( face, size, size );
1749 * <error handling omitted>
1751 * // check whether we have a glyph in a bitmap strike
1752 * error = FT_Load_Glyph( face,
1754 * FT_LOAD_SBITS_ONLY |
1755 * FT_LOAD_BITMAP_METRICS_ONLY );
1756 * if ( error == FT_Err_Invalid_Argument )
1759 * <other error handling omitted>
1764 * if ( i != face->num_fixed_sizes )
1765 * <load embedded bitmap with `FT_Load_Glyph`,
1766 * scale it, display it, etc.>
1768 * if ( i == face->num_fixed_sizes ||
1769 * FT_HAS_SBIX_OVERLAY( face ) )
1770 * <use `face2` to load outline glyph with `FT_Load_Glyph`,
1771 * scale it, display it on top of the bitmap, etc.>
1775 * [*] Assuming a target value of 400dpi and available strike sizes 100,
1776 * 200, 300, and 400dpi, a possible order might be [400, 200, 300, 100]:
1777 * scaling 200dpi to 400dpi usually gives better results than scaling
1778 * 300dpi to 400dpi; it is also much faster. However, scaling 100dpi to
1779 * 400dpi can yield a too pixelated result, thus the preference might be
1780 * 300dpi over 100dpi.
1785 #define FT_HAS_SBIX( face ) \
1786 ( !!( (face)->face_flags & FT_FACE_FLAG_SBIX ) )
1789 /**************************************************************************
1792 * FT_HAS_SBIX_OVERLAY
1795 * A macro that returns true whenever a face object contains an 'sbix'
1796 * OpenType table with bit~1 in its `flags` field set, instructing the
1797 * application to overlay the bitmap strike with the corresponding
1798 * outline glyph. See @FT_HAS_SBIX for pseudo code how to use it.
1803 #define FT_HAS_SBIX_OVERLAY( face ) \
1804 ( !!( (face)->face_flags & FT_FACE_FLAG_SBIX_OVERLAY ) )
1807 /**************************************************************************
1814 /**************************************************************************
1820 * A list of bit flags to indicate the style of a given face. These are
1821 * used in the `style_flags` field of @FT_FaceRec.
1824 * FT_STYLE_FLAG_ITALIC ::
1825 * The face style is italic or oblique.
1827 * FT_STYLE_FLAG_BOLD ::
1831 * The style information as provided by FreeType is very basic. More
1832 * details are beyond the scope and should be done on a higher level (for
1833 * example, by analyzing various fields of the 'OS/2' table in SFNT based
1836 #define FT_STYLE_FLAG_ITALIC ( 1 << 0 )
1837 #define FT_STYLE_FLAG_BOLD ( 1 << 1 )
1840 /**************************************************************************
1847 /**************************************************************************
1853 * An opaque handle to an `FT_Size_InternalRec` structure, used to model
1854 * private data of a given @FT_Size object.
1856 typedef struct FT_Size_InternalRec_* FT_Size_Internal;
1859 /**************************************************************************
1862 * sizing_and_scaling
1866 /**************************************************************************
1872 * The size metrics structure gives the metrics of a size object.
1876 * The width of the scaled EM square in pixels, hence the term 'ppem'
1877 * (pixels per EM). It is also referred to as 'nominal width'.
1880 * The height of the scaled EM square in pixels, hence the term 'ppem'
1881 * (pixels per EM). It is also referred to as 'nominal height'.
1884 * A 16.16 fractional scaling value to convert horizontal metrics from
1885 * font units to 26.6 fractional pixels. Only relevant for scalable
1889 * A 16.16 fractional scaling value to convert vertical metrics from
1890 * font units to 26.6 fractional pixels. Only relevant for scalable
1894 * The ascender in 26.6 fractional pixels, rounded up to an integer
1895 * value. See @FT_FaceRec for the details.
1898 * The descender in 26.6 fractional pixels, rounded down to an integer
1899 * value. See @FT_FaceRec for the details.
1902 * The height in 26.6 fractional pixels, rounded to an integer value.
1903 * See @FT_FaceRec for the details.
1906 * The maximum advance width in 26.6 fractional pixels, rounded to an
1907 * integer value. See @FT_FaceRec for the details.
1910 * The scaling values, if relevant, are determined first during a size
1911 * changing operation. The remaining fields are then set by the driver.
1912 * For scalable formats, they are usually set to scaled values of the
1913 * corresponding fields in @FT_FaceRec. Some values like ascender or
1914 * descender are rounded for historical reasons; more precise values (for
1915 * outline fonts) can be derived by scaling the corresponding @FT_FaceRec
1916 * values manually, with code similar to the following.
1919 * scaled_ascender = FT_MulFix( face->ascender,
1920 * size_metrics->y_scale );
1923 * Note that due to glyph hinting and the selected rendering mode these
1924 * values are usually not exact; consequently, they must be treated as
1925 * unreliable with an error margin of at least one pixel!
1927 * Indeed, the only way to get the exact metrics is to render _all_
1928 * glyphs. As this would be a definite performance hit, it is up to
1929 * client applications to perform such computations.
1931 * The `FT_Size_Metrics` structure is valid for bitmap fonts also.
1934 * **TrueType fonts with native bytecode hinting**
1936 * All applications that handle TrueType fonts with native hinting must
1937 * be aware that TTFs expect different rounding of vertical font
1938 * dimensions. The application has to cater for this, especially if it
1939 * wants to rely on a TTF's vertical data (for example, to properly align
1940 * box characters vertically).
1942 * Only the application knows _in advance_ that it is going to use native
1943 * hinting for TTFs! FreeType, on the other hand, selects the hinting
1944 * mode not at the time of creating an @FT_Size object but much later,
1945 * namely while calling @FT_Load_Glyph.
1947 * Here is some pseudo code that illustrates a possible solution.
1950 * font_format = FT_Get_Font_Format( face );
1952 * if ( !strcmp( font_format, "TrueType" ) &&
1953 * do_native_bytecode_hinting )
1955 * ascender = ROUND( FT_MulFix( face->ascender,
1956 * size_metrics->y_scale ) );
1957 * descender = ROUND( FT_MulFix( face->descender,
1958 * size_metrics->y_scale ) );
1962 * ascender = size_metrics->ascender;
1963 * descender = size_metrics->descender;
1966 * height = size_metrics->height;
1967 * max_advance = size_metrics->max_advance;
1970 typedef struct FT_Size_Metrics_
1972 FT_UShort x_ppem; /* horizontal pixels per EM */
1973 FT_UShort y_ppem; /* vertical pixels per EM */
1975 FT_Fixed x_scale; /* scaling values used to convert font */
1976 FT_Fixed y_scale; /* units to 26.6 fractional pixels */
1978 FT_Pos ascender; /* ascender in 26.6 frac. pixels */
1979 FT_Pos descender; /* descender in 26.6 frac. pixels */
1980 FT_Pos height; /* text height in 26.6 frac. pixels */
1981 FT_Pos max_advance; /* max horizontal advance, in 26.6 pixels */
1986 /**************************************************************************
1992 * FreeType root size class structure. A size object models a face
1993 * object at a given size.
1997 * Handle to the parent face object.
2000 * A typeless pointer, unused by the FreeType library or any of its
2001 * drivers. It can be used by client applications to link their own
2002 * data to each size object.
2005 * Metrics for this size object. This field is read-only.
2007 typedef struct FT_SizeRec_
2009 FT_Face face; /* parent face object */
2010 FT_Generic generic; /* generic pointer for client uses */
2011 FT_Size_Metrics metrics; /* size metrics */
2012 FT_Size_Internal internal;
2017 /**************************************************************************
2024 /**************************************************************************
2030 * The subglyph structure is an internal object used to describe
2031 * subglyphs (for example, in the case of composites).
2034 * The subglyph implementation is not part of the high-level API, hence
2035 * the forward structure declaration.
2037 * You can however retrieve subglyph information with
2038 * @FT_Get_SubGlyph_Info.
2040 typedef struct FT_SubGlyphRec_* FT_SubGlyph;
2043 /**************************************************************************
2049 * An opaque handle to an `FT_Slot_InternalRec` structure, used to model
2050 * private data of a given @FT_GlyphSlot object.
2052 typedef struct FT_Slot_InternalRec_* FT_Slot_Internal;
2055 /**************************************************************************
2062 /**************************************************************************
2068 * FreeType root glyph slot class structure. A glyph slot is a container
2069 * where individual glyphs can be loaded, be they in outline or bitmap
2074 * A handle to the FreeType library instance this slot belongs to.
2077 * A handle to the parent face object.
2080 * In some cases (like some font tools), several glyph slots per face
2081 * object can be a good thing. As this is rare, the glyph slots are
2082 * listed through a direct, single-linked list using its `next` field.
2085 * [Since 2.10] The glyph index passed as an argument to @FT_Load_Glyph
2086 * while initializing the glyph slot.
2089 * A typeless pointer unused by the FreeType library or any of its
2090 * drivers. It can be used by client applications to link their own
2091 * data to each glyph slot object.
2094 * The metrics of the last loaded glyph in the slot. The returned
2095 * values depend on the last load flags (see the @FT_Load_Glyph API
2096 * function) and can be expressed either in 26.6 fractional pixels or
2099 * Note that even when the glyph image is transformed, the metrics are
2102 * linearHoriAdvance ::
2103 * The advance width of the unhinted glyph. Its value is expressed in
2104 * 16.16 fractional pixels, unless @FT_LOAD_LINEAR_DESIGN is set when
2105 * loading the glyph. This field can be important to perform correct
2106 * WYSIWYG layout. Only relevant for scalable glyphs.
2108 * linearVertAdvance ::
2109 * The advance height of the unhinted glyph. Its value is expressed in
2110 * 16.16 fractional pixels, unless @FT_LOAD_LINEAR_DESIGN is set when
2111 * loading the glyph. This field can be important to perform correct
2112 * WYSIWYG layout. Only relevant for scalable glyphs.
2115 * This shorthand is, depending on @FT_LOAD_IGNORE_TRANSFORM, the
2116 * transformed (hinted) advance width for the glyph, in 26.6 fractional
2117 * pixel format. As specified with @FT_LOAD_VERTICAL_LAYOUT, it uses
2118 * either the `horiAdvance` or the `vertAdvance` value of `metrics`
2122 * This field indicates the format of the image contained in the glyph
2123 * slot. Typically @FT_GLYPH_FORMAT_BITMAP, @FT_GLYPH_FORMAT_OUTLINE,
2124 * or @FT_GLYPH_FORMAT_COMPOSITE, but other values are possible.
2127 * This field is used as a bitmap descriptor. Note that the address
2128 * and content of the bitmap buffer can change between calls of
2129 * @FT_Load_Glyph and a few other functions.
2132 * The bitmap's left bearing expressed in integer pixels.
2135 * The bitmap's top bearing expressed in integer pixels. This is the
2136 * distance from the baseline to the top-most glyph scanline, upwards
2137 * y~coordinates being **positive**.
2140 * The outline descriptor for the current glyph image if its format is
2141 * @FT_GLYPH_FORMAT_OUTLINE. Once a glyph is loaded, `outline` can be
2142 * transformed, distorted, emboldened, etc. However, it must not be
2145 * [Since 2.10.1] If @FT_LOAD_NO_SCALE is set, outline coordinates of
2146 * OpenType variation fonts for a selected instance are internally
2147 * handled as 26.6 fractional font units but returned as (rounded)
2148 * integers, as expected. To get unrounded font units, don't use
2149 * @FT_LOAD_NO_SCALE but load the glyph with @FT_LOAD_NO_HINTING and
2150 * scale it, using the font's `units_per_EM` value as the ppem.
2153 * The number of subglyphs in a composite glyph. This field is only
2154 * valid for the composite glyph format that should normally only be
2155 * loaded with the @FT_LOAD_NO_RECURSE flag.
2158 * An array of subglyph descriptors for composite glyphs. There are
2159 * `num_subglyphs` elements in there. Currently internal to FreeType.
2162 * Certain font drivers can also return the control data for a given
2163 * glyph image (e.g. TrueType bytecode, Type~1 charstrings, etc.).
2164 * This field is a pointer to such data; it is currently internal to
2168 * This is the length in bytes of the control data. Currently internal
2175 * The difference between hinted and unhinted left side bearing while
2176 * auto-hinting is active. Zero otherwise.
2179 * The difference between hinted and unhinted right side bearing while
2180 * auto-hinting is active. Zero otherwise.
2183 * If @FT_Load_Glyph is called with default flags (see @FT_LOAD_DEFAULT)
2184 * the glyph image is loaded in the glyph slot in its native format
2185 * (e.g., an outline glyph for TrueType and Type~1 formats). [Since 2.9]
2186 * The prospective bitmap metrics are calculated according to
2187 * @FT_LOAD_TARGET_XXX and other flags even for the outline glyph, even
2188 * if @FT_LOAD_RENDER is not set.
2190 * This image can later be converted into a bitmap by calling
2191 * @FT_Render_Glyph. This function searches the current renderer for the
2192 * native image's format, then invokes it.
2194 * The renderer is in charge of transforming the native image through the
2195 * slot's face transformation fields, then converting it into a bitmap
2196 * that is returned in `slot->bitmap`.
2198 * Note that `slot->bitmap_left` and `slot->bitmap_top` are also used to
2199 * specify the position of the bitmap relative to the current pen
2200 * position (e.g., coordinates (0,0) on the baseline). Of course,
2201 * `slot->format` is also changed to @FT_GLYPH_FORMAT_BITMAP.
2203 * Here is a small pseudo code fragment that shows how to use `lsb_delta`
2204 * and `rsb_delta` to do fractional positioning of glyphs:
2207 * FT_GlyphSlot slot = face->glyph;
2208 * FT_Pos origin_x = 0;
2212 * <load glyph with `FT_Load_Glyph'>
2214 * FT_Outline_Translate( slot->outline, origin_x & 63, 0 );
2216 * <save glyph image, or render glyph, or ...>
2218 * <compute kern between current and next glyph
2219 * and add it to `origin_x'>
2221 * origin_x += slot->advance.x;
2222 * origin_x += slot->lsb_delta - slot->rsb_delta;
2226 * Here is another small pseudo code fragment that shows how to use
2227 * `lsb_delta` and `rsb_delta` to improve integer positioning of glyphs:
2230 * FT_GlyphSlot slot = face->glyph;
2231 * FT_Pos origin_x = 0;
2232 * FT_Pos prev_rsb_delta = 0;
2236 * <compute kern between current and previous glyph
2237 * and add it to `origin_x'>
2239 * <load glyph with `FT_Load_Glyph'>
2241 * if ( prev_rsb_delta - slot->lsb_delta > 32 )
2243 * else if ( prev_rsb_delta - slot->lsb_delta < -31 )
2246 * prev_rsb_delta = slot->rsb_delta;
2248 * <save glyph image, or render glyph, or ...>
2250 * origin_x += slot->advance.x;
2254 * If you use strong auto-hinting, you **must** apply these delta values!
2255 * Otherwise you will experience far too large inter-glyph spacing at
2256 * small rendering sizes in most cases. Note that it doesn't harm to use
2257 * the above code for other hinting modes also, since the delta values
2260 typedef struct FT_GlyphSlotRec_
2265 FT_UInt glyph_index; /* new in 2.10; was reserved previously */
2268 FT_Glyph_Metrics metrics;
2269 FT_Fixed linearHoriAdvance;
2270 FT_Fixed linearVertAdvance;
2273 FT_Glyph_Format format;
2281 FT_UInt num_subglyphs;
2282 FT_SubGlyph subglyphs;
2292 FT_Slot_Internal internal;
2297 /*************************************************************************/
2298 /*************************************************************************/
2300 /* F U N C T I O N S */
2302 /*************************************************************************/
2303 /*************************************************************************/
2306 /**************************************************************************
2313 /**************************************************************************
2319 * Initialize a new FreeType library object. The set of modules that are
2320 * registered by this function is determined at build time.
2324 * A handle to a new library object.
2327 * FreeType error code. 0~means success.
2330 * In case you want to provide your own memory allocating routines, use
2331 * @FT_New_Library instead, followed by a call to @FT_Add_Default_Modules
2332 * (or a series of calls to @FT_Add_Module) and
2333 * @FT_Set_Default_Properties.
2335 * See the documentation of @FT_Library and @FT_Face for multi-threading
2338 * If you need reference-counting (cf. @FT_Reference_Library), use
2339 * @FT_New_Library and @FT_Done_Library.
2341 * If compilation option `FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES` is
2342 * set, this function reads the `FREETYPE_PROPERTIES` environment
2343 * variable to control driver properties. See section @properties for
2346 FT_EXPORT( FT_Error )
2347 FT_Init_FreeType( FT_Library *alibrary );
2350 /**************************************************************************
2356 * Destroy a given FreeType library object and all of its children,
2357 * including resources, drivers, faces, sizes, etc.
2361 * A handle to the target library object.
2364 * FreeType error code. 0~means success.
2366 FT_EXPORT( FT_Error )
2367 FT_Done_FreeType( FT_Library library );
2370 /**************************************************************************
2377 /**************************************************************************
2383 * A list of bit field constants used within the `flags` field of the
2384 * @FT_Open_Args structure.
2388 * This is a memory-based stream.
2391 * Copy the stream from the `stream` field.
2393 * FT_OPEN_PATHNAME ::
2394 * Create a new input stream from a C~path name.
2397 * Use the `driver` field.
2400 * Use the `num_params` and `params` fields.
2403 * The `FT_OPEN_MEMORY`, `FT_OPEN_STREAM`, and `FT_OPEN_PATHNAME` flags
2404 * are mutually exclusive.
2406 #define FT_OPEN_MEMORY 0x1
2407 #define FT_OPEN_STREAM 0x2
2408 #define FT_OPEN_PATHNAME 0x4
2409 #define FT_OPEN_DRIVER 0x8
2410 #define FT_OPEN_PARAMS 0x10
2413 /* these constants are deprecated; use the corresponding `FT_OPEN_XXX` */
2414 /* values instead */
2415 #define ft_open_memory FT_OPEN_MEMORY
2416 #define ft_open_stream FT_OPEN_STREAM
2417 #define ft_open_pathname FT_OPEN_PATHNAME
2418 #define ft_open_driver FT_OPEN_DRIVER
2419 #define ft_open_params FT_OPEN_PARAMS
2422 /**************************************************************************
2428 * A simple structure to pass more or less generic parameters to
2429 * @FT_Open_Face and @FT_Face_Properties.
2433 * A four-byte identification tag.
2436 * A pointer to the parameter data.
2439 * The ID and function of parameters are driver-specific. See section
2440 * @parameter_tags for more information.
2442 typedef struct FT_Parameter_
2450 /**************************************************************************
2456 * A structure to indicate how to open a new font file or stream. A
2457 * pointer to such a structure can be used as a parameter for the
2458 * functions @FT_Open_Face and @FT_Attach_Stream.
2462 * A set of bit flags indicating how to use the structure.
2465 * The first byte of the file in memory.
2468 * The size in bytes of the file in memory.
2471 * A pointer to an 8-bit file pathname, which must be a C~string (i.e.,
2472 * no null bytes except at the very end). The pointer is not owned by
2476 * A handle to a source stream object.
2479 * This field is exclusively used by @FT_Open_Face; it simply specifies
2480 * the font driver to use for opening the face. If set to `NULL`,
2481 * FreeType tries to load the face with each one of the drivers in its
2485 * The number of extra parameters.
2488 * Extra parameters passed to the font driver when opening a new face.
2491 * The stream type is determined by the contents of `flags`:
2493 * If the @FT_OPEN_MEMORY bit is set, assume that this is a memory file
2494 * of `memory_size` bytes, located at `memory_address`. The data are not
2495 * copied, and the client is responsible for releasing and destroying
2496 * them _after_ the corresponding call to @FT_Done_Face.
2498 * Otherwise, if the @FT_OPEN_STREAM bit is set, assume that a custom
2499 * input stream `stream` is used.
2501 * Otherwise, if the @FT_OPEN_PATHNAME bit is set, assume that this is a
2502 * normal file and use `pathname` to open it.
2504 * If none of the above bits are set or if multiple are set at the same
2505 * time, the flags are invalid and @FT_Open_Face fails.
2507 * If the @FT_OPEN_DRIVER bit is set, @FT_Open_Face only tries to open
2508 * the file with the driver whose handler is in `driver`.
2510 * If the @FT_OPEN_PARAMS bit is set, the parameters given by
2511 * `num_params` and `params` is used. They are ignored otherwise.
2513 * Ideally, both the `pathname` and `params` fields should be tagged as
2514 * 'const'; this is missing for API backward compatibility. In other
2515 * words, applications should treat them as read-only.
2517 typedef struct FT_Open_Args_
2520 const FT_Byte* memory_base;
2521 FT_Long memory_size;
2522 FT_String* pathname;
2526 FT_Parameter* params;
2531 /**************************************************************************
2537 * Call @FT_Open_Face to open a font by its pathname.
2541 * A handle to the library resource.
2545 * A path to the font file.
2548 * See @FT_Open_Face for a detailed description of this parameter.
2552 * A handle to a new face object. If `face_index` is greater than or
2553 * equal to zero, it must be non-`NULL`.
2556 * FreeType error code. 0~means success.
2559 * The `pathname` string should be recognizable as such by a standard
2560 * `fopen` call on your system; in particular, this means that `pathname`
2561 * must not contain null bytes. If that is not sufficient to address all
2562 * file name possibilities (for example, to handle wide character file
2563 * names on Windows in UTF-16 encoding) you might use @FT_Open_Face to
2564 * pass a memory array or a stream object instead.
2566 * Use @FT_Done_Face to destroy the created @FT_Face object (along with
2567 * its slot and sizes).
2569 FT_EXPORT( FT_Error )
2570 FT_New_Face( FT_Library library,
2571 const char* filepathname,
2576 /**************************************************************************
2579 * FT_New_Memory_Face
2582 * Call @FT_Open_Face to open a font that has been loaded into memory.
2586 * A handle to the library resource.
2590 * A pointer to the beginning of the font data.
2593 * The size of the memory chunk used by the font data.
2596 * See @FT_Open_Face for a detailed description of this parameter.
2600 * A handle to a new face object. If `face_index` is greater than or
2601 * equal to zero, it must be non-`NULL`.
2604 * FreeType error code. 0~means success.
2607 * You must not deallocate the memory before calling @FT_Done_Face.
2609 FT_EXPORT( FT_Error )
2610 FT_New_Memory_Face( FT_Library library,
2611 const FT_Byte* file_base,
2617 /**************************************************************************
2623 * Create a face object from a given resource described by @FT_Open_Args.
2627 * A handle to the library resource.
2631 * A pointer to an `FT_Open_Args` structure that must be filled by the
2635 * This field holds two different values. Bits 0-15 are the index of
2636 * the face in the font file (starting with value~0). Set it to~0 if
2637 * there is only one face in the font file.
2639 * [Since 2.6.1] Bits 16-30 are relevant to GX and OpenType variation
2640 * fonts only, specifying the named instance index for the current face
2641 * index (starting with value~1; value~0 makes FreeType ignore named
2642 * instances). For non-variation fonts, bits 16-30 are ignored.
2643 * Assuming that you want to access the third named instance in face~4,
2644 * `face_index` should be set to 0x00030004. If you want to access
2645 * face~4 without variation handling, simply set `face_index` to
2648 * `FT_Open_Face` and its siblings can be used to quickly check whether
2649 * the font format of a given font resource is supported by FreeType.
2650 * In general, if the `face_index` argument is negative, the function's
2651 * return value is~0 if the font format is recognized, or non-zero
2652 * otherwise. The function allocates a more or less empty face handle
2653 * in `*aface` (if `aface` isn't `NULL`); the only two useful fields in
2654 * this special case are `face->num_faces` and `face->style_flags`.
2655 * For any negative value of `face_index`, `face->num_faces` gives the
2656 * number of faces within the font file. For the negative value
2657 * '-(N+1)' (with 'N' a non-negative 16-bit value), bits 16-30 in
2658 * `face->style_flags` give the number of named instances in face 'N'
2659 * if we have a variation font (or zero otherwise). After examination,
2660 * the returned @FT_Face structure should be deallocated with a call to
2665 * A handle to a new face object. If `face_index` is greater than or
2666 * equal to zero, it must be non-`NULL`.
2669 * FreeType error code. 0~means success.
2672 * Unlike FreeType 1.x, this function automatically creates a glyph slot
2673 * for the face object that can be accessed directly through
2676 * Each new face object created with this function also owns a default
2677 * @FT_Size object, accessible as `face->size`.
2679 * One @FT_Library instance can have multiple face objects, that is,
2680 * @FT_Open_Face and its siblings can be called multiple times using the
2681 * same `library` argument.
2683 * See the discussion of reference counters in the description of
2684 * @FT_Reference_Face.
2686 * If `FT_OPEN_STREAM` is set in `args->flags`, the stream in
2687 * `args->stream` is automatically closed before this function returns
2688 * any error (including `FT_Err_Invalid_Argument`).
2691 * To loop over all faces, use code similar to the following snippet
2692 * (omitting the error handling).
2697 * FT_Long i, num_faces;
2700 * error = FT_Open_Face( library, args, -1, &face );
2701 * if ( error ) { ... }
2703 * num_faces = face->num_faces;
2704 * FT_Done_Face( face );
2706 * for ( i = 0; i < num_faces; i++ )
2709 * error = FT_Open_Face( library, args, i, &face );
2711 * FT_Done_Face( face );
2716 * To loop over all valid values for `face_index`, use something similar
2717 * to the following snippet, again without error handling. The code
2718 * accesses all faces immediately (thus only a single call of
2719 * `FT_Open_Face` within the do-loop), with and without named instances.
2725 * FT_Long num_faces = 0;
2726 * FT_Long num_instances = 0;
2728 * FT_Long face_idx = 0;
2729 * FT_Long instance_idx = 0;
2734 * FT_Long id = ( instance_idx << 16 ) + face_idx;
2737 * error = FT_Open_Face( library, args, id, &face );
2738 * if ( error ) { ... }
2740 * num_faces = face->num_faces;
2741 * num_instances = face->style_flags >> 16;
2745 * FT_Done_Face( face );
2747 * if ( instance_idx < num_instances )
2755 * } while ( face_idx < num_faces )
2758 FT_EXPORT( FT_Error )
2759 FT_Open_Face( FT_Library library,
2760 const FT_Open_Args* args,
2765 /**************************************************************************
2771 * Call @FT_Attach_Stream to attach a file.
2775 * The target face object.
2782 * FreeType error code. 0~means success.
2784 FT_EXPORT( FT_Error )
2785 FT_Attach_File( FT_Face face,
2786 const char* filepathname );
2789 /**************************************************************************
2795 * 'Attach' data to a face object. Normally, this is used to read
2796 * additional information for the face object. For example, you can
2797 * attach an AFM file that comes with a Type~1 font to get the kerning
2798 * values and other metrics.
2802 * The target face object.
2806 * A pointer to @FT_Open_Args that must be filled by the caller.
2809 * FreeType error code. 0~means success.
2812 * The meaning of the 'attach' (i.e., what really happens when the new
2813 * file is read) is not fixed by FreeType itself. It really depends on
2814 * the font format (and thus the font driver).
2816 * Client applications are expected to know what they are doing when
2817 * invoking this function. Most drivers simply do not implement file or
2818 * stream attachments.
2820 FT_EXPORT( FT_Error )
2821 FT_Attach_Stream( FT_Face face,
2822 const FT_Open_Args* parameters );
2825 /**************************************************************************
2831 * A counter gets initialized to~1 at the time an @FT_Face structure is
2832 * created. This function increments the counter. @FT_Done_Face then
2833 * only destroys a face if the counter is~1, otherwise it simply
2834 * decrements the counter.
2836 * This function helps in managing life-cycles of structures that
2837 * reference @FT_Face objects.
2841 * A handle to a target face object.
2844 * FreeType error code. 0~means success.
2850 FT_EXPORT( FT_Error )
2851 FT_Reference_Face( FT_Face face );
2854 /**************************************************************************
2860 * Discard a given face object, as well as all of its child slots and
2865 * A handle to a target face object.
2868 * FreeType error code. 0~means success.
2871 * See the discussion of reference counters in the description of
2872 * @FT_Reference_Face.
2874 FT_EXPORT( FT_Error )
2875 FT_Done_Face( FT_Face face );
2878 /**************************************************************************
2881 * sizing_and_scaling
2885 /**************************************************************************
2891 * Select a bitmap strike. To be more precise, this function sets the
2892 * scaling factors of the active @FT_Size object in a face so that
2893 * bitmaps from this particular strike are taken by @FT_Load_Glyph and
2898 * A handle to a target face object.
2902 * The index of the bitmap strike in the `available_sizes` field of
2903 * @FT_FaceRec structure.
2906 * FreeType error code. 0~means success.
2909 * For bitmaps embedded in outline fonts it is common that only a subset
2910 * of the available glyphs at a given ppem value is available. FreeType
2911 * silently uses outlines if there is no bitmap for a given glyph index.
2913 * For GX and OpenType variation fonts, a bitmap strike makes sense only
2914 * if the default instance is active (that is, no glyph variation takes
2915 * place); otherwise, FreeType simply ignores bitmap strikes. The same
2916 * is true for all named instances that are different from the default
2919 * Don't use this function if you are using the FreeType cache API.
2921 FT_EXPORT( FT_Error )
2922 FT_Select_Size( FT_Face face,
2923 FT_Int strike_index );
2926 /**************************************************************************
2929 * FT_Size_Request_Type
2932 * An enumeration type that lists the supported size request types, i.e.,
2933 * what input size (in font units) maps to the requested output size (in
2934 * pixels, as computed from the arguments of @FT_Size_Request).
2937 * FT_SIZE_REQUEST_TYPE_NOMINAL ::
2938 * The nominal size. The `units_per_EM` field of @FT_FaceRec is used
2939 * to determine both scaling values.
2941 * This is the standard scaling found in most applications. In
2942 * particular, use this size request type for TrueType fonts if they
2943 * provide optical scaling or something similar. Note, however, that
2944 * `units_per_EM` is a rather abstract value which bears no relation to
2945 * the actual size of the glyphs in a font.
2947 * FT_SIZE_REQUEST_TYPE_REAL_DIM ::
2948 * The real dimension. The sum of the `ascender` and (minus of) the
2949 * `descender` fields of @FT_FaceRec is used to determine both scaling
2952 * FT_SIZE_REQUEST_TYPE_BBOX ::
2953 * The font bounding box. The width and height of the `bbox` field of
2954 * @FT_FaceRec are used to determine the horizontal and vertical
2955 * scaling value, respectively.
2957 * FT_SIZE_REQUEST_TYPE_CELL ::
2958 * The `max_advance_width` field of @FT_FaceRec is used to determine
2959 * the horizontal scaling value; the vertical scaling value is
2960 * determined the same way as @FT_SIZE_REQUEST_TYPE_REAL_DIM does.
2961 * Finally, both scaling values are set to the smaller one. This type
2962 * is useful if you want to specify the font size for, say, a window of
2963 * a given dimension and 80x24 cells.
2965 * FT_SIZE_REQUEST_TYPE_SCALES ::
2966 * Specify the scaling values directly.
2969 * The above descriptions only apply to scalable formats. For bitmap
2970 * formats, the behaviour is up to the driver.
2972 * See the note section of @FT_Size_Metrics if you wonder how size
2973 * requesting relates to scaling values.
2975 typedef enum FT_Size_Request_Type_
2977 FT_SIZE_REQUEST_TYPE_NOMINAL,
2978 FT_SIZE_REQUEST_TYPE_REAL_DIM,
2979 FT_SIZE_REQUEST_TYPE_BBOX,
2980 FT_SIZE_REQUEST_TYPE_CELL,
2981 FT_SIZE_REQUEST_TYPE_SCALES,
2983 FT_SIZE_REQUEST_TYPE_MAX
2985 } FT_Size_Request_Type;
2988 /**************************************************************************
2991 * FT_Size_RequestRec
2994 * A structure to model a size request.
2998 * See @FT_Size_Request_Type.
3001 * The desired width, given as a 26.6 fractional point value (with 72pt
3005 * The desired height, given as a 26.6 fractional point value (with
3009 * The horizontal resolution (dpi, i.e., pixels per inch). If set to
3010 * zero, `width` is treated as a 26.6 fractional **pixel** value, which
3011 * gets internally rounded to an integer.
3014 * The vertical resolution (dpi, i.e., pixels per inch). If set to
3015 * zero, `height` is treated as a 26.6 fractional **pixel** value,
3016 * which gets internally rounded to an integer.
3019 * If `width` is zero, the horizontal scaling value is set equal to the
3020 * vertical scaling value, and vice versa.
3022 * If `type` is `FT_SIZE_REQUEST_TYPE_SCALES`, `width` and `height` are
3023 * interpreted directly as 16.16 fractional scaling values, without any
3024 * further modification, and both `horiResolution` and `vertResolution`
3027 typedef struct FT_Size_RequestRec_
3029 FT_Size_Request_Type type;
3032 FT_UInt horiResolution;
3033 FT_UInt vertResolution;
3035 } FT_Size_RequestRec;
3038 /**************************************************************************
3044 * A handle to a size request structure.
3046 typedef struct FT_Size_RequestRec_ *FT_Size_Request;
3049 /**************************************************************************
3055 * Resize the scale of the active @FT_Size object in a face.
3059 * A handle to a target face object.
3063 * A pointer to a @FT_Size_RequestRec.
3066 * FreeType error code. 0~means success.
3069 * Although drivers may select the bitmap strike matching the request,
3070 * you should not rely on this if you intend to select a particular
3071 * bitmap strike. Use @FT_Select_Size instead in that case.
3073 * The relation between the requested size and the resulting glyph size
3074 * is dependent entirely on how the size is defined in the source face.
3075 * The font designer chooses the final size of each glyph relative to
3076 * this size. For more information refer to
3077 * 'https://www.freetype.org/freetype2/docs/glyphs/glyphs-2.html'.
3079 * Contrary to @FT_Set_Char_Size, this function doesn't have special code
3080 * to normalize zero-valued widths, heights, or resolutions, which are
3081 * treated as @FT_LOAD_NO_SCALE.
3083 * Don't use this function if you are using the FreeType cache API.
3085 FT_EXPORT( FT_Error )
3086 FT_Request_Size( FT_Face face,
3087 FT_Size_Request req );
3090 /**************************************************************************
3096 * Call @FT_Request_Size to request the nominal size (in points).
3100 * A handle to a target face object.
3104 * The nominal width, in 26.6 fractional points.
3107 * The nominal height, in 26.6 fractional points.
3109 * horz_resolution ::
3110 * The horizontal resolution in dpi.
3112 * vert_resolution ::
3113 * The vertical resolution in dpi.
3116 * FreeType error code. 0~means success.
3119 * While this function allows fractional points as input values, the
3120 * resulting ppem value for the given resolution is always rounded to the
3123 * If either the character width or height is zero, it is set equal to
3126 * If either the horizontal or vertical resolution is zero, it is set
3127 * equal to the other value.
3129 * A character width or height smaller than 1pt is set to 1pt; if both
3130 * resolution values are zero, they are set to 72dpi.
3132 * Don't use this function if you are using the FreeType cache API.
3134 FT_EXPORT( FT_Error )
3135 FT_Set_Char_Size( FT_Face face,
3136 FT_F26Dot6 char_width,
3137 FT_F26Dot6 char_height,
3138 FT_UInt horz_resolution,
3139 FT_UInt vert_resolution );
3142 /**************************************************************************
3145 * FT_Set_Pixel_Sizes
3148 * Call @FT_Request_Size to request the nominal size (in pixels).
3152 * A handle to the target face object.
3156 * The nominal width, in pixels.
3159 * The nominal height, in pixels.
3162 * FreeType error code. 0~means success.
3165 * You should not rely on the resulting glyphs matching or being
3166 * constrained to this pixel size. Refer to @FT_Request_Size to
3167 * understand how requested sizes relate to actual sizes.
3169 * Don't use this function if you are using the FreeType cache API.
3171 FT_EXPORT( FT_Error )
3172 FT_Set_Pixel_Sizes( FT_Face face,
3173 FT_UInt pixel_width,
3174 FT_UInt pixel_height );
3177 /**************************************************************************
3184 /**************************************************************************
3190 * Load a glyph into the glyph slot of a face object.
3194 * A handle to the target face object where the glyph is loaded.
3198 * The index of the glyph in the font file. For CID-keyed fonts
3199 * (either in PS or in CFF format) this argument specifies the CID
3203 * A flag indicating what to load for this glyph. The @FT_LOAD_XXX
3204 * flags can be used to control the glyph loading process (e.g.,
3205 * whether the outline should be scaled, whether to load bitmaps or
3206 * not, whether to hint the outline, etc).
3209 * FreeType error code. 0~means success.
3212 * For proper scaling and hinting, the active @FT_Size object owned by
3213 * the face has to be meaningfully initialized by calling
3214 * @FT_Set_Char_Size before this function, for example. The loaded
3215 * glyph may be transformed. See @FT_Set_Transform for the details.
3217 * For subsetted CID-keyed fonts, `FT_Err_Invalid_Argument` is returned
3218 * for invalid CID values (that is, for CID values that don't have a
3219 * corresponding glyph in the font). See the discussion of the
3220 * @FT_FACE_FLAG_CID_KEYED flag for more details.
3222 * If you receive `FT_Err_Glyph_Too_Big`, try getting the glyph outline
3223 * at EM size, then scale it manually and fill it as a graphics
3226 FT_EXPORT( FT_Error )
3227 FT_Load_Glyph( FT_Face face,
3228 FT_UInt glyph_index,
3229 FT_Int32 load_flags );
3232 /**************************************************************************
3239 /**************************************************************************
3245 * Load a glyph into the glyph slot of a face object, accessed by its
3250 * A handle to a target face object where the glyph is loaded.
3254 * The glyph's character code, according to the current charmap used in
3258 * A flag indicating what to load for this glyph. The @FT_LOAD_XXX
3259 * constants can be used to control the glyph loading process (e.g.,
3260 * whether the outline should be scaled, whether to load bitmaps or
3261 * not, whether to hint the outline, etc).
3264 * FreeType error code. 0~means success.
3267 * This function simply calls @FT_Get_Char_Index and @FT_Load_Glyph.
3269 * Many fonts contain glyphs that can't be loaded by this function since
3270 * its glyph indices are not listed in any of the font's charmaps.
3272 * If no active cmap is set up (i.e., `face->charmap` is zero), the call
3273 * to @FT_Get_Char_Index is omitted, and the function behaves identically
3274 * to @FT_Load_Glyph.
3276 FT_EXPORT( FT_Error )
3277 FT_Load_Char( FT_Face face,
3279 FT_Int32 load_flags );
3282 /**************************************************************************
3289 /**************************************************************************
3295 * A list of bit field constants for @FT_Load_Glyph to indicate what kind
3296 * of operations to perform during glyph loading.
3299 * FT_LOAD_DEFAULT ::
3300 * Corresponding to~0, this value is used as the default glyph load
3301 * operation. In this case, the following happens:
3303 * 1. FreeType looks for a bitmap for the glyph corresponding to the
3304 * face's current size. If one is found, the function returns. The
3305 * bitmap data can be accessed from the glyph slot (see note below).
3307 * 2. If no embedded bitmap is searched for or found, FreeType looks
3308 * for a scalable outline. If one is found, it is loaded from the font
3309 * file, scaled to device pixels, then 'hinted' to the pixel grid in
3310 * order to optimize it. The outline data can be accessed from the
3311 * glyph slot (see note below).
3313 * Note that by default the glyph loader doesn't render outlines into
3314 * bitmaps. The following flags are used to modify this default
3315 * behaviour to more specific and useful cases.
3317 * FT_LOAD_NO_SCALE ::
3318 * Don't scale the loaded outline glyph but keep it in font units.
3319 * This flag is also assumed if @FT_Size owned by the face was not
3320 * properly initialized.
3322 * This flag implies @FT_LOAD_NO_HINTING and @FT_LOAD_NO_BITMAP, and
3323 * unsets @FT_LOAD_RENDER.
3325 * If the font is 'tricky' (see @FT_FACE_FLAG_TRICKY for more), using
3326 * `FT_LOAD_NO_SCALE` usually yields meaningless outlines because the
3327 * subglyphs must be scaled and positioned with hinting instructions.
3328 * This can be solved by loading the font without `FT_LOAD_NO_SCALE`
3329 * and setting the character size to `font->units_per_EM`.
3331 * FT_LOAD_NO_HINTING ::
3332 * Disable hinting. This generally generates 'blurrier' bitmap glyphs
3333 * when the glyphs are rendered in any of the anti-aliased modes. See
3334 * also the note below.
3336 * This flag is implied by @FT_LOAD_NO_SCALE.
3339 * Call @FT_Render_Glyph after the glyph is loaded. By default, the
3340 * glyph is rendered in @FT_RENDER_MODE_NORMAL mode. This can be
3341 * overridden by @FT_LOAD_TARGET_XXX or @FT_LOAD_MONOCHROME.
3343 * This flag is unset by @FT_LOAD_NO_SCALE.
3345 * FT_LOAD_NO_BITMAP ::
3346 * Ignore bitmap strikes when loading. Bitmap-only fonts ignore this
3349 * @FT_LOAD_NO_SCALE always sets this flag.
3351 * FT_LOAD_SBITS_ONLY ::
3352 * [Since 2.12] This is the opposite of @FT_LOAD_NO_BITMAP, more or
3353 * less: @FT_Load_Glyph returns `FT_Err_Invalid_Argument` if the face
3354 * contains a bitmap strike for the given size (or the strike selected
3355 * by @FT_Select_Size) but there is no glyph in the strike.
3357 * Note that this load flag was part of FreeType since version 2.0.6
3358 * but previously tagged as internal.
3360 * FT_LOAD_VERTICAL_LAYOUT ::
3361 * Load the glyph for vertical text layout. In particular, the
3362 * `advance` value in the @FT_GlyphSlotRec structure is set to the
3363 * `vertAdvance` value of the `metrics` field.
3365 * In case @FT_HAS_VERTICAL doesn't return true, you shouldn't use this
3366 * flag currently. Reason is that in this case vertical metrics get
3367 * synthesized, and those values are not always consistent across
3368 * various font formats.
3370 * FT_LOAD_FORCE_AUTOHINT ::
3371 * Prefer the auto-hinter over the font's native hinter. See also the
3374 * FT_LOAD_PEDANTIC ::
3375 * Make the font driver perform pedantic verifications during glyph
3376 * loading and hinting. This is mostly used to detect broken glyphs in
3377 * fonts. By default, FreeType tries to handle broken fonts also.
3379 * In particular, errors from the TrueType bytecode engine are not
3380 * passed to the application if this flag is not set; this might result
3381 * in partially hinted or distorted glyphs in case a glyph's bytecode
3384 * FT_LOAD_NO_RECURSE ::
3385 * Don't load composite glyphs recursively. Instead, the font driver
3386 * fills the `num_subglyph` and `subglyphs` values of the glyph slot;
3387 * it also sets `glyph->format` to @FT_GLYPH_FORMAT_COMPOSITE. The
3388 * description of subglyphs can then be accessed with
3389 * @FT_Get_SubGlyph_Info.
3391 * Don't use this flag for retrieving metrics information since some
3392 * font drivers only return rudimentary data.
3394 * This flag implies @FT_LOAD_NO_SCALE and @FT_LOAD_IGNORE_TRANSFORM.
3396 * FT_LOAD_IGNORE_TRANSFORM ::
3397 * Ignore the transform matrix set by @FT_Set_Transform.
3399 * FT_LOAD_MONOCHROME ::
3400 * This flag is used with @FT_LOAD_RENDER to indicate that you want to
3401 * render an outline glyph to a 1-bit monochrome bitmap glyph, with
3402 * 8~pixels packed into each byte of the bitmap data.
3404 * Note that this has no effect on the hinting algorithm used. You
3405 * should rather use @FT_LOAD_TARGET_MONO so that the
3406 * monochrome-optimized hinting algorithm is used.
3408 * FT_LOAD_LINEAR_DESIGN ::
3409 * Keep `linearHoriAdvance` and `linearVertAdvance` fields of
3410 * @FT_GlyphSlotRec in font units. See @FT_GlyphSlotRec for details.
3412 * FT_LOAD_NO_AUTOHINT ::
3413 * Disable the auto-hinter. See also the note below.
3416 * Load colored glyphs. FreeType searches in the following order;
3417 * there are slight differences depending on the font format.
3419 * [Since 2.5] Load embedded color bitmap images (provided
3420 * @FT_LOAD_NO_BITMAP is not set). The resulting color bitmaps, if
3421 * available, have the @FT_PIXEL_MODE_BGRA format, with pre-multiplied
3422 * color channels. If the flag is not set and color bitmaps are found,
3423 * they are converted to 256-level gray bitmaps, using the
3424 * @FT_PIXEL_MODE_GRAY format.
3426 * [Since 2.12] If the glyph index maps to an entry in the face's
3427 * 'SVG~' table, load the associated SVG document from this table and
3428 * set the `format` field of @FT_GlyphSlotRec to @FT_GLYPH_FORMAT_SVG
3429 * ([since 2.13.1] provided @FT_LOAD_NO_SVG is not set). Note that
3430 * FreeType itself can't render SVG documents; however, the library
3431 * provides hooks to seamlessly integrate an external renderer. See
3432 * sections @ot_svg_driver and @svg_fonts for more.
3434 * [Since 2.10, experimental] If the glyph index maps to an entry in
3435 * the face's 'COLR' table with a 'CPAL' palette table (as defined in
3436 * the OpenType specification), make @FT_Render_Glyph provide a default
3437 * blending of the color glyph layers associated with the glyph index,
3438 * using the same bitmap format as embedded color bitmap images. This
3439 * is mainly for convenience and works only for glyphs in 'COLR' v0
3440 * tables (or glyphs in 'COLR' v1 tables that exclusively use v0
3441 * features). For full control of color layers use
3442 * @FT_Get_Color_Glyph_Layer and FreeType's color functions like
3443 * @FT_Palette_Select instead of setting @FT_LOAD_COLOR for rendering
3444 * so that the client application can handle blending by itself.
3447 * [Since 2.13.1] Ignore SVG glyph data when loading.
3449 * FT_LOAD_COMPUTE_METRICS ::
3450 * [Since 2.6.1] Compute glyph metrics from the glyph data, without the
3451 * use of bundled metrics tables (for example, the 'hdmx' table in
3452 * TrueType fonts). This flag is mainly used by font validating or
3453 * font editing applications, which need to ignore, verify, or edit
3456 * Currently, this flag is only implemented for TrueType fonts.
3458 * FT_LOAD_BITMAP_METRICS_ONLY ::
3459 * [Since 2.7.1] Request loading of the metrics and bitmap image
3460 * information of a (possibly embedded) bitmap glyph without allocating
3461 * or copying the bitmap image data itself. No effect if the target
3462 * glyph is not a bitmap image.
3464 * This flag unsets @FT_LOAD_RENDER.
3466 * FT_LOAD_CROP_BITMAP ::
3467 * Ignored. Deprecated.
3469 * FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ::
3470 * Ignored. Deprecated.
3473 * By default, hinting is enabled and the font's native hinter (see
3474 * @FT_FACE_FLAG_HINTER) is preferred over the auto-hinter. You can
3475 * disable hinting by setting @FT_LOAD_NO_HINTING or change the
3476 * precedence by setting @FT_LOAD_FORCE_AUTOHINT. You can also set
3477 * @FT_LOAD_NO_AUTOHINT in case you don't want the auto-hinter to be used
3480 * See the description of @FT_FACE_FLAG_TRICKY for a special exception
3481 * (affecting only a handful of Asian fonts).
3483 * Besides deciding which hinter to use, you can also decide which
3484 * hinting algorithm to use. See @FT_LOAD_TARGET_XXX for details.
3486 * Note that the auto-hinter needs a valid Unicode cmap (either a native
3487 * one or synthesized by FreeType) for producing correct results. If a
3488 * font provides an incorrect mapping (for example, assigning the
3489 * character code U+005A, LATIN CAPITAL LETTER~Z, to a glyph depicting a
3490 * mathematical integral sign), the auto-hinter might produce useless
3494 #define FT_LOAD_DEFAULT 0x0
3495 #define FT_LOAD_NO_SCALE ( 1L << 0 )
3496 #define FT_LOAD_NO_HINTING ( 1L << 1 )
3497 #define FT_LOAD_RENDER ( 1L << 2 )
3498 #define FT_LOAD_NO_BITMAP ( 1L << 3 )
3499 #define FT_LOAD_VERTICAL_LAYOUT ( 1L << 4 )
3500 #define FT_LOAD_FORCE_AUTOHINT ( 1L << 5 )
3501 #define FT_LOAD_CROP_BITMAP ( 1L << 6 )
3502 #define FT_LOAD_PEDANTIC ( 1L << 7 )
3503 #define FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ( 1L << 9 )
3504 #define FT_LOAD_NO_RECURSE ( 1L << 10 )
3505 #define FT_LOAD_IGNORE_TRANSFORM ( 1L << 11 )
3506 #define FT_LOAD_MONOCHROME ( 1L << 12 )
3507 #define FT_LOAD_LINEAR_DESIGN ( 1L << 13 )
3508 #define FT_LOAD_SBITS_ONLY ( 1L << 14 )
3509 #define FT_LOAD_NO_AUTOHINT ( 1L << 15 )
3510 /* Bits 16-19 are used by `FT_LOAD_TARGET_` */
3511 #define FT_LOAD_COLOR ( 1L << 20 )
3512 #define FT_LOAD_COMPUTE_METRICS ( 1L << 21 )
3513 #define FT_LOAD_BITMAP_METRICS_ONLY ( 1L << 22 )
3514 #define FT_LOAD_NO_SVG ( 1L << 24 )
3518 /* used internally only by certain font drivers */
3519 #define FT_LOAD_ADVANCE_ONLY ( 1L << 8 )
3520 #define FT_LOAD_SVG_ONLY ( 1L << 23 )
3523 /**************************************************************************
3526 * FT_LOAD_TARGET_XXX
3529 * A list of values to select a specific hinting algorithm for the
3530 * hinter. You should OR one of these values to your `load_flags` when
3531 * calling @FT_Load_Glyph.
3533 * Note that a font's native hinters may ignore the hinting algorithm you
3534 * have specified (e.g., the TrueType bytecode interpreter). You can set
3535 * @FT_LOAD_FORCE_AUTOHINT to ensure that the auto-hinter is used.
3538 * FT_LOAD_TARGET_NORMAL ::
3539 * The default hinting algorithm, optimized for standard gray-level
3540 * rendering. For monochrome output, use @FT_LOAD_TARGET_MONO instead.
3542 * FT_LOAD_TARGET_LIGHT ::
3543 * A lighter hinting algorithm for gray-level modes. Many generated
3544 * glyphs are fuzzier but better resemble their original shape. This
3545 * is achieved by snapping glyphs to the pixel grid only vertically
3546 * (Y-axis), as is done by FreeType's new CFF engine or Microsoft's
3547 * ClearType font renderer. This preserves inter-glyph spacing in
3548 * horizontal text. The snapping is done either by the native font
3549 * driver, if the driver itself and the font support it, or by the
3552 * Advance widths are rounded to integer values; however, using the
3553 * `lsb_delta` and `rsb_delta` fields of @FT_GlyphSlotRec, it is
3554 * possible to get fractional advance widths for subpixel positioning
3555 * (which is recommended to use).
3557 * If configuration option `AF_CONFIG_OPTION_TT_SIZE_METRICS` is
3558 * active, TrueType-like metrics are used to make this mode behave
3559 * similarly as in unpatched FreeType versions between 2.4.6 and 2.7.1
3562 * FT_LOAD_TARGET_MONO ::
3563 * Strong hinting algorithm that should only be used for monochrome
3564 * output. The result is probably unpleasant if the glyph is rendered
3565 * in non-monochrome modes.
3567 * Note that for outline fonts only the TrueType font driver has proper
3568 * monochrome hinting support, provided the TTFs contain hints for B/W
3569 * rendering (which most fonts no longer provide). If these conditions
3570 * are not met it is very likely that you get ugly results at smaller
3573 * FT_LOAD_TARGET_LCD ::
3574 * A variant of @FT_LOAD_TARGET_LIGHT optimized for horizontally
3575 * decimated LCD displays.
3577 * FT_LOAD_TARGET_LCD_V ::
3578 * A variant of @FT_LOAD_TARGET_NORMAL optimized for vertically
3579 * decimated LCD displays.
3582 * You should use only _one_ of the `FT_LOAD_TARGET_XXX` values in your
3583 * `load_flags`. They can't be ORed.
3585 * If @FT_LOAD_RENDER is also set, the glyph is rendered in the
3586 * corresponding mode (i.e., the mode that matches the used algorithm
3587 * best). An exception is `FT_LOAD_TARGET_MONO` since it implies
3588 * @FT_LOAD_MONOCHROME.
3590 * You can use a hinting algorithm that doesn't correspond to the same
3591 * rendering mode. As an example, it is possible to use the 'light'
3592 * hinting algorithm and have the results rendered in horizontal LCD
3593 * pixel mode, with code like
3596 * FT_Load_Glyph( face, glyph_index,
3597 * load_flags | FT_LOAD_TARGET_LIGHT );
3599 * FT_Render_Glyph( face->glyph, FT_RENDER_MODE_LCD );
3602 * In general, you should stick with one rendering mode. For example,
3603 * switching between @FT_LOAD_TARGET_NORMAL and @FT_LOAD_TARGET_MONO
3604 * enforces a lot of recomputation for TrueType fonts, which is slow.
3605 * Another reason is caching: Selecting a different mode usually causes
3606 * changes in both the outlines and the rasterized bitmaps; it is thus
3607 * necessary to empty the cache after a mode switch to avoid false hits.
3610 #define FT_LOAD_TARGET_( x ) ( FT_STATIC_CAST( FT_Int32, (x) & 15 ) << 16 )
3612 #define FT_LOAD_TARGET_NORMAL FT_LOAD_TARGET_( FT_RENDER_MODE_NORMAL )
3613 #define FT_LOAD_TARGET_LIGHT FT_LOAD_TARGET_( FT_RENDER_MODE_LIGHT )
3614 #define FT_LOAD_TARGET_MONO FT_LOAD_TARGET_( FT_RENDER_MODE_MONO )
3615 #define FT_LOAD_TARGET_LCD FT_LOAD_TARGET_( FT_RENDER_MODE_LCD )
3616 #define FT_LOAD_TARGET_LCD_V FT_LOAD_TARGET_( FT_RENDER_MODE_LCD_V )
3619 /**************************************************************************
3622 * FT_LOAD_TARGET_MODE
3625 * Return the @FT_Render_Mode corresponding to a given
3626 * @FT_LOAD_TARGET_XXX value.
3629 #define FT_LOAD_TARGET_MODE( x ) \
3630 FT_STATIC_CAST( FT_Render_Mode, ( (x) >> 16 ) & 15 )
3633 /**************************************************************************
3636 * sizing_and_scaling
3640 /**************************************************************************
3646 * Set the transformation that is applied to glyph images when they are
3647 * loaded into a glyph slot through @FT_Load_Glyph.
3651 * A handle to the source face object.
3655 * A pointer to the transformation's 2x2 matrix. Use `NULL` for the
3658 * A pointer to the translation vector. Use `NULL` for the null
3662 * This function is provided as a convenience, but keep in mind that
3663 * @FT_Matrix coefficients are only 16.16 fixed-point values, which can
3664 * limit the accuracy of the results. Using floating-point computations
3665 * to perform the transform directly in client code instead will always
3666 * yield better numbers.
3668 * The transformation is only applied to scalable image formats after the
3669 * glyph has been loaded. It means that hinting is unaltered by the
3670 * transformation and is performed on the character size given in the
3671 * last call to @FT_Set_Char_Size or @FT_Set_Pixel_Sizes.
3673 * Note that this also transforms the `face.glyph.advance` field, but
3674 * **not** the values in `face.glyph.metrics`.
3677 FT_Set_Transform( FT_Face face,
3682 /**************************************************************************
3688 * Return the transformation that is applied to glyph images when they
3689 * are loaded into a glyph slot through @FT_Load_Glyph. See
3690 * @FT_Set_Transform for more details.
3694 * A handle to the source face object.
3698 * A pointer to a transformation's 2x2 matrix. Set this to NULL if you
3699 * are not interested in the value.
3702 * A pointer to a translation vector. Set this to NULL if you are not
3703 * interested in the value.
3710 FT_Get_Transform( FT_Face face,
3715 /**************************************************************************
3722 /**************************************************************************
3728 * Render modes supported by FreeType~2. Each mode corresponds to a
3729 * specific type of scanline conversion performed on the outline.
3731 * For bitmap fonts and embedded bitmaps the `bitmap->pixel_mode` field
3732 * in the @FT_GlyphSlotRec structure gives the format of the returned
3735 * All modes except @FT_RENDER_MODE_MONO use 256 levels of opacity,
3736 * indicating pixel coverage. Use linear alpha blending and gamma
3737 * correction to correctly render non-monochrome glyph bitmaps onto a
3738 * surface; see @FT_Render_Glyph.
3740 * The @FT_RENDER_MODE_SDF is a special render mode that uses up to 256
3741 * distance values, indicating the signed distance from the grid position
3742 * to the nearest outline.
3745 * FT_RENDER_MODE_NORMAL ::
3746 * Default render mode; it corresponds to 8-bit anti-aliased bitmaps.
3748 * FT_RENDER_MODE_LIGHT ::
3749 * This is equivalent to @FT_RENDER_MODE_NORMAL. It is only defined as
3750 * a separate value because render modes are also used indirectly to
3751 * define hinting algorithm selectors. See @FT_LOAD_TARGET_XXX for
3754 * FT_RENDER_MODE_MONO ::
3755 * This mode corresponds to 1-bit bitmaps (with 2~levels of opacity).
3757 * FT_RENDER_MODE_LCD ::
3758 * This mode corresponds to horizontal RGB and BGR subpixel displays
3759 * like LCD screens. It produces 8-bit bitmaps that are 3~times the
3760 * width of the original glyph outline in pixels, and which use the
3761 * @FT_PIXEL_MODE_LCD mode.
3763 * FT_RENDER_MODE_LCD_V ::
3764 * This mode corresponds to vertical RGB and BGR subpixel displays
3765 * (like PDA screens, rotated LCD displays, etc.). It produces 8-bit
3766 * bitmaps that are 3~times the height of the original glyph outline in
3767 * pixels and use the @FT_PIXEL_MODE_LCD_V mode.
3769 * FT_RENDER_MODE_SDF ::
3770 * This mode corresponds to 8-bit, single-channel signed distance field
3771 * (SDF) bitmaps. Each pixel in the SDF grid is the value from the
3772 * pixel's position to the nearest glyph's outline. The distances are
3773 * calculated from the center of the pixel and are positive if they are
3774 * filled by the outline (i.e., inside the outline) and negative
3775 * otherwise. Check the note below on how to convert the output values
3779 * The selected render mode only affects vector glyphs of a font.
3780 * Embedded bitmaps often have a different pixel mode like
3781 * @FT_PIXEL_MODE_MONO. You can use @FT_Bitmap_Convert to transform them
3782 * into 8-bit pixmaps.
3784 * For @FT_RENDER_MODE_SDF the output bitmap buffer contains normalized
3785 * distances that are packed into unsigned 8-bit values. To get pixel
3786 * values in floating point representation use the following pseudo-C
3787 * code for the conversion.
3790 * // Load glyph and render using FT_RENDER_MODE_SDF,
3791 * // then use the output buffer as follows.
3794 * FT_Byte buffer = glyph->bitmap->buffer;
3797 * for pixel in buffer
3799 * // `sd` is the signed distance and `spread` is the current spread;
3800 * // the default spread is 2 and can be changed.
3802 * float sd = (float)pixel - 128.0f;
3805 * // Convert to pixel values.
3806 * sd = ( sd / 128.0f ) * spread;
3808 * // Store `sd` in a buffer or use as required.
3813 * FreeType has two rasterizers for generating SDF, namely:
3815 * 1. `sdf` for generating SDF directly from glyph's outline, and
3817 * 2. `bsdf` for generating SDF from rasterized bitmaps.
3819 * Depending on the glyph type (i.e., outline or bitmap), one of the two
3820 * rasterizers is chosen at runtime and used for generating SDFs. To
3821 * force the use of `bsdf` you should render the glyph with any of the
3822 * FreeType's other rendering modes (e.g., `FT_RENDER_MODE_NORMAL`) and
3823 * then re-render with `FT_RENDER_MODE_SDF`.
3825 * There are some issues with stability and possible failures of the SDF
3826 * renderers (specifically `sdf`).
3828 * 1. The `sdf` rasterizer is sensitive to really small features (e.g.,
3829 * sharp turns that are less than 1~pixel) and imperfections in the
3830 * glyph's outline, causing artifacts in the final output.
3832 * 2. The `sdf` rasterizer has limited support for handling intersecting
3833 * contours and *cannot* handle self-intersecting contours whatsoever.
3834 * Self-intersection happens when a single connected contour
3835 * intersects itself at some point; having these in your font
3836 * definitely poses a problem to the rasterizer and cause artifacts,
3839 * 3. Generating SDF for really small glyphs may result in undesirable
3840 * output; the pixel grid (which stores distance information) becomes
3843 * 4. Since the output buffer is normalized, precision at smaller spreads
3844 * is greater than precision at larger spread values because the
3845 * output range of [0..255] gets mapped to a smaller SDF range. A
3846 * spread of~2 should be sufficient in most cases.
3848 * Points (1) and (2) can be avoided by using the `bsdf` rasterizer,
3849 * which is more stable than the `sdf` rasterizer in general.
3852 typedef enum FT_Render_Mode_
3854 FT_RENDER_MODE_NORMAL = 0,
3855 FT_RENDER_MODE_LIGHT,
3856 FT_RENDER_MODE_MONO,
3858 FT_RENDER_MODE_LCD_V,
3866 /* these constants are deprecated; use the corresponding */
3867 /* `FT_Render_Mode` values instead */
3868 #define ft_render_mode_normal FT_RENDER_MODE_NORMAL
3869 #define ft_render_mode_mono FT_RENDER_MODE_MONO
3872 /**************************************************************************
3878 * Convert a given glyph image to a bitmap. It does so by inspecting the
3879 * glyph image format, finding the relevant renderer, and invoking it.
3883 * A handle to the glyph slot containing the image to convert.
3887 * The render mode used to render the glyph image into a bitmap. See
3888 * @FT_Render_Mode for a list of possible values.
3890 * If @FT_RENDER_MODE_NORMAL is used, a previous call of @FT_Load_Glyph
3891 * with flag @FT_LOAD_COLOR makes `FT_Render_Glyph` provide a default
3892 * blending of colored glyph layers associated with the current glyph
3893 * slot (provided the font contains such layers) instead of rendering
3894 * the glyph slot's outline. This is an experimental feature; see
3895 * @FT_LOAD_COLOR for more information.
3898 * FreeType error code. 0~means success.
3901 * When FreeType outputs a bitmap of a glyph, it really outputs an alpha
3902 * coverage map. If a pixel is completely covered by a filled-in
3903 * outline, the bitmap contains 0xFF at that pixel, meaning that
3904 * 0xFF/0xFF fraction of that pixel is covered, meaning the pixel is 100%
3905 * black (or 0% bright). If a pixel is only 50% covered (value 0x80),
3906 * the pixel is made 50% black (50% bright or a middle shade of grey).
3907 * 0% covered means 0% black (100% bright or white).
3909 * On high-DPI screens like on smartphones and tablets, the pixels are so
3910 * small that their chance of being completely covered and therefore
3911 * completely black are fairly good. On the low-DPI screens, however,
3912 * the situation is different. The pixels are too large for most of the
3913 * details of a glyph and shades of gray are the norm rather than the
3916 * This is relevant because all our screens have a second problem: they
3917 * are not linear. 1~+~1 is not~2. Twice the value does not result in
3918 * twice the brightness. When a pixel is only 50% covered, the coverage
3919 * map says 50% black, and this translates to a pixel value of 128 when
3920 * you use 8~bits per channel (0-255). However, this does not translate
3921 * to 50% brightness for that pixel on our sRGB and gamma~2.2 screens.
3922 * Due to their non-linearity, they dwell longer in the darks and only a
3923 * pixel value of about 186 results in 50% brightness -- 128 ends up too
3924 * dark on both bright and dark backgrounds. The net result is that dark
3925 * text looks burnt-out, pixely and blotchy on bright background, bright
3926 * text too frail on dark backgrounds, and colored text on colored
3927 * background (for example, red on green) seems to have dark halos or
3928 * 'dirt' around it. The situation is especially ugly for diagonal stems
3929 * like in 'w' glyph shapes where the quality of FreeType's anti-aliasing
3930 * depends on the correct display of grays. On high-DPI screens where
3931 * smaller, fully black pixels reign supreme, this doesn't matter, but on
3932 * our low-DPI screens with all the gray shades, it does. 0% and 100%
3933 * brightness are the same things in linear and non-linear space, just
3934 * all the shades in-between aren't.
3936 * The blending function for placing text over a background is
3939 * dst = alpha * src + (1 - alpha) * dst ,
3942 * which is known as the OVER operator.
3944 * To correctly composite an anti-aliased pixel of a glyph onto a
3947 * 1. take the foreground and background colors (e.g., in sRGB space)
3948 * and apply gamma to get them in a linear space,
3950 * 2. use OVER to blend the two linear colors using the glyph pixel
3951 * as the alpha value (remember, the glyph bitmap is an alpha coverage
3954 * 3. apply inverse gamma to the blended pixel and write it back to
3957 * Internal testing at Adobe found that a target inverse gamma of~1.8 for
3958 * step~3 gives good results across a wide range of displays with an sRGB
3959 * gamma curve or a similar one.
3961 * This process can cost performance. There is an approximation that
3962 * does not need to know about the background color; see
3963 * https://bel.fi/alankila/lcd/ and
3964 * https://bel.fi/alankila/lcd/alpcor.html for details.
3966 * **ATTENTION**: Linear blending is even more important when dealing
3967 * with subpixel-rendered glyphs to prevent color-fringing! A
3968 * subpixel-rendered glyph must first be filtered with a filter that
3969 * gives equal weight to the three color primaries and does not exceed a
3970 * sum of 0x100, see section @lcd_rendering. Then the only difference to
3971 * gray linear blending is that subpixel-rendered linear blending is done
3972 * 3~times per pixel: red foreground subpixel to red background subpixel
3973 * and so on for green and blue.
3975 FT_EXPORT( FT_Error )
3976 FT_Render_Glyph( FT_GlyphSlot slot,
3977 FT_Render_Mode render_mode );
3980 /**************************************************************************
3986 * An enumeration to specify the format of kerning values returned by
3990 * FT_KERNING_DEFAULT ::
3991 * Return grid-fitted kerning distances in 26.6 fractional pixels.
3993 * FT_KERNING_UNFITTED ::
3994 * Return un-grid-fitted kerning distances in 26.6 fractional pixels.
3996 * FT_KERNING_UNSCALED ::
3997 * Return the kerning vector in original font units.
4000 * `FT_KERNING_DEFAULT` returns full pixel values; it also makes FreeType
4001 * heuristically scale down kerning distances at small ppem values so
4002 * that they don't become too big.
4004 * Both `FT_KERNING_DEFAULT` and `FT_KERNING_UNFITTED` use the current
4005 * horizontal scaling factor (as set e.g. with @FT_Set_Char_Size) to
4006 * convert font units to pixels.
4008 typedef enum FT_Kerning_Mode_
4010 FT_KERNING_DEFAULT = 0,
4011 FT_KERNING_UNFITTED,
4017 /* these constants are deprecated; use the corresponding */
4018 /* `FT_Kerning_Mode` values instead */
4019 #define ft_kerning_default FT_KERNING_DEFAULT
4020 #define ft_kerning_unfitted FT_KERNING_UNFITTED
4021 #define ft_kerning_unscaled FT_KERNING_UNSCALED
4024 /**************************************************************************
4030 * Return the kerning vector between two glyphs of the same face.
4034 * A handle to a source face object.
4037 * The index of the left glyph in the kern pair.
4040 * The index of the right glyph in the kern pair.
4043 * See @FT_Kerning_Mode for more information. Determines the scale and
4044 * dimension of the returned kerning vector.
4048 * The kerning vector. This is either in font units, fractional pixels
4049 * (26.6 format), or pixels for scalable formats, and in pixels for
4050 * fixed-sizes formats.
4053 * FreeType error code. 0~means success.
4056 * Only horizontal layouts (left-to-right & right-to-left) are supported
4057 * by this method. Other layouts, or more sophisticated kernings, are
4058 * out of the scope of this API function -- they can be implemented
4059 * through format-specific interfaces.
4061 * Kerning for OpenType fonts implemented in a 'GPOS' table is not
4062 * supported; use @FT_HAS_KERNING to find out whether a font has data
4063 * that can be extracted with `FT_Get_Kerning`.
4065 FT_EXPORT( FT_Error )
4066 FT_Get_Kerning( FT_Face face,
4068 FT_UInt right_glyph,
4070 FT_Vector *akerning );
4073 /**************************************************************************
4076 * FT_Get_Track_Kerning
4079 * Return the track kerning for a given face object at a given size.
4083 * A handle to a source face object.
4086 * The point size in 16.16 fractional points.
4089 * The degree of tightness. Increasingly negative values represent
4090 * tighter track kerning, while increasingly positive values represent
4091 * looser track kerning. Value zero means no track kerning.
4095 * The kerning in 16.16 fractional points, to be uniformly applied
4096 * between all glyphs.
4099 * FreeType error code. 0~means success.
4102 * Currently, only the Type~1 font driver supports track kerning, using
4103 * data from AFM files (if attached with @FT_Attach_File or
4104 * @FT_Attach_Stream).
4106 * Only very few AFM files come with track kerning data; please refer to
4107 * Adobe's AFM specification for more details.
4109 FT_EXPORT( FT_Error )
4110 FT_Get_Track_Kerning( FT_Face face,
4111 FT_Fixed point_size,
4113 FT_Fixed* akerning );
4116 /**************************************************************************
4123 /**************************************************************************
4129 * Select a given charmap by its encoding tag (as listed in
4134 * A handle to the source face object.
4138 * A handle to the selected encoding.
4141 * FreeType error code. 0~means success.
4144 * This function returns an error if no charmap in the face corresponds
4145 * to the encoding queried here.
4147 * Because many fonts contain more than a single cmap for Unicode
4148 * encoding, this function has some special code to select the one that
4149 * covers Unicode best ('best' in the sense that a UCS-4 cmap is
4150 * preferred to a UCS-2 cmap). It is thus preferable to @FT_Set_Charmap
4153 FT_EXPORT( FT_Error )
4154 FT_Select_Charmap( FT_Face face,
4155 FT_Encoding encoding );
4158 /**************************************************************************
4164 * Select a given charmap for character code to glyph index mapping.
4168 * A handle to the source face object.
4172 * A handle to the selected charmap.
4175 * FreeType error code. 0~means success.
4178 * This function returns an error if the charmap is not part of the face
4179 * (i.e., if it is not listed in the `face->charmaps` table).
4181 * It also fails if an OpenType type~14 charmap is selected (which
4182 * doesn't map character codes to glyph indices at all).
4184 FT_EXPORT( FT_Error )
4185 FT_Set_Charmap( FT_Face face,
4186 FT_CharMap charmap );
4189 /**************************************************************************
4192 * FT_Get_Charmap_Index
4195 * Retrieve index of a given charmap.
4199 * A handle to a charmap.
4202 * The index into the array of character maps within the face to which
4203 * `charmap` belongs. If an error occurs, -1 is returned.
4207 FT_Get_Charmap_Index( FT_CharMap charmap );
4210 /**************************************************************************
4216 * Return the glyph index of a given character code. This function uses
4217 * the currently selected charmap to do the mapping.
4221 * A handle to the source face object.
4224 * The character code.
4227 * The glyph index. 0~means 'undefined character code'.
4230 * If you use FreeType to manipulate the contents of font files directly,
4231 * be aware that the glyph index returned by this function doesn't always
4232 * correspond to the internal indices used within the file. This is done
4233 * to ensure that value~0 always corresponds to the 'missing glyph'. If
4234 * the first glyph is not named '.notdef', then for Type~1 and Type~42
4235 * fonts, '.notdef' will be moved into the glyph ID~0 position, and
4236 * whatever was there will be moved to the position '.notdef' had. For
4237 * Type~1 fonts, if there is no '.notdef' glyph at all, then one will be
4238 * created at index~0 and whatever was there will be moved to the last
4239 * index -- Type~42 fonts are considered invalid under this condition.
4241 FT_EXPORT( FT_UInt )
4242 FT_Get_Char_Index( FT_Face face,
4243 FT_ULong charcode );
4246 /**************************************************************************
4252 * Return the first character code in the current charmap of a given
4253 * face, together with its corresponding glyph index.
4257 * A handle to the source face object.
4261 * Glyph index of first character code. 0~if charmap is empty.
4264 * The charmap's first character code.
4267 * You should use this function together with @FT_Get_Next_Char to parse
4268 * all character codes available in a given charmap. The code should
4272 * FT_ULong charcode;
4276 * charcode = FT_Get_First_Char( face, &gindex );
4277 * while ( gindex != 0 )
4279 * ... do something with (charcode,gindex) pair ...
4281 * charcode = FT_Get_Next_Char( face, charcode, &gindex );
4285 * Be aware that character codes can have values up to 0xFFFFFFFF; this
4286 * might happen for non-Unicode or malformed cmaps. However, even with
4287 * regular Unicode encoding, so-called 'last resort fonts' (using SFNT
4288 * cmap format 13, see function @FT_Get_CMap_Format) normally have
4289 * entries for all Unicode characters up to 0x1FFFFF, which can cause *a
4290 * lot* of iterations.
4292 * Note that `*agindex` is set to~0 if the charmap is empty. The result
4293 * itself can be~0 in two cases: if the charmap is empty or if the
4294 * value~0 is the first valid character code.
4296 FT_EXPORT( FT_ULong )
4297 FT_Get_First_Char( FT_Face face,
4301 /**************************************************************************
4307 * Return the next character code in the current charmap of a given face
4308 * following the value `char_code`, as well as the corresponding glyph
4313 * A handle to the source face object.
4316 * The starting character code.
4320 * Glyph index of next character code. 0~if charmap is empty.
4323 * The charmap's next character code.
4326 * You should use this function with @FT_Get_First_Char to walk over all
4327 * character codes available in a given charmap. See the note for that
4328 * function for a simple code example.
4330 * Note that `*agindex` is set to~0 when there are no more codes in the
4333 FT_EXPORT( FT_ULong )
4334 FT_Get_Next_Char( FT_Face face,
4339 /**************************************************************************
4346 /**************************************************************************
4349 * FT_Face_Properties
4352 * Set or override certain (library or module-wide) properties on a
4353 * face-by-face basis. Useful for finer-grained control and avoiding
4354 * locks on shared structures (threads can modify their own faces as they
4357 * Contrary to @FT_Property_Set, this function uses @FT_Parameter so that
4358 * you can pass multiple properties to the target face in one call. Note
4359 * that only a subset of the available properties can be controlled.
4361 * * @FT_PARAM_TAG_STEM_DARKENING (stem darkening, corresponding to the
4362 * property `no-stem-darkening` provided by the 'autofit', 'cff',
4363 * 'type1', and 't1cid' modules; see @no-stem-darkening).
4365 * * @FT_PARAM_TAG_LCD_FILTER_WEIGHTS (LCD filter weights, corresponding
4366 * to function @FT_Library_SetLcdFilterWeights).
4368 * * @FT_PARAM_TAG_RANDOM_SEED (seed value for the CFF, Type~1, and CID
4369 * 'random' operator, corresponding to the `random-seed` property
4370 * provided by the 'cff', 'type1', and 't1cid' modules; see
4373 * Pass `NULL` as `data` in @FT_Parameter for a given tag to reset the
4374 * option and use the library or module default again.
4378 * A handle to the source face object.
4381 * The number of properties that follow.
4384 * A handle to an @FT_Parameter array with `num_properties` elements.
4387 * FreeType error code. 0~means success.
4390 * Here is an example that sets three properties. You must define
4391 * `FT_CONFIG_OPTION_SUBPIXEL_RENDERING` to make the LCD filter examples
4395 * FT_Parameter property1;
4396 * FT_Bool darken_stems = 1;
4398 * FT_Parameter property2;
4399 * FT_LcdFiveTapFilter custom_weight =
4400 * { 0x11, 0x44, 0x56, 0x44, 0x11 };
4402 * FT_Parameter property3;
4403 * FT_Int32 random_seed = 314159265;
4405 * FT_Parameter properties[3] = { property1,
4410 * property1.tag = FT_PARAM_TAG_STEM_DARKENING;
4411 * property1.data = &darken_stems;
4413 * property2.tag = FT_PARAM_TAG_LCD_FILTER_WEIGHTS;
4414 * property2.data = custom_weight;
4416 * property3.tag = FT_PARAM_TAG_RANDOM_SEED;
4417 * property3.data = &random_seed;
4419 * FT_Face_Properties( face, 3, properties );
4422 * The next example resets a single property to its default value.
4425 * FT_Parameter property;
4428 * property.tag = FT_PARAM_TAG_LCD_FILTER_WEIGHTS;
4429 * property.data = NULL;
4431 * FT_Face_Properties( face, 1, &property );
4438 FT_EXPORT( FT_Error )
4439 FT_Face_Properties( FT_Face face,
4440 FT_UInt num_properties,
4441 FT_Parameter* properties );
4444 /**************************************************************************
4447 * information_retrieval
4451 /**************************************************************************
4457 * Return the glyph index of a given glyph name. This only works
4458 * for those faces where @FT_HAS_GLYPH_NAMES returns true.
4462 * A handle to the source face object.
4468 * The glyph index. 0~means 'undefined character code'.
4471 * Acceptable glyph names might come from the [Adobe Glyph
4472 * List](https://github.com/adobe-type-tools/agl-aglfn). See
4473 * @FT_Get_Glyph_Name for the inverse functionality.
4475 * This function has limited capabilities if the config macro
4476 * `FT_CONFIG_OPTION_POSTSCRIPT_NAMES` is not defined in `ftoption.h`:
4477 * It then works only for fonts that actually embed glyph names (which
4478 * many recent OpenType fonts do not).
4480 FT_EXPORT( FT_UInt )
4481 FT_Get_Name_Index( FT_Face face,
4482 const FT_String* glyph_name );
4485 /**************************************************************************
4491 * Retrieve the ASCII name of a given glyph in a face. This only works
4492 * for those faces where @FT_HAS_GLYPH_NAMES returns true.
4496 * A handle to a source face object.
4502 * The maximum number of bytes available in the buffer.
4506 * A pointer to a target buffer where the name is copied to.
4509 * FreeType error code. 0~means success.
4512 * An error is returned if the face doesn't provide glyph names or if the
4513 * glyph index is invalid. In all cases of failure, the first byte of
4514 * `buffer` is set to~0 to indicate an empty name.
4516 * The glyph name is truncated to fit within the buffer if it is too
4517 * long. The returned string is always zero-terminated.
4519 * Be aware that FreeType reorders glyph indices internally so that glyph
4520 * index~0 always corresponds to the 'missing glyph' (called '.notdef').
4522 * This function has limited capabilities if the config macro
4523 * `FT_CONFIG_OPTION_POSTSCRIPT_NAMES` is not defined in `ftoption.h`:
4524 * It then works only for fonts that actually embed glyph names (which
4525 * many recent OpenType fonts do not).
4527 FT_EXPORT( FT_Error )
4528 FT_Get_Glyph_Name( FT_Face face,
4529 FT_UInt glyph_index,
4531 FT_UInt buffer_max );
4534 /**************************************************************************
4537 * FT_Get_Postscript_Name
4540 * Retrieve the ASCII PostScript name of a given face, if available.
4541 * This only works with PostScript, TrueType, and OpenType fonts.
4545 * A handle to the source face object.
4548 * A pointer to the face's PostScript name. `NULL` if unavailable.
4551 * The returned pointer is owned by the face and is destroyed with it.
4553 * For variation fonts, this string changes if you select a different
4554 * instance, and you have to call `FT_Get_PostScript_Name` again to
4555 * retrieve it. FreeType follows Adobe TechNote #5902, 'Generating
4556 * PostScript Names for Fonts Using OpenType Font Variations'.
4558 * https://download.macromedia.com/pub/developer/opentype/tech-notes/5902.AdobePSNameGeneration.html
4560 * [Since 2.9] Special PostScript names for named instances are only
4561 * returned if the named instance is set with @FT_Set_Named_Instance (and
4562 * the font has corresponding entries in its 'fvar' table or is the
4563 * default named instance). If @FT_IS_VARIATION returns true, the
4564 * algorithmically derived PostScript name is provided, not looking up
4565 * special entries for named instances.
4567 FT_EXPORT( const char* )
4568 FT_Get_Postscript_Name( FT_Face face );
4571 /**************************************************************************
4574 * FT_SUBGLYPH_FLAG_XXX
4577 * A list of constants describing subglyphs. Please refer to the 'glyf'
4578 * table description in the OpenType specification for the meaning of the
4579 * various flags (which get synthesized for non-OpenType subglyphs).
4581 * https://docs.microsoft.com/en-us/typography/opentype/spec/glyf#composite-glyph-description
4584 * FT_SUBGLYPH_FLAG_ARGS_ARE_WORDS ::
4585 * FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES ::
4586 * FT_SUBGLYPH_FLAG_ROUND_XY_TO_GRID ::
4587 * FT_SUBGLYPH_FLAG_SCALE ::
4588 * FT_SUBGLYPH_FLAG_XY_SCALE ::
4589 * FT_SUBGLYPH_FLAG_2X2 ::
4590 * FT_SUBGLYPH_FLAG_USE_MY_METRICS ::
4593 #define FT_SUBGLYPH_FLAG_ARGS_ARE_WORDS 1
4594 #define FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES 2
4595 #define FT_SUBGLYPH_FLAG_ROUND_XY_TO_GRID 4
4596 #define FT_SUBGLYPH_FLAG_SCALE 8
4597 #define FT_SUBGLYPH_FLAG_XY_SCALE 0x40
4598 #define FT_SUBGLYPH_FLAG_2X2 0x80
4599 #define FT_SUBGLYPH_FLAG_USE_MY_METRICS 0x200
4602 /**************************************************************************
4605 * FT_Get_SubGlyph_Info
4608 * Retrieve a description of a given subglyph. Only use it if
4609 * `glyph->format` is @FT_GLYPH_FORMAT_COMPOSITE; an error is returned
4614 * The source glyph slot.
4617 * The index of the subglyph. Must be less than
4618 * `glyph->num_subglyphs`.
4622 * The glyph index of the subglyph.
4625 * The subglyph flags, see @FT_SUBGLYPH_FLAG_XXX.
4628 * The subglyph's first argument (if any).
4631 * The subglyph's second argument (if any).
4634 * The subglyph transformation (if any).
4637 * FreeType error code. 0~means success.
4640 * The values of `*p_arg1`, `*p_arg2`, and `*p_transform` must be
4641 * interpreted depending on the flags returned in `*p_flags`. See the
4642 * OpenType specification for details.
4644 * https://docs.microsoft.com/en-us/typography/opentype/spec/glyf#composite-glyph-description
4647 FT_EXPORT( FT_Error )
4648 FT_Get_SubGlyph_Info( FT_GlyphSlot glyph,
4654 FT_Matrix *p_transform );
4657 /**************************************************************************
4663 * A list of bit flags used in the `fsType` field of the OS/2 table in a
4664 * TrueType or OpenType font and the `FSType` entry in a PostScript font.
4665 * These bit flags are returned by @FT_Get_FSType_Flags; they inform
4666 * client applications of embedding and subsetting restrictions
4667 * associated with a font.
4670 * https://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/FontPolicies.pdf
4674 * FT_FSTYPE_INSTALLABLE_EMBEDDING ::
4675 * Fonts with no fsType bit set may be embedded and permanently
4676 * installed on the remote system by an application.
4678 * FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING ::
4679 * Fonts that have only this bit set must not be modified, embedded or
4680 * exchanged in any manner without first obtaining permission of the
4681 * font software copyright owner.
4683 * FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING ::
4684 * The font may be embedded and temporarily loaded on the remote
4685 * system. Documents containing Preview & Print fonts must be opened
4686 * 'read-only'; no edits can be applied to the document.
4688 * FT_FSTYPE_EDITABLE_EMBEDDING ::
4689 * The font may be embedded but must only be installed temporarily on
4690 * other systems. In contrast to Preview & Print fonts, documents
4691 * containing editable fonts may be opened for reading, editing is
4692 * permitted, and changes may be saved.
4694 * FT_FSTYPE_NO_SUBSETTING ::
4695 * The font may not be subsetted prior to embedding.
4697 * FT_FSTYPE_BITMAP_EMBEDDING_ONLY ::
4698 * Only bitmaps contained in the font may be embedded; no outline data
4699 * may be embedded. If there are no bitmaps available in the font,
4700 * then the font is unembeddable.
4703 * The flags are ORed together, thus more than a single value can be
4706 * While the `fsType` flags can indicate that a font may be embedded, a
4707 * license with the font vendor may be separately required to use the
4710 #define FT_FSTYPE_INSTALLABLE_EMBEDDING 0x0000
4711 #define FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING 0x0002
4712 #define FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING 0x0004
4713 #define FT_FSTYPE_EDITABLE_EMBEDDING 0x0008
4714 #define FT_FSTYPE_NO_SUBSETTING 0x0100
4715 #define FT_FSTYPE_BITMAP_EMBEDDING_ONLY 0x0200
4718 /**************************************************************************
4721 * FT_Get_FSType_Flags
4724 * Return the `fsType` flags for a font.
4728 * A handle to the source face object.
4731 * The `fsType` flags, see @FT_FSTYPE_XXX.
4734 * Use this function rather than directly reading the `fs_type` field in
4735 * the @PS_FontInfoRec structure, which is only guaranteed to return the
4736 * correct results for Type~1 fonts.
4742 FT_EXPORT( FT_UShort )
4743 FT_Get_FSType_Flags( FT_Face face );
4746 /**************************************************************************
4752 * Unicode Variation Sequences
4755 * The FreeType~2 interface to Unicode Variation Sequences (UVS), using
4756 * the SFNT cmap format~14.
4759 * Many characters, especially for CJK scripts, have variant forms. They
4760 * are a sort of grey area somewhere between being totally irrelevant and
4761 * semantically distinct; for this reason, the Unicode consortium decided
4762 * to introduce Variation Sequences (VS), consisting of a Unicode base
4763 * character and a variation selector instead of further extending the
4764 * already huge number of characters.
4766 * Unicode maintains two different sets, namely 'Standardized Variation
4767 * Sequences' and registered 'Ideographic Variation Sequences' (IVS),
4768 * collected in the 'Ideographic Variation Database' (IVD).
4770 * https://unicode.org/Public/UCD/latest/ucd/StandardizedVariants.txt
4771 * https://unicode.org/reports/tr37/ https://unicode.org/ivd/
4773 * To date (January 2017), the character with the most ideographic
4774 * variations is U+9089, having 32 such IVS.
4776 * Three Mongolian Variation Selectors have the values U+180B-U+180D; 256
4777 * generic Variation Selectors are encoded in the ranges U+FE00-U+FE0F
4778 * and U+E0100-U+E01EF. IVS currently use Variation Selectors from the
4779 * range U+E0100-U+E01EF only.
4781 * A VS consists of the base character value followed by a single
4782 * Variation Selector. For example, to get the first variation of
4783 * U+9089, you have to write the character sequence `U+9089 U+E0100`.
4785 * Adobe and MS decided to support both standardized and ideographic VS
4786 * with a new cmap subtable (format~14). It is an odd subtable because
4787 * it is not a mapping of input code points to glyphs, but contains lists
4788 * of all variations supported by the font.
4790 * A variation may be either 'default' or 'non-default' for a given font.
4791 * A default variation is the one you will get for that code point if you
4792 * look it up in the standard Unicode cmap. A non-default variation is a
4798 /**************************************************************************
4801 * FT_Face_GetCharVariantIndex
4804 * Return the glyph index of a given character code as modified by the
4805 * variation selector.
4809 * A handle to the source face object.
4812 * The character code point in Unicode.
4814 * variantSelector ::
4815 * The Unicode code point of the variation selector.
4818 * The glyph index. 0~means either 'undefined character code', or
4819 * 'undefined selector code', or 'no variation selector cmap subtable',
4820 * or 'current CharMap is not Unicode'.
4823 * If you use FreeType to manipulate the contents of font files directly,
4824 * be aware that the glyph index returned by this function doesn't always
4825 * correspond to the internal indices used within the file. This is done
4826 * to ensure that value~0 always corresponds to the 'missing glyph'.
4828 * This function is only meaningful if
4829 * a) the font has a variation selector cmap sub table, and
4830 * b) the current charmap has a Unicode encoding.
4836 FT_EXPORT( FT_UInt )
4837 FT_Face_GetCharVariantIndex( FT_Face face,
4839 FT_ULong variantSelector );
4842 /**************************************************************************
4845 * FT_Face_GetCharVariantIsDefault
4848 * Check whether this variation of this Unicode character is the one to
4849 * be found in the charmap.
4853 * A handle to the source face object.
4856 * The character codepoint in Unicode.
4858 * variantSelector ::
4859 * The Unicode codepoint of the variation selector.
4862 * 1~if found in the standard (Unicode) cmap, 0~if found in the variation
4863 * selector cmap, or -1 if it is not a variation.
4866 * This function is only meaningful if the font has a variation selector
4874 FT_Face_GetCharVariantIsDefault( FT_Face face,
4876 FT_ULong variantSelector );
4879 /**************************************************************************
4882 * FT_Face_GetVariantSelectors
4885 * Return a zero-terminated list of Unicode variation selectors found in
4890 * A handle to the source face object.
4893 * A pointer to an array of selector code points, or `NULL` if there is
4894 * no valid variation selector cmap subtable.
4897 * The last item in the array is~0; the array is owned by the @FT_Face
4898 * object but can be overwritten or released on the next call to a
4899 * FreeType function.
4905 FT_EXPORT( FT_UInt32* )
4906 FT_Face_GetVariantSelectors( FT_Face face );
4909 /**************************************************************************
4912 * FT_Face_GetVariantsOfChar
4915 * Return a zero-terminated list of Unicode variation selectors found for
4916 * the specified character code.
4920 * A handle to the source face object.
4923 * The character codepoint in Unicode.
4926 * A pointer to an array of variation selector code points that are
4927 * active for the given character, or `NULL` if the corresponding list is
4931 * The last item in the array is~0; the array is owned by the @FT_Face
4932 * object but can be overwritten or released on the next call to a
4933 * FreeType function.
4939 FT_EXPORT( FT_UInt32* )
4940 FT_Face_GetVariantsOfChar( FT_Face face,
4941 FT_ULong charcode );
4944 /**************************************************************************
4947 * FT_Face_GetCharsOfVariant
4950 * Return a zero-terminated list of Unicode character codes found for the
4951 * specified variation selector.
4955 * A handle to the source face object.
4957 * variantSelector ::
4958 * The variation selector code point in Unicode.
4961 * A list of all the code points that are specified by this selector
4962 * (both default and non-default codes are returned) or `NULL` if there
4963 * is no valid cmap or the variation selector is invalid.
4966 * The last item in the array is~0; the array is owned by the @FT_Face
4967 * object but can be overwritten or released on the next call to a
4968 * FreeType function.
4974 FT_EXPORT( FT_UInt32* )
4975 FT_Face_GetCharsOfVariant( FT_Face face,
4976 FT_ULong variantSelector );
4979 /**************************************************************************
4988 * Crunching fixed numbers and vectors.
4991 * This section contains various functions used to perform computations
4992 * on 16.16 fixed-point numbers or 2D vectors. FreeType does not use
4993 * floating-point data types.
4995 * **Attention**: Most arithmetic functions take `FT_Long` as arguments.
4996 * For historical reasons, FreeType was designed under the assumption
4997 * that `FT_Long` is a 32-bit integer; results can thus be undefined if
4998 * the arguments don't fit into 32 bits.
5007 * FT_Vector_Transform
5008 * FT_Matrix_Multiply
5014 /**************************************************************************
5020 * Compute `(a*b)/c` with maximum accuracy, using a 64-bit intermediate
5021 * integer whenever necessary.
5023 * This function isn't necessarily as fast as some processor-specific
5024 * operations, but is at least completely portable.
5028 * The first multiplier.
5031 * The second multiplier.
5037 * The result of `(a*b)/c`. This function never traps when trying to
5038 * divide by zero; it simply returns 'MaxInt' or 'MinInt' depending on
5039 * the signs of `a` and `b`.
5041 FT_EXPORT( FT_Long )
5042 FT_MulDiv( FT_Long a,
5047 /**************************************************************************
5053 * Compute `(a*b)/0x10000` with maximum accuracy. Its main use is to
5054 * multiply a given value by a 16.16 fixed-point factor.
5058 * The first multiplier.
5061 * The second multiplier. Use a 16.16 factor here whenever possible
5065 * The result of `(a*b)/0x10000`.
5068 * This function has been optimized for the case where the absolute value
5069 * of `a` is less than 2048, and `b` is a 16.16 scaling factor. As this
5070 * happens mainly when scaling from notional units to fractional pixels
5071 * in FreeType, it resulted in noticeable speed improvements between
5072 * versions 2.x and 1.x.
5074 * As a conclusion, always try to place a 16.16 factor as the _second_
5075 * argument of this function; this can make a great difference.
5077 FT_EXPORT( FT_Long )
5078 FT_MulFix( FT_Long a,
5082 /**************************************************************************
5088 * Compute `(a*0x10000)/b` with maximum accuracy. Its main use is to
5089 * divide a given value by a 16.16 fixed-point factor.
5096 * The denominator. Use a 16.16 factor here.
5099 * The result of `(a*0x10000)/b`.
5101 FT_EXPORT( FT_Long )
5102 FT_DivFix( FT_Long a,
5106 /**************************************************************************
5112 * Round a 16.16 fixed number.
5116 * The number to be rounded.
5119 * `a` rounded to the nearest 16.16 fixed integer, halfway cases away
5123 * The function uses wrap-around arithmetic.
5125 FT_EXPORT( FT_Fixed )
5126 FT_RoundFix( FT_Fixed a );
5129 /**************************************************************************
5135 * Compute the smallest following integer of a 16.16 fixed number.
5139 * The number for which the ceiling function is to be computed.
5142 * `a` rounded towards plus infinity.
5145 * The function uses wrap-around arithmetic.
5147 FT_EXPORT( FT_Fixed )
5148 FT_CeilFix( FT_Fixed a );
5151 /**************************************************************************
5157 * Compute the largest previous integer of a 16.16 fixed number.
5161 * The number for which the floor function is to be computed.
5164 * `a` rounded towards minus infinity.
5166 FT_EXPORT( FT_Fixed )
5167 FT_FloorFix( FT_Fixed a );
5170 /**************************************************************************
5173 * FT_Vector_Transform
5176 * Transform a single vector through a 2x2 matrix.
5180 * The target vector to transform.
5184 * A pointer to the source 2x2 matrix.
5187 * The result is undefined if either `vector` or `matrix` is invalid.
5190 FT_Vector_Transform( FT_Vector* vector,
5191 const FT_Matrix* matrix );
5194 /**************************************************************************
5201 /**************************************************************************
5207 * These three macros identify the FreeType source code version. Use
5208 * @FT_Library_Version to access them at runtime.
5212 * The major version number.
5214 * The minor version number.
5219 * The version number of FreeType if built as a dynamic link library with
5220 * the 'libtool' package is _not_ controlled by these three macros.
5223 #define FREETYPE_MAJOR 2
5224 #define FREETYPE_MINOR 13
5225 #define FREETYPE_PATCH 2
5228 /**************************************************************************
5231 * FT_Library_Version
5234 * Return the version of the FreeType library being used. This is useful
5235 * when dynamically linking to the library, since one cannot use the
5236 * macros @FREETYPE_MAJOR, @FREETYPE_MINOR, and @FREETYPE_PATCH.
5240 * A source library handle.
5244 * The major version number.
5247 * The minor version number.
5250 * The patch version number.
5253 * The reason why this function takes a `library` argument is because
5254 * certain programs implement library initialization in a custom way that
5255 * doesn't use @FT_Init_FreeType.
5257 * In such cases, the library version might not be available before the
5258 * library object has been created.
5261 FT_Library_Version( FT_Library library,
5267 /**************************************************************************
5274 /**************************************************************************
5277 * FT_Face_CheckTrueTypePatents
5280 * Deprecated, does nothing.
5287 * Always returns false.
5290 * Since May 2010, TrueType hinting is no longer patented.
5296 FT_EXPORT( FT_Bool )
5297 FT_Face_CheckTrueTypePatents( FT_Face face );
5300 /**************************************************************************
5303 * FT_Face_SetUnpatentedHinting
5306 * Deprecated, does nothing.
5313 * New boolean setting.
5316 * Always returns false.
5319 * Since May 2010, TrueType hinting is no longer patented.
5325 FT_EXPORT( FT_Bool )
5326 FT_Face_SetUnpatentedHinting( FT_Face face,
5334 #endif /* FREETYPE_H_ */