1 /***************************************************************************/
5 /* FreeType high-level API and common types (specification only). */
7 /* Copyright 1996-2018 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. */
16 /***************************************************************************/
24 #error "`ft2build.h' hasn't been included yet!"
25 #error "Please always use macros to include FreeType header files."
27 #error " #include <ft2build.h>"
28 #error " #include FT_FREETYPE_H"
33 #include FT_CONFIG_CONFIG_H
42 /*************************************************************************/
45 /* header_inclusion */
48 /* FreeType's header inclusion scheme */
51 /* How client applications should include FreeType header files. */
54 /* To be as flexible as possible (and for historical reasons), */
55 /* FreeType uses a very special inclusion scheme to load header */
56 /* files, for example */
59 /* #include <ft2build.h> */
61 /* #include FT_FREETYPE_H */
62 /* #include FT_OUTLINE_H */
65 /* A compiler and its preprocessor only needs an include path to find */
66 /* the file `ft2build.h'; the exact locations and names of the other */
67 /* FreeType header files are hidden by preprocessor macro names, */
68 /* loaded by `ft2build.h'. The API documentation always gives the */
69 /* header macro name needed for a particular function. */
71 /*************************************************************************/
74 /*************************************************************************/
83 /* How client applications should allocate FreeType data structures. */
86 /* FreeType assumes that structures allocated by the user and passed */
87 /* as arguments are zeroed out except for the actual data. In other */
88 /* words, it is recommended to use `calloc' (or variants of it) */
89 /* instead of `malloc' for allocation. */
91 /*************************************************************************/
95 /*************************************************************************/
96 /*************************************************************************/
98 /* B A S I C T Y P E S */
100 /*************************************************************************/
101 /*************************************************************************/
104 /*************************************************************************/
113 /* The FreeType~2 base font interface. */
116 /* This section describes the most important public high-level API */
117 /* functions of FreeType~2. */
130 /* FT_FACE_FLAG_SCALABLE */
131 /* FT_FACE_FLAG_FIXED_SIZES */
132 /* FT_FACE_FLAG_FIXED_WIDTH */
133 /* FT_FACE_FLAG_HORIZONTAL */
134 /* FT_FACE_FLAG_VERTICAL */
135 /* FT_FACE_FLAG_COLOR */
136 /* FT_FACE_FLAG_SFNT */
137 /* FT_FACE_FLAG_CID_KEYED */
138 /* FT_FACE_FLAG_TRICKY */
139 /* FT_FACE_FLAG_KERNING */
140 /* FT_FACE_FLAG_MULTIPLE_MASTERS */
141 /* FT_FACE_FLAG_VARIATION */
142 /* FT_FACE_FLAG_GLYPH_NAMES */
143 /* FT_FACE_FLAG_EXTERNAL_STREAM */
144 /* FT_FACE_FLAG_HINTER */
146 /* FT_HAS_HORIZONTAL */
147 /* FT_HAS_VERTICAL */
149 /* FT_HAS_FIXED_SIZES */
150 /* FT_HAS_GLYPH_NAMES */
152 /* FT_HAS_MULTIPLE_MASTERS */
156 /* FT_IS_FIXED_WIDTH */
157 /* FT_IS_CID_KEYED */
159 /* FT_IS_NAMED_INSTANCE */
160 /* FT_IS_VARIATION */
162 /* FT_STYLE_FLAG_BOLD */
163 /* FT_STYLE_FLAG_ITALIC */
166 /* FT_Size_Metrics */
168 /* FT_GlyphSlotRec */
169 /* FT_Glyph_Metrics */
174 /* FT_Init_FreeType */
175 /* FT_Done_FreeType */
179 /* FT_Reference_Face */
180 /* FT_New_Memory_Face */
181 /* FT_Face_Properties */
186 /* FT_Attach_Stream */
188 /* FT_Set_Char_Size */
189 /* FT_Set_Pixel_Sizes */
190 /* FT_Request_Size */
192 /* FT_Size_Request_Type */
193 /* FT_Size_RequestRec */
194 /* FT_Size_Request */
195 /* FT_Set_Transform */
197 /* FT_Get_Char_Index */
198 /* FT_Get_First_Char */
199 /* FT_Get_Next_Char */
200 /* FT_Get_Name_Index */
205 /* FT_OPEN_PATHNAME */
209 /* FT_LOAD_DEFAULT */
211 /* FT_LOAD_MONOCHROME */
212 /* FT_LOAD_LINEAR_DESIGN */
213 /* FT_LOAD_NO_SCALE */
214 /* FT_LOAD_NO_HINTING */
215 /* FT_LOAD_NO_BITMAP */
216 /* FT_LOAD_NO_AUTOHINT */
219 /* FT_LOAD_VERTICAL_LAYOUT */
220 /* FT_LOAD_IGNORE_TRANSFORM */
221 /* FT_LOAD_FORCE_AUTOHINT */
222 /* FT_LOAD_NO_RECURSE */
223 /* FT_LOAD_PEDANTIC */
225 /* FT_LOAD_TARGET_NORMAL */
226 /* FT_LOAD_TARGET_LIGHT */
227 /* FT_LOAD_TARGET_MONO */
228 /* FT_LOAD_TARGET_LCD */
229 /* FT_LOAD_TARGET_LCD_V */
231 /* FT_LOAD_TARGET_MODE */
233 /* FT_Render_Glyph */
236 /* FT_Kerning_Mode */
237 /* FT_Get_Track_Kerning */
238 /* FT_Get_Glyph_Name */
239 /* FT_Get_Postscript_Name */
242 /* FT_Select_Charmap */
244 /* FT_Get_Charmap_Index */
246 /* FT_Get_FSType_Flags */
247 /* FT_Get_SubGlyph_Info */
249 /* FT_Face_Internal */
250 /* FT_Size_Internal */
251 /* FT_Slot_Internal */
253 /* FT_FACE_FLAG_XXX */
254 /* FT_STYLE_FLAG_XXX */
257 /* FT_LOAD_TARGET_XXX */
258 /* FT_SUBGLYPH_FLAG_XXX */
261 /* FT_HAS_FAST_GLYPHS */
263 /*************************************************************************/
266 /*************************************************************************/
269 /* FT_Glyph_Metrics */
272 /* A structure to model the metrics of a single glyph. The values */
273 /* are expressed in 26.6 fractional pixel format; if the flag */
274 /* @FT_LOAD_NO_SCALE has been used while loading the glyph, values */
275 /* are expressed in font units instead. */
279 /* The glyph's width. */
282 /* The glyph's height. */
284 /* horiBearingX :: */
285 /* Left side bearing for horizontal layout. */
287 /* horiBearingY :: */
288 /* Top side bearing for horizontal layout. */
291 /* Advance width for horizontal layout. */
293 /* vertBearingX :: */
294 /* Left side bearing for vertical layout. */
296 /* vertBearingY :: */
297 /* Top side bearing for vertical layout. Larger positive values */
298 /* mean further below the vertical glyph origin. */
301 /* Advance height for vertical layout. Positive values mean the */
302 /* glyph has a positive advance downward. */
305 /* If not disabled with @FT_LOAD_NO_HINTING, the values represent */
306 /* dimensions of the hinted glyph (in case hinting is applicable). */
308 /* Stroking a glyph with an outside border does not increase */
309 /* `horiAdvance' or `vertAdvance'; you have to manually adjust these */
310 /* values to account for the added width and height. */
312 /* FreeType doesn't use the `VORG' table data for CFF fonts because */
313 /* it doesn't have an interface to quickly retrieve the glyph height. */
314 /* The y~coordinate of the vertical origin can be simply computed as */
315 /* `vertBearingY + height' after loading a glyph. */
317 typedef struct FT_Glyph_Metrics_
333 /*************************************************************************/
339 /* This structure models the metrics of a bitmap strike (i.e., a set */
340 /* of glyphs for a given point size and resolution) in a bitmap font. */
341 /* It is used for the `available_sizes' field of @FT_Face. */
344 /* height :: The vertical distance, in pixels, between two */
345 /* consecutive baselines. It is always positive. */
347 /* width :: The average width, in pixels, of all glyphs in the */
350 /* size :: The nominal size of the strike in 26.6 fractional */
351 /* points. This field is not very useful. */
353 /* x_ppem :: The horizontal ppem (nominal width) in 26.6 fractional */
356 /* y_ppem :: The vertical ppem (nominal height) in 26.6 fractional */
361 /* The nominal size given in a FNT font is not reliable. If the */
362 /* driver finds it incorrect, it sets `size' to some calculated */
363 /* values, and `x_ppem' and `y_ppem' to the pixel width and height */
364 /* given in the font, respectively. */
366 /* TrueType embedded bitmaps: */
367 /* `size', `width', and `height' values are not contained in the */
368 /* bitmap strike itself. They are computed from the global font */
371 typedef struct FT_Bitmap_Size_
384 /*************************************************************************/
385 /*************************************************************************/
387 /* O B J E C T C L A S S E S */
389 /*************************************************************************/
390 /*************************************************************************/
392 /*************************************************************************/
398 /* A handle to a FreeType library instance. Each `library' is */
399 /* completely independent from the others; it is the `root' of a set */
400 /* of objects like fonts, faces, sizes, etc. */
402 /* It also embeds a memory manager (see @FT_Memory), as well as a */
403 /* scan-line converter object (see @FT_Raster). */
405 /* In multi-threaded applications it is easiest to use one */
406 /* `FT_Library' object per thread. In case this is too cumbersome, */
407 /* a single `FT_Library' object across threads is possible also */
408 /* (since FreeType version 2.5.6), as long as a mutex lock is used */
409 /* around @FT_New_Face and @FT_Done_Face. */
412 /* Library objects are normally created by @FT_Init_FreeType, and */
413 /* destroyed with @FT_Done_FreeType. If you need reference-counting */
414 /* (cf. @FT_Reference_Library), use @FT_New_Library and */
415 /* @FT_Done_Library. */
417 typedef struct FT_LibraryRec_ *FT_Library;
420 /*************************************************************************/
423 /* module_management */
425 /*************************************************************************/
427 /*************************************************************************/
433 /* A handle to a given FreeType module object. A module can be a */
434 /* font driver, a renderer, or anything else that provides services */
437 typedef struct FT_ModuleRec_* FT_Module;
440 /*************************************************************************/
446 /* A handle to a given FreeType font driver object. A font driver */
447 /* is a module capable of creating faces from font files. */
449 typedef struct FT_DriverRec_* FT_Driver;
452 /*************************************************************************/
458 /* A handle to a given FreeType renderer. A renderer is a module in */
459 /* charge of converting a glyph's outline image to a bitmap. It */
460 /* supports a single glyph image format, and one or more target */
461 /* surface depths. */
463 typedef struct FT_RendererRec_* FT_Renderer;
466 /*************************************************************************/
471 /*************************************************************************/
473 /*************************************************************************/
479 /* A handle to a typographic face object. A face object models a */
480 /* given typeface, in a given style. */
483 /* A face object also owns a single @FT_GlyphSlot object, as well */
484 /* as one or more @FT_Size objects. */
486 /* Use @FT_New_Face or @FT_Open_Face to create a new face object from */
487 /* a given filepath or a custom input stream. */
489 /* Use @FT_Done_Face to destroy it (along with its slot and sizes). */
491 /* An `FT_Face' object can only be safely used from one thread at a */
492 /* time. Similarly, creation and destruction of `FT_Face' with the */
493 /* same @FT_Library object can only be done from one thread at a */
494 /* time. On the other hand, functions like @FT_Load_Glyph and its */
495 /* siblings are thread-safe and do not need the lock to be held as */
496 /* long as the same `FT_Face' object is not used from multiple */
497 /* threads at the same time. */
500 /* See @FT_FaceRec for the publicly accessible fields of a given face */
503 typedef struct FT_FaceRec_* FT_Face;
506 /*************************************************************************/
512 /* A handle to an object that models a face scaled to a given */
513 /* character size. */
516 /* An @FT_Face has one _active_ @FT_Size object that is used by */
517 /* functions like @FT_Load_Glyph to determine the scaling */
518 /* transformation that in turn is used to load and hint glyphs and */
521 /* You can use @FT_Set_Char_Size, @FT_Set_Pixel_Sizes, */
522 /* @FT_Request_Size or even @FT_Select_Size to change the content */
523 /* (i.e., the scaling values) of the active @FT_Size. */
525 /* You can use @FT_New_Size to create additional size objects for a */
526 /* given @FT_Face, but they won't be used by other functions until */
527 /* you activate it through @FT_Activate_Size. Only one size can be */
528 /* activated at any given time per face. */
531 /* See @FT_SizeRec for the publicly accessible fields of a given size */
534 typedef struct FT_SizeRec_* FT_Size;
537 /*************************************************************************/
543 /* A handle to a given `glyph slot'. A slot is a container that can */
544 /* hold any of the glyphs contained in its parent face. */
546 /* In other words, each time you call @FT_Load_Glyph or */
547 /* @FT_Load_Char, the slot's content is erased by the new glyph data, */
548 /* i.e., the glyph's metrics, its image (bitmap or outline), and */
549 /* other control information. */
552 /* See @FT_GlyphSlotRec for the publicly accessible glyph fields. */
554 typedef struct FT_GlyphSlotRec_* FT_GlyphSlot;
557 /*************************************************************************/
563 /* A handle to a character map (usually abbreviated to `charmap'). A */
564 /* charmap is used to translate character codes in a given encoding */
565 /* into glyph indexes for its parent's face. Some font formats may */
566 /* provide several charmaps per font. */
568 /* Each face object owns zero or more charmaps, but only one of them */
569 /* can be `active', providing the data used by @FT_Get_Char_Index or */
572 /* The list of available charmaps in a face is available through the */
573 /* `face->num_charmaps' and `face->charmaps' fields of @FT_FaceRec. */
575 /* The currently active charmap is available as `face->charmap'. */
576 /* You should call @FT_Set_Charmap to change it. */
579 /* When a new face is created (either through @FT_New_Face or */
580 /* @FT_Open_Face), the library looks for a Unicode charmap within */
581 /* the list and automatically activates it. If there is no Unicode */
582 /* charmap, FreeType doesn't set an `active' charmap. */
585 /* See @FT_CharMapRec for the publicly accessible fields of a given */
588 typedef struct FT_CharMapRec_* FT_CharMap;
591 /*************************************************************************/
597 /* This macro converts four-letter tags into an unsigned long. It is */
598 /* used to define `encoding' identifiers (see @FT_Encoding). */
601 /* Since many 16-bit compilers don't like 32-bit enumerations, you */
602 /* should redefine this macro in case of problems to something like */
606 /* #define FT_ENC_TAG( value, a, b, c, d ) value */
609 /* to get a simple enumeration without assigning special numbers. */
613 #define FT_ENC_TAG( value, a, b, c, d ) \
614 value = ( ( (FT_UInt32)(a) << 24 ) | \
615 ( (FT_UInt32)(b) << 16 ) | \
616 ( (FT_UInt32)(c) << 8 ) | \
619 #endif /* FT_ENC_TAG */
622 /*************************************************************************/
628 /* An enumeration to specify character sets supported by charmaps. */
629 /* Used in the @FT_Select_Charmap API function. */
632 /* Despite the name, this enumeration lists specific character */
633 /* repertories (i.e., charsets), and not text encoding methods (e.g., */
634 /* UTF-8, UTF-16, etc.). */
636 /* Other encodings might be defined in the future. */
639 /* FT_ENCODING_NONE :: */
640 /* The encoding value~0 is reserved. */
642 /* FT_ENCODING_UNICODE :: */
643 /* The Unicode character set. This value covers all versions of */
644 /* the Unicode repertoire, including ASCII and Latin-1. Most fonts */
645 /* include a Unicode charmap, but not all of them. */
647 /* For example, if you want to access Unicode value U+1F028 (and */
648 /* the font contains it), use value 0x1F028 as the input value for */
649 /* @FT_Get_Char_Index. */
651 /* FT_ENCODING_MS_SYMBOL :: */
652 /* Microsoft Symbol encoding, used to encode mathematical symbols */
653 /* and wingdings. For more information, see */
654 /* `https://www.microsoft.com/typography/otspec/recom.htm', */
655 /* `http://www.kostis.net/charsets/symbol.htm', and */
656 /* `http://www.kostis.net/charsets/wingding.htm'. */
658 /* This encoding uses character codes from the PUA (Private Unicode */
659 /* Area) in the range U+F020-U+F0FF. */
661 /* FT_ENCODING_SJIS :: */
662 /* Shift JIS encoding for Japanese. More info at */
663 /* `https://en.wikipedia.org/wiki/Shift_JIS'. See note on */
664 /* multi-byte encodings below. */
666 /* FT_ENCODING_PRC :: */
667 /* Corresponds to encoding systems mainly for Simplified Chinese as */
668 /* used in People's Republic of China (PRC). The encoding layout */
669 /* is based on GB~2312 and its supersets GBK and GB~18030. */
671 /* FT_ENCODING_BIG5 :: */
672 /* Corresponds to an encoding system for Traditional Chinese as */
673 /* used in Taiwan and Hong Kong. */
675 /* FT_ENCODING_WANSUNG :: */
676 /* Corresponds to the Korean encoding system known as Extended */
677 /* Wansung (MS Windows code page 949). */
678 /* For more information see */
679 /* `https://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WindowsBestFit/bestfit949.txt'. */
681 /* FT_ENCODING_JOHAB :: */
682 /* The Korean standard character set (KS~C 5601-1992), which */
683 /* corresponds to MS Windows code page 1361. This character set */
684 /* includes all possible Hangul character combinations. */
686 /* FT_ENCODING_ADOBE_LATIN_1 :: */
687 /* Corresponds to a Latin-1 encoding as defined in a Type~1 */
688 /* PostScript font. It is limited to 256 character codes. */
690 /* FT_ENCODING_ADOBE_STANDARD :: */
691 /* Adobe Standard encoding, as found in Type~1, CFF, and */
692 /* OpenType/CFF fonts. It is limited to 256 character codes. */
694 /* FT_ENCODING_ADOBE_EXPERT :: */
695 /* Adobe Expert encoding, as found in Type~1, CFF, and OpenType/CFF */
696 /* fonts. It is limited to 256 character codes. */
698 /* FT_ENCODING_ADOBE_CUSTOM :: */
699 /* Corresponds to a custom encoding, as found in Type~1, CFF, and */
700 /* OpenType/CFF fonts. It is limited to 256 character codes. */
702 /* FT_ENCODING_APPLE_ROMAN :: */
703 /* Apple roman encoding. Many TrueType and OpenType fonts contain */
704 /* a charmap for this 8-bit encoding, since older versions of Mac */
705 /* OS are able to use it. */
707 /* FT_ENCODING_OLD_LATIN_2 :: */
708 /* This value is deprecated and was neither used nor reported by */
709 /* FreeType. Don't use or test for it. */
711 /* FT_ENCODING_MS_SJIS :: */
712 /* Same as FT_ENCODING_SJIS. Deprecated. */
714 /* FT_ENCODING_MS_GB2312 :: */
715 /* Same as FT_ENCODING_PRC. Deprecated. */
717 /* FT_ENCODING_MS_BIG5 :: */
718 /* Same as FT_ENCODING_BIG5. Deprecated. */
720 /* FT_ENCODING_MS_WANSUNG :: */
721 /* Same as FT_ENCODING_WANSUNG. Deprecated. */
723 /* FT_ENCODING_MS_JOHAB :: */
724 /* Same as FT_ENCODING_JOHAB. Deprecated. */
727 /* By default, FreeType automatically synthesizes a Unicode charmap */
728 /* for PostScript fonts, using their glyph name dictionaries. */
729 /* However, it also reports the encodings defined explicitly in the */
730 /* font file, for the cases when they are needed, with the Adobe */
731 /* values as well. */
733 /* FT_ENCODING_NONE is set by the BDF and PCF drivers if the charmap */
734 /* is neither Unicode nor ISO-8859-1 (otherwise it is set to */
735 /* FT_ENCODING_UNICODE). Use @FT_Get_BDF_Charset_ID to find out */
736 /* which encoding is really present. If, for example, the */
737 /* `cs_registry' field is `KOI8' and the `cs_encoding' field is `R', */
738 /* the font is encoded in KOI8-R. */
740 /* FT_ENCODING_NONE is always set (with a single exception) by the */
741 /* winfonts driver. Use @FT_Get_WinFNT_Header and examine the */
742 /* `charset' field of the @FT_WinFNT_HeaderRec structure to find out */
743 /* which encoding is really present. For example, */
744 /* @FT_WinFNT_ID_CP1251 (204) means Windows code page 1251 (for */
747 /* FT_ENCODING_NONE is set if `platform_id' is @TT_PLATFORM_MACINTOSH */
748 /* and `encoding_id' is not `TT_MAC_ID_ROMAN' (otherwise it is set to */
749 /* FT_ENCODING_APPLE_ROMAN). */
751 /* If `platform_id' is @TT_PLATFORM_MACINTOSH, use the function */
752 /* @FT_Get_CMap_Language_ID to query the Mac language ID that may */
753 /* be needed to be able to distinguish Apple encoding variants. See */
755 /* https://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/Readme.txt */
757 /* to get an idea how to do that. Basically, if the language ID */
758 /* is~0, don't use it, otherwise subtract 1 from the language ID. */
759 /* Then examine `encoding_id'. If, for example, `encoding_id' is */
760 /* `TT_MAC_ID_ROMAN' and the language ID (minus~1) is */
761 /* `TT_MAC_LANGID_GREEK', it is the Greek encoding, not Roman. */
762 /* `TT_MAC_ID_ARABIC' with `TT_MAC_LANGID_FARSI' means the Farsi */
763 /* variant the Arabic encoding. */
765 typedef enum FT_Encoding_
767 FT_ENC_TAG( FT_ENCODING_NONE, 0, 0, 0, 0 ),
769 FT_ENC_TAG( FT_ENCODING_MS_SYMBOL, 's', 'y', 'm', 'b' ),
770 FT_ENC_TAG( FT_ENCODING_UNICODE, 'u', 'n', 'i', 'c' ),
772 FT_ENC_TAG( FT_ENCODING_SJIS, 's', 'j', 'i', 's' ),
773 FT_ENC_TAG( FT_ENCODING_PRC, 'g', 'b', ' ', ' ' ),
774 FT_ENC_TAG( FT_ENCODING_BIG5, 'b', 'i', 'g', '5' ),
775 FT_ENC_TAG( FT_ENCODING_WANSUNG, 'w', 'a', 'n', 's' ),
776 FT_ENC_TAG( FT_ENCODING_JOHAB, 'j', 'o', 'h', 'a' ),
778 /* for backward compatibility */
779 FT_ENCODING_GB2312 = FT_ENCODING_PRC,
780 FT_ENCODING_MS_SJIS = FT_ENCODING_SJIS,
781 FT_ENCODING_MS_GB2312 = FT_ENCODING_PRC,
782 FT_ENCODING_MS_BIG5 = FT_ENCODING_BIG5,
783 FT_ENCODING_MS_WANSUNG = FT_ENCODING_WANSUNG,
784 FT_ENCODING_MS_JOHAB = FT_ENCODING_JOHAB,
786 FT_ENC_TAG( FT_ENCODING_ADOBE_STANDARD, 'A', 'D', 'O', 'B' ),
787 FT_ENC_TAG( FT_ENCODING_ADOBE_EXPERT, 'A', 'D', 'B', 'E' ),
788 FT_ENC_TAG( FT_ENCODING_ADOBE_CUSTOM, 'A', 'D', 'B', 'C' ),
789 FT_ENC_TAG( FT_ENCODING_ADOBE_LATIN_1, 'l', 'a', 't', '1' ),
791 FT_ENC_TAG( FT_ENCODING_OLD_LATIN_2, 'l', 'a', 't', '2' ),
793 FT_ENC_TAG( FT_ENCODING_APPLE_ROMAN, 'a', 'r', 'm', 'n' )
798 /* these constants are deprecated; use the corresponding `FT_Encoding' */
800 #define ft_encoding_none FT_ENCODING_NONE
801 #define ft_encoding_unicode FT_ENCODING_UNICODE
802 #define ft_encoding_symbol FT_ENCODING_MS_SYMBOL
803 #define ft_encoding_latin_1 FT_ENCODING_ADOBE_LATIN_1
804 #define ft_encoding_latin_2 FT_ENCODING_OLD_LATIN_2
805 #define ft_encoding_sjis FT_ENCODING_SJIS
806 #define ft_encoding_gb2312 FT_ENCODING_PRC
807 #define ft_encoding_big5 FT_ENCODING_BIG5
808 #define ft_encoding_wansung FT_ENCODING_WANSUNG
809 #define ft_encoding_johab FT_ENCODING_JOHAB
811 #define ft_encoding_adobe_standard FT_ENCODING_ADOBE_STANDARD
812 #define ft_encoding_adobe_expert FT_ENCODING_ADOBE_EXPERT
813 #define ft_encoding_adobe_custom FT_ENCODING_ADOBE_CUSTOM
814 #define ft_encoding_apple_roman FT_ENCODING_APPLE_ROMAN
817 /*************************************************************************/
823 /* The base charmap structure. */
826 /* face :: A handle to the parent face object. */
828 /* encoding :: An @FT_Encoding tag identifying the charmap. Use */
829 /* this with @FT_Select_Charmap. */
831 /* platform_id :: An ID number describing the platform for the */
832 /* following encoding ID. This comes directly from */
833 /* the TrueType specification and gets emulated for */
836 /* encoding_id :: A platform specific encoding number. This also */
837 /* comes from the TrueType specification and gets */
838 /* emulated similarly. */
840 typedef struct FT_CharMapRec_
843 FT_Encoding encoding;
844 FT_UShort platform_id;
845 FT_UShort encoding_id;
850 /*************************************************************************/
851 /*************************************************************************/
853 /* B A S E O B J E C T C L A S S E S */
855 /*************************************************************************/
856 /*************************************************************************/
859 /*************************************************************************/
862 /* FT_Face_Internal */
865 /* An opaque handle to an `FT_Face_InternalRec' structure that models */
866 /* the private data of a given @FT_Face object. */
868 /* This structure might change between releases of FreeType~2 and is */
869 /* not generally available to client applications. */
871 typedef struct FT_Face_InternalRec_* FT_Face_Internal;
874 /*************************************************************************/
880 /* FreeType root face class structure. A face object models a */
881 /* typeface in a font file. */
884 /* num_faces :: The number of faces in the font file. Some */
885 /* font formats can have multiple faces in */
886 /* a single font file. */
888 /* face_index :: This field holds two different values. */
889 /* Bits 0-15 are the index of the face in the */
890 /* font file (starting with value~0). They */
891 /* are set to~0 if there is only one face in */
894 /* [Since 2.6.1] Bits 16-30 are relevant to GX */
895 /* and OpenType variation fonts only, holding */
896 /* the named instance index for the current */
897 /* face index (starting with value~1; value~0 */
898 /* indicates font access without a named */
899 /* instance). For non-variation fonts, bits */
900 /* 16-30 are ignored. If we have the third */
901 /* named instance of face~4, say, `face_index' */
902 /* is set to 0x00030004. */
904 /* Bit 31 is always zero (this is, */
905 /* `face_index' is always a positive value). */
907 /* [Since 2.9] Changing the design coordinates */
908 /* with @FT_Set_Var_Design_Coordinates or */
909 /* @FT_Set_Var_Blend_Coordinates does not */
910 /* influence the named instance index value */
911 /* (only @FT_Set_Named_Instance does that). */
913 /* face_flags :: A set of bit flags that give important */
914 /* information about the face; see */
915 /* @FT_FACE_FLAG_XXX for the details. */
917 /* style_flags :: The lower 16~bits contain a set of bit */
918 /* flags indicating the style of the face; see */
919 /* @FT_STYLE_FLAG_XXX for the details. */
921 /* [Since 2.6.1] Bits 16-30 hold the number */
922 /* of named instances available for the */
923 /* current face if we have a GX or OpenType */
924 /* variation (sub)font. Bit 31 is always zero */
925 /* (this is, `style_flags' is always a */
926 /* positive value). Note that a variation */
927 /* font has always at least one named */
928 /* instance, namely the default instance. */
930 /* num_glyphs :: The number of glyphs in the face. If the */
931 /* face is scalable and has sbits (see */
932 /* `num_fixed_sizes'), it is set to the number */
933 /* of outline glyphs. */
935 /* For CID-keyed fonts (not in an SFNT */
936 /* wrapper) this value gives the highest CID */
937 /* used in the font. */
939 /* family_name :: The face's family name. This is an ASCII */
940 /* string, usually in English, that describes */
941 /* the typeface's family (like `Times New */
942 /* Roman', `Bodoni', `Garamond', etc). This */
943 /* is a least common denominator used to list */
944 /* fonts. Some formats (TrueType & OpenType) */
945 /* provide localized and Unicode versions of */
946 /* this string. Applications should use the */
947 /* format specific interface to access them. */
948 /* Can be NULL (e.g., in fonts embedded in a */
951 /* In case the font doesn't provide a specific */
952 /* family name entry, FreeType tries to */
953 /* synthesize one, deriving it from other name */
956 /* style_name :: The face's style name. This is an ASCII */
957 /* string, usually in English, that describes */
958 /* the typeface's style (like `Italic', */
959 /* `Bold', `Condensed', etc). Not all font */
960 /* formats provide a style name, so this field */
961 /* is optional, and can be set to NULL. As */
962 /* for `family_name', some formats provide */
963 /* localized and Unicode versions of this */
964 /* string. Applications should use the format */
965 /* specific interface to access them. */
967 /* num_fixed_sizes :: The number of bitmap strikes in the face. */
968 /* Even if the face is scalable, there might */
969 /* still be bitmap strikes, which are called */
970 /* `sbits' in that case. */
972 /* available_sizes :: An array of @FT_Bitmap_Size for all bitmap */
973 /* strikes in the face. It is set to NULL if */
974 /* there is no bitmap strike. */
976 /* Note that FreeType tries to sanitize the */
977 /* strike data since they are sometimes sloppy */
978 /* or incorrect, but this can easily fail. */
980 /* num_charmaps :: The number of charmaps in the face. */
982 /* charmaps :: An array of the charmaps of the face. */
984 /* generic :: A field reserved for client uses. See the */
985 /* @FT_Generic type description. */
987 /* bbox :: The font bounding box. Coordinates are */
988 /* expressed in font units (see */
989 /* `units_per_EM'). The box is large enough */
990 /* to contain any glyph from the font. Thus, */
991 /* `bbox.yMax' can be seen as the `maximum */
992 /* ascender', and `bbox.yMin' as the `minimum */
993 /* descender'. Only relevant for scalable */
996 /* Note that the bounding box might be off by */
997 /* (at least) one pixel for hinted fonts. See */
998 /* @FT_Size_Metrics for further discussion. */
1000 /* units_per_EM :: The number of font units per EM square for */
1001 /* this face. This is typically 2048 for */
1002 /* TrueType fonts, and 1000 for Type~1 fonts. */
1003 /* Only relevant for scalable formats. */
1005 /* ascender :: The typographic ascender of the face, */
1006 /* expressed in font units. For font formats */
1007 /* not having this information, it is set to */
1008 /* `bbox.yMax'. Only relevant for scalable */
1011 /* descender :: The typographic descender of the face, */
1012 /* expressed in font units. For font formats */
1013 /* not having this information, it is set to */
1014 /* `bbox.yMin'. Note that this field is */
1015 /* negative for values below the baseline. */
1016 /* Only relevant for scalable formats. */
1018 /* height :: This value is the vertical distance */
1019 /* between two consecutive baselines, */
1020 /* expressed in font units. It is always */
1021 /* positive. Only relevant for scalable */
1024 /* If you want the global glyph height, use */
1025 /* `ascender - descender'. */
1027 /* max_advance_width :: The maximum advance width, in font units, */
1028 /* for all glyphs in this face. This can be */
1029 /* used to make word wrapping computations */
1030 /* faster. Only relevant for scalable */
1033 /* max_advance_height :: The maximum advance height, in font units, */
1034 /* for all glyphs in this face. This is only */
1035 /* relevant for vertical layouts, and is set */
1036 /* to `height' for fonts that do not provide */
1037 /* vertical metrics. Only relevant for */
1038 /* scalable formats. */
1040 /* underline_position :: The position, in font units, of the */
1041 /* underline line for this face. It is the */
1042 /* center of the underlining stem. Only */
1043 /* relevant for scalable formats. */
1045 /* underline_thickness :: The thickness, in font units, of the */
1046 /* underline for this face. Only relevant for */
1047 /* scalable formats. */
1049 /* glyph :: The face's associated glyph slot(s). */
1051 /* size :: The current active size for this face. */
1053 /* charmap :: The current active charmap for this face. */
1056 /* Fields may be changed after a call to @FT_Attach_File or */
1057 /* @FT_Attach_Stream. */
1059 /* For an OpenType variation font, the values of the following fields */
1060 /* can change after a call to @FT_Set_Var_Design_Coordinates (and */
1061 /* friends) if the font contains an `MVAR' table: `ascender', */
1062 /* `descender', `height', `underline_position', and */
1063 /* `underline_thickness'. */
1065 /* Especially for TrueType fonts see also the documentation for */
1066 /* @FT_Size_Metrics. */
1068 typedef struct FT_FaceRec_
1074 FT_Long style_flags;
1078 FT_String* family_name;
1079 FT_String* style_name;
1081 FT_Int num_fixed_sizes;
1082 FT_Bitmap_Size* available_sizes;
1084 FT_Int num_charmaps;
1085 FT_CharMap* charmaps;
1089 /*# The following member variables (down to `underline_thickness') */
1090 /*# are only relevant to scalable outlines; cf. @FT_Bitmap_Size */
1091 /*# for bitmap fonts. */
1094 FT_UShort units_per_EM;
1099 FT_Short max_advance_width;
1100 FT_Short max_advance_height;
1102 FT_Short underline_position;
1103 FT_Short underline_thickness;
1115 FT_ListRec sizes_list;
1117 FT_Generic autohint; /* face-specific auto-hinter data */
1118 void* extensions; /* unused */
1120 FT_Face_Internal internal;
1127 /*************************************************************************/
1130 /* FT_FACE_FLAG_XXX */
1133 /* A list of bit flags used in the `face_flags' field of the */
1134 /* @FT_FaceRec structure. They inform client applications of */
1135 /* properties of the corresponding face. */
1138 /* FT_FACE_FLAG_SCALABLE :: */
1139 /* The face contains outline glyphs. Note that a face can contain */
1140 /* bitmap strikes also, i.e., a face can have both this flag and */
1141 /* @FT_FACE_FLAG_FIXED_SIZES set. */
1143 /* FT_FACE_FLAG_FIXED_SIZES :: */
1144 /* The face contains bitmap strikes. See also the */
1145 /* `num_fixed_sizes' and `available_sizes' fields of @FT_FaceRec. */
1147 /* FT_FACE_FLAG_FIXED_WIDTH :: */
1148 /* The face contains fixed-width characters (like Courier, Lucida, */
1149 /* MonoType, etc.). */
1151 /* FT_FACE_FLAG_SFNT :: */
1152 /* The face uses the SFNT storage scheme. For now, this means */
1153 /* TrueType and OpenType. */
1155 /* FT_FACE_FLAG_HORIZONTAL :: */
1156 /* The face contains horizontal glyph metrics. This should be set */
1157 /* for all common formats. */
1159 /* FT_FACE_FLAG_VERTICAL :: */
1160 /* The face contains vertical glyph metrics. This is only */
1161 /* available in some formats, not all of them. */
1163 /* FT_FACE_FLAG_KERNING :: */
1164 /* The face contains kerning information. If set, the kerning */
1165 /* distance can be retrieved using the function @FT_Get_Kerning. */
1166 /* Otherwise the function always return the vector (0,0). Note */
1167 /* that FreeType doesn't handle kerning data from the SFNT `GPOS' */
1168 /* table (as present in many OpenType fonts). */
1170 /* FT_FACE_FLAG_FAST_GLYPHS :: */
1171 /* THIS FLAG IS DEPRECATED. DO NOT USE OR TEST IT. */
1173 /* FT_FACE_FLAG_MULTIPLE_MASTERS :: */
1174 /* The face contains multiple masters and is capable of */
1175 /* interpolating between them. Supported formats are Adobe MM, */
1176 /* TrueType GX, and OpenType variation fonts. */
1178 /* See the multiple-masters specific API for details. */
1180 /* FT_FACE_FLAG_GLYPH_NAMES :: */
1181 /* The face contains glyph names, which can be retrieved using */
1182 /* @FT_Get_Glyph_Name. Note that some TrueType fonts contain */
1183 /* broken glyph name tables. Use the function */
1184 /* @FT_Has_PS_Glyph_Names when needed. */
1186 /* FT_FACE_FLAG_EXTERNAL_STREAM :: */
1187 /* Used internally by FreeType to indicate that a face's stream was */
1188 /* provided by the client application and should not be destroyed */
1189 /* when @FT_Done_Face is called. Don't read or test this flag. */
1191 /* FT_FACE_FLAG_HINTER :: */
1192 /* The font driver has a hinting machine of its own. For example, */
1193 /* with TrueType fonts, it makes sense to use data from the SFNT */
1194 /* `gasp' table only if the native TrueType hinting engine (with */
1195 /* the bytecode interpreter) is available and active. */
1197 /* FT_FACE_FLAG_CID_KEYED :: */
1198 /* The face is CID-keyed. In that case, the face is not accessed */
1199 /* by glyph indices but by CID values. For subsetted CID-keyed */
1200 /* fonts this has the consequence that not all index values are a */
1201 /* valid argument to @FT_Load_Glyph. Only the CID values for which */
1202 /* corresponding glyphs in the subsetted font exist make */
1203 /* `FT_Load_Glyph' return successfully; in all other cases you get */
1204 /* an `FT_Err_Invalid_Argument' error. */
1206 /* Note that CID-keyed fonts that are in an SFNT wrapper (this is, */
1207 /* all OpenType/CFF fonts) don't have this flag set since the */
1208 /* glyphs are accessed in the normal way (using contiguous */
1209 /* indices); the `CID-ness' isn't visible to the application. */
1211 /* FT_FACE_FLAG_TRICKY :: */
1212 /* The face is `tricky', this is, it always needs the font format's */
1213 /* native hinting engine to get a reasonable result. A typical */
1214 /* example is the old Chinese font `mingli.ttf' (but not */
1215 /* `mingliu.ttc') that uses TrueType bytecode instructions to move */
1216 /* and scale all of its subglyphs. */
1218 /* It is not possible to auto-hint such fonts using */
1219 /* @FT_LOAD_FORCE_AUTOHINT; it will also ignore */
1220 /* @FT_LOAD_NO_HINTING. You have to set both @FT_LOAD_NO_HINTING */
1221 /* and @FT_LOAD_NO_AUTOHINT to really disable hinting; however, you */
1222 /* probably never want this except for demonstration purposes. */
1224 /* Currently, there are about a dozen TrueType fonts in the list of */
1225 /* tricky fonts; they are hard-coded in file `ttobjs.c'. */
1227 /* FT_FACE_FLAG_COLOR :: */
1228 /* [Since 2.5.1] The face has color glyph tables. To access color */
1229 /* glyphs use @FT_LOAD_COLOR. */
1231 /* FT_FACE_FLAG_VARIATION :: */
1232 /* [Since 2.9] Set if the current face (or named instance) has been */
1233 /* altered with @FT_Set_MM_Design_Coordinates, */
1234 /* @FT_Set_Var_Design_Coordinates, or */
1235 /* @FT_Set_Var_Blend_Coordinates. This flag is unset by a call to */
1236 /* @FT_Set_Named_Instance. */
1238 #define FT_FACE_FLAG_SCALABLE ( 1L << 0 )
1239 #define FT_FACE_FLAG_FIXED_SIZES ( 1L << 1 )
1240 #define FT_FACE_FLAG_FIXED_WIDTH ( 1L << 2 )
1241 #define FT_FACE_FLAG_SFNT ( 1L << 3 )
1242 #define FT_FACE_FLAG_HORIZONTAL ( 1L << 4 )
1243 #define FT_FACE_FLAG_VERTICAL ( 1L << 5 )
1244 #define FT_FACE_FLAG_KERNING ( 1L << 6 )
1245 #define FT_FACE_FLAG_FAST_GLYPHS ( 1L << 7 )
1246 #define FT_FACE_FLAG_MULTIPLE_MASTERS ( 1L << 8 )
1247 #define FT_FACE_FLAG_GLYPH_NAMES ( 1L << 9 )
1248 #define FT_FACE_FLAG_EXTERNAL_STREAM ( 1L << 10 )
1249 #define FT_FACE_FLAG_HINTER ( 1L << 11 )
1250 #define FT_FACE_FLAG_CID_KEYED ( 1L << 12 )
1251 #define FT_FACE_FLAG_TRICKY ( 1L << 13 )
1252 #define FT_FACE_FLAG_COLOR ( 1L << 14 )
1253 #define FT_FACE_FLAG_VARIATION ( 1L << 15 )
1256 /*************************************************************************
1259 * FT_HAS_HORIZONTAL( face )
1262 * A macro that returns true whenever a face object contains
1263 * horizontal metrics (this is true for all font formats though).
1266 * @FT_HAS_VERTICAL can be used to check for vertical metrics.
1269 #define FT_HAS_HORIZONTAL( face ) \
1270 ( (face)->face_flags & FT_FACE_FLAG_HORIZONTAL )
1273 /*************************************************************************
1276 * FT_HAS_VERTICAL( face )
1279 * A macro that returns true whenever a face object contains real
1280 * vertical metrics (and not only synthesized ones).
1283 #define FT_HAS_VERTICAL( face ) \
1284 ( (face)->face_flags & FT_FACE_FLAG_VERTICAL )
1287 /*************************************************************************
1290 * FT_HAS_KERNING( face )
1293 * A macro that returns true whenever a face object contains kerning
1294 * data that can be accessed with @FT_Get_Kerning.
1297 #define FT_HAS_KERNING( face ) \
1298 ( (face)->face_flags & FT_FACE_FLAG_KERNING )
1301 /*************************************************************************
1304 * FT_IS_SCALABLE( face )
1307 * A macro that returns true whenever a face object contains a scalable
1308 * font face (true for TrueType, Type~1, Type~42, CID, OpenType/CFF,
1309 * and PFR font formats).
1312 #define FT_IS_SCALABLE( face ) \
1313 ( (face)->face_flags & FT_FACE_FLAG_SCALABLE )
1316 /*************************************************************************
1319 * FT_IS_SFNT( face )
1322 * A macro that returns true whenever a face object contains a font
1323 * whose format is based on the SFNT storage scheme. This usually
1324 * means: TrueType fonts, OpenType fonts, as well as SFNT-based embedded
1327 * If this macro is true, all functions defined in @FT_SFNT_NAMES_H and
1328 * @FT_TRUETYPE_TABLES_H are available.
1331 #define FT_IS_SFNT( face ) \
1332 ( (face)->face_flags & FT_FACE_FLAG_SFNT )
1335 /*************************************************************************
1338 * FT_IS_FIXED_WIDTH( face )
1341 * A macro that returns true whenever a face object contains a font face
1342 * that contains fixed-width (or `monospace', `fixed-pitch', etc.)
1346 #define FT_IS_FIXED_WIDTH( face ) \
1347 ( (face)->face_flags & FT_FACE_FLAG_FIXED_WIDTH )
1350 /*************************************************************************
1353 * FT_HAS_FIXED_SIZES( face )
1356 * A macro that returns true whenever a face object contains some
1357 * embedded bitmaps. See the `available_sizes' field of the
1358 * @FT_FaceRec structure.
1361 #define FT_HAS_FIXED_SIZES( face ) \
1362 ( (face)->face_flags & FT_FACE_FLAG_FIXED_SIZES )
1365 /*************************************************************************
1368 * FT_HAS_FAST_GLYPHS( face )
1374 #define FT_HAS_FAST_GLYPHS( face ) 0
1377 /*************************************************************************
1380 * FT_HAS_GLYPH_NAMES( face )
1383 * A macro that returns true whenever a face object contains some glyph
1384 * names that can be accessed through @FT_Get_Glyph_Name.
1387 #define FT_HAS_GLYPH_NAMES( face ) \
1388 ( (face)->face_flags & FT_FACE_FLAG_GLYPH_NAMES )
1391 /*************************************************************************
1394 * FT_HAS_MULTIPLE_MASTERS( face )
1397 * A macro that returns true whenever a face object contains some
1398 * multiple masters. The functions provided by @FT_MULTIPLE_MASTERS_H
1399 * are then available to choose the exact design you want.
1402 #define FT_HAS_MULTIPLE_MASTERS( face ) \
1403 ( (face)->face_flags & FT_FACE_FLAG_MULTIPLE_MASTERS )
1406 /*************************************************************************
1409 * FT_IS_NAMED_INSTANCE( face )
1412 * A macro that returns true whenever a face object is a named instance
1413 * of a GX or OpenType variation font.
1415 * [Since 2.9] Changing the design coordinates with
1416 * @FT_Set_Var_Design_Coordinates or @FT_Set_Var_Blend_Coordinates does
1417 * not influence the return value of this macro (only
1418 * @FT_Set_Named_Instance does that).
1424 #define FT_IS_NAMED_INSTANCE( face ) \
1425 ( (face)->face_index & 0x7FFF0000L )
1428 /*************************************************************************
1431 * FT_IS_VARIATION( face )
1434 * A macro that returns true whenever a face object has been altered
1435 * by @FT_Set_MM_Design_Coordinates, @FT_Set_Var_Design_Coordinates, or
1436 * @FT_Set_Var_Blend_Coordinates.
1442 #define FT_IS_VARIATION( face ) \
1443 ( (face)->face_flags & FT_FACE_FLAG_VARIATION )
1446 /*************************************************************************
1449 * FT_IS_CID_KEYED( face )
1452 * A macro that returns true whenever a face object contains a CID-keyed
1453 * font. See the discussion of @FT_FACE_FLAG_CID_KEYED for more
1456 * If this macro is true, all functions defined in @FT_CID_H are
1460 #define FT_IS_CID_KEYED( face ) \
1461 ( (face)->face_flags & FT_FACE_FLAG_CID_KEYED )
1464 /*************************************************************************
1467 * FT_IS_TRICKY( face )
1470 * A macro that returns true whenever a face represents a `tricky' font.
1471 * See the discussion of @FT_FACE_FLAG_TRICKY for more details.
1474 #define FT_IS_TRICKY( face ) \
1475 ( (face)->face_flags & FT_FACE_FLAG_TRICKY )
1478 /*************************************************************************
1481 * FT_HAS_COLOR( face )
1484 * A macro that returns true whenever a face object contains
1485 * tables for color glyphs.
1491 #define FT_HAS_COLOR( face ) \
1492 ( (face)->face_flags & FT_FACE_FLAG_COLOR )
1495 /*************************************************************************/
1498 /* FT_STYLE_FLAG_XXX */
1501 /* A list of bit flags to indicate the style of a given face. These */
1502 /* are used in the `style_flags' field of @FT_FaceRec. */
1505 /* FT_STYLE_FLAG_ITALIC :: */
1506 /* The face style is italic or oblique. */
1508 /* FT_STYLE_FLAG_BOLD :: */
1509 /* The face is bold. */
1512 /* The style information as provided by FreeType is very basic. More */
1513 /* details are beyond the scope and should be done on a higher level */
1514 /* (for example, by analyzing various fields of the `OS/2' table in */
1515 /* SFNT based fonts). */
1517 #define FT_STYLE_FLAG_ITALIC ( 1 << 0 )
1518 #define FT_STYLE_FLAG_BOLD ( 1 << 1 )
1521 /*************************************************************************/
1524 /* FT_Size_Internal */
1527 /* An opaque handle to an `FT_Size_InternalRec' structure, used to */
1528 /* model private data of a given @FT_Size object. */
1530 typedef struct FT_Size_InternalRec_* FT_Size_Internal;
1533 /*************************************************************************/
1536 /* FT_Size_Metrics */
1539 /* The size metrics structure gives the metrics of a size object. */
1542 /* x_ppem :: The width of the scaled EM square in pixels, hence */
1543 /* the term `ppem' (pixels per EM). It is also */
1544 /* referred to as `nominal width'. */
1546 /* y_ppem :: The height of the scaled EM square in pixels, */
1547 /* hence the term `ppem' (pixels per EM). It is also */
1548 /* referred to as `nominal height'. */
1550 /* x_scale :: A 16.16 fractional scaling value to convert */
1551 /* horizontal metrics from font units to 26.6 */
1552 /* fractional pixels. Only relevant for scalable */
1555 /* y_scale :: A 16.16 fractional scaling value to convert */
1556 /* vertical metrics from font units to 26.6 */
1557 /* fractional pixels. Only relevant for scalable */
1560 /* ascender :: The ascender in 26.6 fractional pixels, rounded up */
1561 /* to an integer value. See @FT_FaceRec for the */
1564 /* descender :: The descender in 26.6 fractional pixels, rounded */
1565 /* down to an integer value. See @FT_FaceRec for the */
1568 /* height :: The height in 26.6 fractional pixels, rounded to */
1569 /* an integer value. See @FT_FaceRec for the */
1572 /* max_advance :: The maximum advance width in 26.6 fractional */
1573 /* pixels, rounded to an integer value. See */
1574 /* @FT_FaceRec for the details. */
1577 /* The scaling values, if relevant, are determined first during a */
1578 /* size changing operation. The remaining fields are then set by the */
1579 /* driver. For scalable formats, they are usually set to scaled */
1580 /* values of the corresponding fields in @FT_FaceRec. Some values */
1581 /* like ascender or descender are rounded for historical reasons; */
1582 /* more precise values (for outline fonts) can be derived by scaling */
1583 /* the corresponding @FT_FaceRec values manually, with code similar */
1584 /* to the following. */
1587 /* scaled_ascender = FT_MulFix( face->ascender, */
1588 /* size_metrics->y_scale ); */
1591 /* Note that due to glyph hinting and the selected rendering mode */
1592 /* these values are usually not exact; consequently, they must be */
1593 /* treated as unreliable with an error margin of at least one pixel! */
1595 /* Indeed, the only way to get the exact metrics is to render _all_ */
1596 /* glyphs. As this would be a definite performance hit, it is up to */
1597 /* client applications to perform such computations. */
1599 /* The `FT_Size_Metrics' structure is valid for bitmap fonts also. */
1602 /* *TrueType* *fonts* *with* *native* *bytecode* *hinting* */
1604 /* All applications that handle TrueType fonts with native hinting */
1605 /* must be aware that TTFs expect different rounding of vertical font */
1606 /* dimensions. The application has to cater for this, especially if */
1607 /* it wants to rely on a TTF's vertical data (for example, to */
1608 /* properly align box characters vertically). */
1610 /* Only the application knows _in_ _advance_ that it is going to use */
1611 /* native hinting for TTFs! FreeType, on the other hand, selects the */
1612 /* hinting mode not at the time of creating an @FT_Size object but */
1613 /* much later, namely while calling @FT_Load_Glyph. */
1615 /* Here is some pseudo code that illustrates a possible solution. */
1618 /* font_format = FT_Get_Font_Format( face ); */
1620 /* if ( !strcmp( font_format, "TrueType" ) && */
1621 /* do_native_bytecode_hinting ) */
1623 /* ascender = ROUND( FT_MulFix( face->ascender, */
1624 /* size_metrics->y_scale ) ); */
1625 /* descender = ROUND( FT_MulFix( face->descender, */
1626 /* size_metrics->y_scale ) ); */
1630 /* ascender = size_metrics->ascender; */
1631 /* descender = size_metrics->descender; */
1634 /* height = size_metrics->height; */
1635 /* max_advance = size_metrics->max_advance; */
1638 typedef struct FT_Size_Metrics_
1640 FT_UShort x_ppem; /* horizontal pixels per EM */
1641 FT_UShort y_ppem; /* vertical pixels per EM */
1643 FT_Fixed x_scale; /* scaling values used to convert font */
1644 FT_Fixed y_scale; /* units to 26.6 fractional pixels */
1646 FT_Pos ascender; /* ascender in 26.6 frac. pixels */
1647 FT_Pos descender; /* descender in 26.6 frac. pixels */
1648 FT_Pos height; /* text height in 26.6 frac. pixels */
1649 FT_Pos max_advance; /* max horizontal advance, in 26.6 pixels */
1654 /*************************************************************************/
1660 /* FreeType root size class structure. A size object models a face */
1661 /* object at a given size. */
1664 /* face :: Handle to the parent face object. */
1666 /* generic :: A typeless pointer, unused by the FreeType library or */
1667 /* any of its drivers. It can be used by client */
1668 /* applications to link their own data to each size */
1671 /* metrics :: Metrics for this size object. This field is read-only. */
1673 typedef struct FT_SizeRec_
1675 FT_Face face; /* parent face object */
1676 FT_Generic generic; /* generic pointer for client uses */
1677 FT_Size_Metrics metrics; /* size metrics */
1678 FT_Size_Internal internal;
1683 /*************************************************************************/
1689 /* The subglyph structure is an internal object used to describe */
1690 /* subglyphs (for example, in the case of composites). */
1693 /* The subglyph implementation is not part of the high-level API, */
1694 /* hence the forward structure declaration. */
1696 /* You can however retrieve subglyph information with */
1697 /* @FT_Get_SubGlyph_Info. */
1699 typedef struct FT_SubGlyphRec_* FT_SubGlyph;
1702 /*************************************************************************/
1705 /* FT_Slot_Internal */
1708 /* An opaque handle to an `FT_Slot_InternalRec' structure, used to */
1709 /* model private data of a given @FT_GlyphSlot object. */
1711 typedef struct FT_Slot_InternalRec_* FT_Slot_Internal;
1714 /*************************************************************************/
1717 /* FT_GlyphSlotRec */
1720 /* FreeType root glyph slot class structure. A glyph slot is a */
1721 /* container where individual glyphs can be loaded, be they in */
1722 /* outline or bitmap format. */
1725 /* library :: A handle to the FreeType library instance */
1726 /* this slot belongs to. */
1728 /* face :: A handle to the parent face object. */
1730 /* next :: In some cases (like some font tools), several */
1731 /* glyph slots per face object can be a good */
1732 /* thing. As this is rare, the glyph slots are */
1733 /* listed through a direct, single-linked list */
1734 /* using its `next' field. */
1736 /* generic :: A typeless pointer unused by the FreeType */
1737 /* library or any of its drivers. It can be */
1738 /* used by client applications to link their own */
1739 /* data to each glyph slot object. */
1741 /* metrics :: The metrics of the last loaded glyph in the */
1742 /* slot. The returned values depend on the last */
1743 /* load flags (see the @FT_Load_Glyph API */
1744 /* function) and can be expressed either in 26.6 */
1745 /* fractional pixels or font units. */
1747 /* Note that even when the glyph image is */
1748 /* transformed, the metrics are not. */
1750 /* linearHoriAdvance :: The advance width of the unhinted glyph. */
1751 /* Its value is expressed in 16.16 fractional */
1752 /* pixels, unless @FT_LOAD_LINEAR_DESIGN is set */
1753 /* when loading the glyph. This field can be */
1754 /* important to perform correct WYSIWYG layout. */
1755 /* Only relevant for outline glyphs. */
1757 /* linearVertAdvance :: The advance height of the unhinted glyph. */
1758 /* Its value is expressed in 16.16 fractional */
1759 /* pixels, unless @FT_LOAD_LINEAR_DESIGN is set */
1760 /* when loading the glyph. This field can be */
1761 /* important to perform correct WYSIWYG layout. */
1762 /* Only relevant for outline glyphs. */
1764 /* advance :: This shorthand is, depending on */
1765 /* @FT_LOAD_IGNORE_TRANSFORM, the transformed */
1766 /* (hinted) advance width for the glyph, in 26.6 */
1767 /* fractional pixel format. As specified with */
1768 /* @FT_LOAD_VERTICAL_LAYOUT, it uses either the */
1769 /* `horiAdvance' or the `vertAdvance' value of */
1770 /* `metrics' field. */
1772 /* format :: This field indicates the format of the image */
1773 /* contained in the glyph slot. Typically */
1774 /* @FT_GLYPH_FORMAT_BITMAP, */
1775 /* @FT_GLYPH_FORMAT_OUTLINE, or */
1776 /* @FT_GLYPH_FORMAT_COMPOSITE, but other values */
1779 /* bitmap :: This field is used as a bitmap descriptor. */
1780 /* Note that the address and content of the */
1781 /* bitmap buffer can change between calls of */
1782 /* @FT_Load_Glyph and a few other functions. */
1784 /* bitmap_left :: The bitmap's left bearing expressed in */
1785 /* integer pixels. */
1787 /* bitmap_top :: The bitmap's top bearing expressed in integer */
1788 /* pixels. This is the distance from the */
1789 /* baseline to the top-most glyph scanline, */
1790 /* upwards y~coordinates being *positive*. */
1792 /* outline :: The outline descriptor for the current glyph */
1793 /* image if its format is */
1794 /* @FT_GLYPH_FORMAT_OUTLINE. Once a glyph is */
1795 /* loaded, `outline' can be transformed, */
1796 /* distorted, emboldened, etc. However, it must */
1799 /* num_subglyphs :: The number of subglyphs in a composite glyph. */
1800 /* This field is only valid for the composite */
1801 /* glyph format that should normally only be */
1802 /* loaded with the @FT_LOAD_NO_RECURSE flag. */
1804 /* subglyphs :: An array of subglyph descriptors for */
1805 /* composite glyphs. There are `num_subglyphs' */
1806 /* elements in there. Currently internal to */
1809 /* control_data :: Certain font drivers can also return the */
1810 /* control data for a given glyph image (e.g. */
1811 /* TrueType bytecode, Type~1 charstrings, etc.). */
1812 /* This field is a pointer to such data; it is */
1813 /* currently internal to FreeType. */
1815 /* control_len :: This is the length in bytes of the control */
1816 /* data. Currently internal to FreeType. */
1818 /* other :: Reserved. */
1820 /* lsb_delta :: The difference between hinted and unhinted */
1821 /* left side bearing while auto-hinting is */
1822 /* active. Zero otherwise. */
1824 /* rsb_delta :: The difference between hinted and unhinted */
1825 /* right side bearing while auto-hinting is */
1826 /* active. Zero otherwise. */
1829 /* If @FT_Load_Glyph is called with default flags (see */
1830 /* @FT_LOAD_DEFAULT) the glyph image is loaded in the glyph slot in */
1831 /* its native format (e.g., an outline glyph for TrueType and Type~1 */
1832 /* formats). [Since 2.9] The prospective bitmap metrics are */
1833 /* calculated according to @FT_LOAD_TARGET_XXX and other flags even */
1834 /* for the outline glyph, even if @FT_LOAD_RENDER is not set. */
1836 /* This image can later be converted into a bitmap by calling */
1837 /* @FT_Render_Glyph. This function searches the current renderer for */
1838 /* the native image's format, then invokes it. */
1840 /* The renderer is in charge of transforming the native image through */
1841 /* the slot's face transformation fields, then converting it into a */
1842 /* bitmap that is returned in `slot->bitmap'. */
1844 /* Note that `slot->bitmap_left' and `slot->bitmap_top' are also used */
1845 /* to specify the position of the bitmap relative to the current pen */
1846 /* position (e.g., coordinates (0,0) on the baseline). Of course, */
1847 /* `slot->format' is also changed to @FT_GLYPH_FORMAT_BITMAP. */
1849 /* Here is a small pseudo code fragment that shows how to use */
1850 /* `lsb_delta' and `rsb_delta' to do fractional positioning of */
1854 /* FT_GlyphSlot slot = face->glyph; */
1855 /* FT_Pos origin_x = 0; */
1858 /* for all glyphs do */
1859 /* <load glyph with `FT_Load_Glyph'> */
1861 /* FT_Outline_Translate( slot->outline, origin_x & 63, 0 ); */
1863 /* <save glyph image, or render glyph, or ...> */
1865 /* <compute kern between current and next glyph */
1866 /* and add it to `origin_x'> */
1868 /* origin_x += slot->advance.x; */
1869 /* origin_x += slot->rsb_delta - slot->lsb_delta; */
1873 /* Here is another small pseudo code fragment that shows how to use */
1874 /* `lsb_delta' and `rsb_delta' to improve integer positioning of */
1878 /* FT_GlyphSlot slot = face->glyph; */
1879 /* FT_Pos origin_x = 0; */
1880 /* FT_Pos prev_rsb_delta = 0; */
1883 /* for all glyphs do */
1884 /* <compute kern between current and previous glyph */
1885 /* and add it to `origin_x'> */
1887 /* <load glyph with `FT_Load_Glyph'> */
1889 /* if ( prev_rsb_delta - slot->lsb_delta > 32 ) */
1890 /* origin_x -= 64; */
1891 /* else if ( prev_rsb_delta - slot->lsb_delta < -31 ) */
1892 /* origin_x += 64; */
1894 /* prev_rsb_delta = slot->rsb_delta; */
1896 /* <save glyph image, or render glyph, or ...> */
1898 /* origin_x += slot->advance.x; */
1902 /* If you use strong auto-hinting, you *must* apply these delta */
1903 /* values! Otherwise you will experience far too large inter-glyph */
1904 /* spacing at small rendering sizes in most cases. Note that it */
1905 /* doesn't harm to use the above code for other hinting modes also, */
1906 /* since the delta values are zero then. */
1908 typedef struct FT_GlyphSlotRec_
1913 FT_UInt reserved; /* retained for binary compatibility */
1916 FT_Glyph_Metrics metrics;
1917 FT_Fixed linearHoriAdvance;
1918 FT_Fixed linearVertAdvance;
1921 FT_Glyph_Format format;
1929 FT_UInt num_subglyphs;
1930 FT_SubGlyph subglyphs;
1940 FT_Slot_Internal internal;
1945 /*************************************************************************/
1946 /*************************************************************************/
1948 /* F U N C T I O N S */
1950 /*************************************************************************/
1951 /*************************************************************************/
1954 /*************************************************************************/
1957 /* FT_Init_FreeType */
1960 /* Initialize a new FreeType library object. The set of modules */
1961 /* that are registered by this function is determined at build time. */
1964 /* alibrary :: A handle to a new library object. */
1967 /* FreeType error code. 0~means success. */
1970 /* In case you want to provide your own memory allocating routines, */
1971 /* use @FT_New_Library instead, followed by a call to */
1972 /* @FT_Add_Default_Modules (or a series of calls to @FT_Add_Module) */
1973 /* and @FT_Set_Default_Properties. */
1975 /* See the documentation of @FT_Library and @FT_Face for */
1976 /* multi-threading issues. */
1978 /* If you need reference-counting (cf. @FT_Reference_Library), use */
1979 /* @FT_New_Library and @FT_Done_Library. */
1981 /* If compilation option FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES is */
1982 /* set, this function reads the `FREETYPE_PROPERTIES' environment */
1983 /* variable to control driver properties. See section @properties */
1986 FT_EXPORT( FT_Error )
1987 FT_Init_FreeType( FT_Library *alibrary );
1990 /*************************************************************************/
1993 /* FT_Done_FreeType */
1996 /* Destroy a given FreeType library object and all of its children, */
1997 /* including resources, drivers, faces, sizes, etc. */
2000 /* library :: A handle to the target library object. */
2003 /* FreeType error code. 0~means success. */
2005 FT_EXPORT( FT_Error )
2006 FT_Done_FreeType( FT_Library library );
2009 /*************************************************************************/
2015 /* A list of bit field constants used within the `flags' field of the */
2016 /* @FT_Open_Args structure. */
2019 /* FT_OPEN_MEMORY :: This is a memory-based stream. */
2021 /* FT_OPEN_STREAM :: Copy the stream from the `stream' field. */
2023 /* FT_OPEN_PATHNAME :: Create a new input stream from a C~path */
2026 /* FT_OPEN_DRIVER :: Use the `driver' field. */
2028 /* FT_OPEN_PARAMS :: Use the `num_params' and `params' fields. */
2031 /* The `FT_OPEN_MEMORY', `FT_OPEN_STREAM', and `FT_OPEN_PATHNAME' */
2032 /* flags are mutually exclusive. */
2034 #define FT_OPEN_MEMORY 0x1
2035 #define FT_OPEN_STREAM 0x2
2036 #define FT_OPEN_PATHNAME 0x4
2037 #define FT_OPEN_DRIVER 0x8
2038 #define FT_OPEN_PARAMS 0x10
2041 /* these constants are deprecated; use the corresponding `FT_OPEN_XXX' */
2042 /* values instead */
2043 #define ft_open_memory FT_OPEN_MEMORY
2044 #define ft_open_stream FT_OPEN_STREAM
2045 #define ft_open_pathname FT_OPEN_PATHNAME
2046 #define ft_open_driver FT_OPEN_DRIVER
2047 #define ft_open_params FT_OPEN_PARAMS
2050 /*************************************************************************/
2056 /* A simple structure to pass more or less generic parameters to */
2057 /* @FT_Open_Face and @FT_Face_Properties. */
2060 /* tag :: A four-byte identification tag. */
2062 /* data :: A pointer to the parameter data. */
2065 /* The ID and function of parameters are driver-specific. See the */
2066 /* various FT_PARAM_TAG_XXX flags for more information. */
2068 typedef struct FT_Parameter_
2076 /*************************************************************************/
2082 /* A structure to indicate how to open a new font file or stream. A */
2083 /* pointer to such a structure can be used as a parameter for the */
2084 /* functions @FT_Open_Face and @FT_Attach_Stream. */
2087 /* flags :: A set of bit flags indicating how to use the */
2090 /* memory_base :: The first byte of the file in memory. */
2092 /* memory_size :: The size in bytes of the file in memory. */
2094 /* pathname :: A pointer to an 8-bit file pathname. */
2096 /* stream :: A handle to a source stream object. */
2098 /* driver :: This field is exclusively used by @FT_Open_Face; */
2099 /* it simply specifies the font driver to use for */
2100 /* opening the face. If set to NULL, FreeType tries */
2101 /* to load the face with each one of the drivers in */
2104 /* num_params :: The number of extra parameters. */
2106 /* params :: Extra parameters passed to the font driver when */
2107 /* opening a new face. */
2110 /* The stream type is determined by the contents of `flags' that */
2111 /* are tested in the following order by @FT_Open_Face: */
2113 /* If the @FT_OPEN_MEMORY bit is set, assume that this is a */
2114 /* memory file of `memory_size' bytes, located at `memory_address'. */
2115 /* The data are not copied, and the client is responsible for */
2116 /* releasing and destroying them _after_ the corresponding call to */
2117 /* @FT_Done_Face. */
2119 /* Otherwise, if the @FT_OPEN_STREAM bit is set, assume that a */
2120 /* custom input stream `stream' is used. */
2122 /* Otherwise, if the @FT_OPEN_PATHNAME bit is set, assume that this */
2123 /* is a normal file and use `pathname' to open it. */
2125 /* If the @FT_OPEN_DRIVER bit is set, @FT_Open_Face only tries to */
2126 /* open the file with the driver whose handler is in `driver'. */
2128 /* If the @FT_OPEN_PARAMS bit is set, the parameters given by */
2129 /* `num_params' and `params' is used. They are ignored otherwise. */
2131 /* Ideally, both the `pathname' and `params' fields should be tagged */
2132 /* as `const'; this is missing for API backward compatibility. In */
2133 /* other words, applications should treat them as read-only. */
2135 typedef struct FT_Open_Args_
2138 const FT_Byte* memory_base;
2139 FT_Long memory_size;
2140 FT_String* pathname;
2144 FT_Parameter* params;
2149 /*************************************************************************/
2155 /* Call @FT_Open_Face to open a font by its pathname. */
2158 /* library :: A handle to the library resource. */
2161 /* pathname :: A path to the font file. */
2163 /* face_index :: See @FT_Open_Face for a detailed description of this */
2167 /* aface :: A handle to a new face object. If `face_index' is */
2168 /* greater than or equal to zero, it must be non-NULL. */
2171 /* FreeType error code. 0~means success. */
2174 /* Use @FT_Done_Face to destroy the created @FT_Face object (along */
2175 /* with its slot and sizes). */
2177 FT_EXPORT( FT_Error )
2178 FT_New_Face( FT_Library library,
2179 const char* filepathname,
2184 /*************************************************************************/
2187 /* FT_New_Memory_Face */
2190 /* Call @FT_Open_Face to open a font that has been loaded into */
2194 /* library :: A handle to the library resource. */
2197 /* file_base :: A pointer to the beginning of the font data. */
2199 /* file_size :: The size of the memory chunk used by the font data. */
2201 /* face_index :: See @FT_Open_Face for a detailed description of this */
2205 /* aface :: A handle to a new face object. If `face_index' is */
2206 /* greater than or equal to zero, it must be non-NULL. */
2209 /* FreeType error code. 0~means success. */
2212 /* You must not deallocate the memory before calling @FT_Done_Face. */
2214 FT_EXPORT( FT_Error )
2215 FT_New_Memory_Face( FT_Library library,
2216 const FT_Byte* file_base,
2222 /*************************************************************************/
2228 /* Create a face object from a given resource described by */
2229 /* @FT_Open_Args. */
2232 /* library :: A handle to the library resource. */
2235 /* args :: A pointer to an `FT_Open_Args' structure that must */
2236 /* be filled by the caller. */
2238 /* face_index :: This field holds two different values. Bits 0-15 */
2239 /* are the index of the face in the font file (starting */
2240 /* with value~0). Set it to~0 if there is only one */
2241 /* face in the font file. */
2243 /* [Since 2.6.1] Bits 16-30 are relevant to GX and */
2244 /* OpenType variation fonts only, specifying the named */
2245 /* instance index for the current face index (starting */
2246 /* with value~1; value~0 makes FreeType ignore named */
2247 /* instances). For non-variation fonts, bits 16-30 are */
2248 /* ignored. Assuming that you want to access the third */
2249 /* named instance in face~4, `face_index' should be set */
2250 /* to 0x00030004. If you want to access face~4 without */
2251 /* variation handling, simply set `face_index' to */
2254 /* `FT_Open_Face' and its siblings can be used to */
2255 /* quickly check whether the font format of a given */
2256 /* font resource is supported by FreeType. In general, */
2257 /* if the `face_index' argument is negative, the */
2258 /* function's return value is~0 if the font format is */
2259 /* recognized, or non-zero otherwise. The function */
2260 /* allocates a more or less empty face handle in */
2261 /* `*aface' (if `aface' isn't NULL); the only two */
2262 /* useful fields in this special case are */
2263 /* `face->num_faces' and `face->style_flags'. For any */
2264 /* negative value of `face_index', `face->num_faces' */
2265 /* gives the number of faces within the font file. For */
2266 /* the negative value `-(N+1)' (with `N' a non-negative */
2267 /* 16-bit value), bits 16-30 in `face->style_flags' */
2268 /* give the number of named instances in face `N' if we */
2269 /* have a variation font (or zero otherwise). After */
2270 /* examination, the returned @FT_Face structure should */
2271 /* be deallocated with a call to @FT_Done_Face. */
2274 /* aface :: A handle to a new face object. If `face_index' is */
2275 /* greater than or equal to zero, it must be non-NULL. */
2278 /* FreeType error code. 0~means success. */
2281 /* Unlike FreeType 1.x, this function automatically creates a glyph */
2282 /* slot for the face object that can be accessed directly through */
2283 /* `face->glyph'. */
2285 /* Each new face object created with this function also owns a */
2286 /* default @FT_Size object, accessible as `face->size'. */
2288 /* One @FT_Library instance can have multiple face objects, this is, */
2289 /* @FT_Open_Face and its siblings can be called multiple times using */
2290 /* the same `library' argument. */
2292 /* See the discussion of reference counters in the description of */
2293 /* @FT_Reference_Face. */
2295 /* To loop over all faces, use code similar to the following snippet */
2296 /* (omitting the error handling). */
2301 /* FT_Long i, num_faces; */
2304 /* error = FT_Open_Face( library, args, -1, &face ); */
2305 /* if ( error ) { ... } */
2307 /* num_faces = face->num_faces; */
2308 /* FT_Done_Face( face ); */
2310 /* for ( i = 0; i < num_faces; i++ ) */
2313 /* error = FT_Open_Face( library, args, i, &face ); */
2315 /* FT_Done_Face( face ); */
2320 /* To loop over all valid values for `face_index', use something */
2321 /* similar to the following snippet, again without error handling. */
2322 /* The code accesses all faces immediately (thus only a single call */
2323 /* of `FT_Open_Face' within the do-loop), with and without named */
2330 /* FT_Long num_faces = 0; */
2331 /* FT_Long num_instances = 0; */
2333 /* FT_Long face_idx = 0; */
2334 /* FT_Long instance_idx = 0; */
2339 /* FT_Long id = ( instance_idx << 16 ) + face_idx; */
2342 /* error = FT_Open_Face( library, args, id, &face ); */
2343 /* if ( error ) { ... } */
2345 /* num_faces = face->num_faces; */
2346 /* num_instances = face->style_flags >> 16; */
2350 /* FT_Done_Face( face ); */
2352 /* if ( instance_idx < num_instances ) */
2353 /* instance_idx++; */
2357 /* instance_idx = 0; */
2360 /* } while ( face_idx < num_faces ) */
2363 FT_EXPORT( FT_Error )
2364 FT_Open_Face( FT_Library library,
2365 const FT_Open_Args* args,
2370 /*************************************************************************/
2373 /* FT_Attach_File */
2376 /* Call @FT_Attach_Stream to attach a file. */
2379 /* face :: The target face object. */
2382 /* filepathname :: The pathname. */
2385 /* FreeType error code. 0~means success. */
2387 FT_EXPORT( FT_Error )
2388 FT_Attach_File( FT_Face face,
2389 const char* filepathname );
2392 /*************************************************************************/
2395 /* FT_Attach_Stream */
2398 /* `Attach' data to a face object. Normally, this is used to read */
2399 /* additional information for the face object. For example, you can */
2400 /* attach an AFM file that comes with a Type~1 font to get the */
2401 /* kerning values and other metrics. */
2404 /* face :: The target face object. */
2407 /* parameters :: A pointer to @FT_Open_Args that must be filled by */
2411 /* FreeType error code. 0~means success. */
2414 /* The meaning of the `attach' (i.e., what really happens when the */
2415 /* new file is read) is not fixed by FreeType itself. It really */
2416 /* depends on the font format (and thus the font driver). */
2418 /* Client applications are expected to know what they are doing */
2419 /* when invoking this function. Most drivers simply do not implement */
2420 /* file or stream attachments. */
2422 FT_EXPORT( FT_Error )
2423 FT_Attach_Stream( FT_Face face,
2424 FT_Open_Args* parameters );
2427 /*************************************************************************/
2430 /* FT_Reference_Face */
2433 /* A counter gets initialized to~1 at the time an @FT_Face structure */
2434 /* is created. This function increments the counter. @FT_Done_Face */
2435 /* then only destroys a face if the counter is~1, otherwise it simply */
2436 /* decrements the counter. */
2438 /* This function helps in managing life-cycles of structures that */
2439 /* reference @FT_Face objects. */
2442 /* face :: A handle to a target face object. */
2445 /* FreeType error code. 0~means success. */
2450 FT_EXPORT( FT_Error )
2451 FT_Reference_Face( FT_Face face );
2454 /*************************************************************************/
2460 /* Discard a given face object, as well as all of its child slots and */
2464 /* face :: A handle to a target face object. */
2467 /* FreeType error code. 0~means success. */
2470 /* See the discussion of reference counters in the description of */
2471 /* @FT_Reference_Face. */
2473 FT_EXPORT( FT_Error )
2474 FT_Done_Face( FT_Face face );
2477 /*************************************************************************/
2480 /* FT_Select_Size */
2483 /* Select a bitmap strike. To be more precise, this function sets */
2484 /* the scaling factors of the active @FT_Size object in a face so */
2485 /* that bitmaps from this particular strike are taken by */
2486 /* @FT_Load_Glyph and friends. */
2489 /* face :: A handle to a target face object. */
2492 /* strike_index :: The index of the bitmap strike in the */
2493 /* `available_sizes' field of @FT_FaceRec structure. */
2496 /* FreeType error code. 0~means success. */
2499 /* For bitmaps embedded in outline fonts it is common that only a */
2500 /* subset of the available glyphs at a given ppem value is available. */
2501 /* FreeType silently uses outlines if there is no bitmap for a given */
2504 /* For GX and OpenType variation fonts, a bitmap strike makes sense */
2505 /* only if the default instance is active (this is, no glyph */
2506 /* variation takes place); otherwise, FreeType simply ignores bitmap */
2507 /* strikes. The same is true for all named instances that are */
2508 /* different from the default instance. */
2510 /* Don't use this function if you are using the FreeType cache API. */
2512 FT_EXPORT( FT_Error )
2513 FT_Select_Size( FT_Face face,
2514 FT_Int strike_index );
2517 /*************************************************************************/
2520 /* FT_Size_Request_Type */
2523 /* An enumeration type that lists the supported size request types, */
2524 /* i.e., what input size (in font units) maps to the requested output */
2525 /* size (in pixels, as computed from the arguments of */
2526 /* @FT_Size_Request). */
2529 /* FT_SIZE_REQUEST_TYPE_NOMINAL :: */
2530 /* The nominal size. The `units_per_EM' field of @FT_FaceRec is */
2531 /* used to determine both scaling values. */
2533 /* This is the standard scaling found in most applications. In */
2534 /* particular, use this size request type for TrueType fonts if */
2535 /* they provide optical scaling or something similar. Note, */
2536 /* however, that `units_per_EM' is a rather abstract value which */
2537 /* bears no relation to the actual size of the glyphs in a font. */
2539 /* FT_SIZE_REQUEST_TYPE_REAL_DIM :: */
2540 /* The real dimension. The sum of the `ascender' and (minus of) */
2541 /* the `descender' fields of @FT_FaceRec is used to determine both */
2542 /* scaling values. */
2544 /* FT_SIZE_REQUEST_TYPE_BBOX :: */
2545 /* The font bounding box. The width and height of the `bbox' field */
2546 /* of @FT_FaceRec are used to determine the horizontal and vertical */
2547 /* scaling value, respectively. */
2549 /* FT_SIZE_REQUEST_TYPE_CELL :: */
2550 /* The `max_advance_width' field of @FT_FaceRec is used to */
2551 /* determine the horizontal scaling value; the vertical scaling */
2552 /* value is determined the same way as */
2553 /* @FT_SIZE_REQUEST_TYPE_REAL_DIM does. Finally, both scaling */
2554 /* values are set to the smaller one. This type is useful if you */
2555 /* want to specify the font size for, say, a window of a given */
2556 /* dimension and 80x24 cells. */
2558 /* FT_SIZE_REQUEST_TYPE_SCALES :: */
2559 /* Specify the scaling values directly. */
2562 /* The above descriptions only apply to scalable formats. For bitmap */
2563 /* formats, the behaviour is up to the driver. */
2565 /* See the note section of @FT_Size_Metrics if you wonder how size */
2566 /* requesting relates to scaling values. */
2568 typedef enum FT_Size_Request_Type_
2570 FT_SIZE_REQUEST_TYPE_NOMINAL,
2571 FT_SIZE_REQUEST_TYPE_REAL_DIM,
2572 FT_SIZE_REQUEST_TYPE_BBOX,
2573 FT_SIZE_REQUEST_TYPE_CELL,
2574 FT_SIZE_REQUEST_TYPE_SCALES,
2576 FT_SIZE_REQUEST_TYPE_MAX
2578 } FT_Size_Request_Type;
2581 /*************************************************************************/
2584 /* FT_Size_RequestRec */
2587 /* A structure to model a size request. */
2590 /* type :: See @FT_Size_Request_Type. */
2592 /* width :: The desired width, given as a 26.6 fractional */
2593 /* point value (with 72pt = 1in). */
2595 /* height :: The desired height, given as a 26.6 fractional */
2596 /* point value (with 72pt = 1in). */
2598 /* horiResolution :: The horizontal resolution (dpi, i.e., pixels per */
2599 /* inch). If set to zero, `width' is treated as a */
2600 /* 26.6 fractional *pixel* value, which gets */
2601 /* internally rounded to an integer. */
2603 /* vertResolution :: The vertical resolution (dpi, i.e., pixels per */
2604 /* inch). If set to zero, `height' is treated as a */
2605 /* 26.6 fractional *pixel* value, which gets */
2606 /* internally rounded to an integer. */
2609 /* If `width' is zero, the horizontal scaling value is set equal */
2610 /* to the vertical scaling value, and vice versa. */
2612 /* If `type' is FT_SIZE_REQUEST_TYPE_SCALES, `width' and `height' are */
2613 /* interpreted directly as 16.16 fractional scaling values, without */
2614 /* any further modification, and both `horiResolution' and */
2615 /* `vertResolution' are ignored. */
2617 typedef struct FT_Size_RequestRec_
2619 FT_Size_Request_Type type;
2622 FT_UInt horiResolution;
2623 FT_UInt vertResolution;
2625 } FT_Size_RequestRec;
2628 /*************************************************************************/
2631 /* FT_Size_Request */
2634 /* A handle to a size request structure. */
2636 typedef struct FT_Size_RequestRec_ *FT_Size_Request;
2639 /*************************************************************************/
2642 /* FT_Request_Size */
2645 /* Resize the scale of the active @FT_Size object in a face. */
2648 /* face :: A handle to a target face object. */
2651 /* req :: A pointer to a @FT_Size_RequestRec. */
2654 /* FreeType error code. 0~means success. */
2657 /* Although drivers may select the bitmap strike matching the */
2658 /* request, you should not rely on this if you intend to select a */
2659 /* particular bitmap strike. Use @FT_Select_Size instead in that */
2662 /* The relation between the requested size and the resulting glyph */
2663 /* size is dependent entirely on how the size is defined in the */
2664 /* source face. The font designer chooses the final size of each */
2665 /* glyph relative to this size. For more information refer to */
2666 /* `https://www.freetype.org/freetype2/docs/glyphs/glyphs-2.html'. */
2668 /* Contrary to @FT_Set_Char_Size, this function doesn't have special */
2669 /* code to normalize zero-valued widths, heights, or resolutions */
2670 /* (which lead to errors in most cases). */
2672 /* Don't use this function if you are using the FreeType cache API. */
2674 FT_EXPORT( FT_Error )
2675 FT_Request_Size( FT_Face face,
2676 FT_Size_Request req );
2679 /*************************************************************************/
2682 /* FT_Set_Char_Size */
2685 /* Call @FT_Request_Size to request the nominal size (in points). */
2688 /* face :: A handle to a target face object. */
2691 /* char_width :: The nominal width, in 26.6 fractional points. */
2693 /* char_height :: The nominal height, in 26.6 fractional points. */
2695 /* horz_resolution :: The horizontal resolution in dpi. */
2697 /* vert_resolution :: The vertical resolution in dpi. */
2700 /* FreeType error code. 0~means success. */
2703 /* While this function allows fractional points as input values, the */
2704 /* resulting ppem value for the given resolution is always rounded to */
2705 /* the nearest integer. */
2707 /* If either the character width or height is zero, it is set equal */
2708 /* to the other value. */
2710 /* If either the horizontal or vertical resolution is zero, it is set */
2711 /* equal to the other value. */
2713 /* A character width or height smaller than 1pt is set to 1pt; if */
2714 /* both resolution values are zero, they are set to 72dpi. */
2716 /* Don't use this function if you are using the FreeType cache API. */
2718 FT_EXPORT( FT_Error )
2719 FT_Set_Char_Size( FT_Face face,
2720 FT_F26Dot6 char_width,
2721 FT_F26Dot6 char_height,
2722 FT_UInt horz_resolution,
2723 FT_UInt vert_resolution );
2726 /*************************************************************************/
2729 /* FT_Set_Pixel_Sizes */
2732 /* Call @FT_Request_Size to request the nominal size (in pixels). */
2735 /* face :: A handle to the target face object. */
2738 /* pixel_width :: The nominal width, in pixels. */
2740 /* pixel_height :: The nominal height, in pixels. */
2743 /* FreeType error code. 0~means success. */
2746 /* You should not rely on the resulting glyphs matching or being */
2747 /* constrained to this pixel size. Refer to @FT_Request_Size to */
2748 /* understand how requested sizes relate to actual sizes. */
2750 /* Don't use this function if you are using the FreeType cache API. */
2752 FT_EXPORT( FT_Error )
2753 FT_Set_Pixel_Sizes( FT_Face face,
2754 FT_UInt pixel_width,
2755 FT_UInt pixel_height );
2758 /*************************************************************************/
2764 /* Load a glyph into the glyph slot of a face object. */
2767 /* face :: A handle to the target face object where the glyph */
2771 /* glyph_index :: The index of the glyph in the font file. For */
2772 /* CID-keyed fonts (either in PS or in CFF format) */
2773 /* this argument specifies the CID value. */
2775 /* load_flags :: A flag indicating what to load for this glyph. The */
2776 /* @FT_LOAD_XXX constants can be used to control the */
2777 /* glyph loading process (e.g., whether the outline */
2778 /* should be scaled, whether to load bitmaps or not, */
2779 /* whether to hint the outline, etc). */
2782 /* FreeType error code. 0~means success. */
2785 /* The loaded glyph may be transformed. See @FT_Set_Transform for */
2788 /* For subsetted CID-keyed fonts, `FT_Err_Invalid_Argument' is */
2789 /* returned for invalid CID values (this is, for CID values that */
2790 /* don't have a corresponding glyph in the font). See the discussion */
2791 /* of the @FT_FACE_FLAG_CID_KEYED flag for more details. */
2793 /* If you receive `FT_Err_Glyph_Too_Big', try getting the glyph */
2794 /* outline at EM size, then scale it manually and fill it as a */
2795 /* graphics operation. */
2797 FT_EXPORT( FT_Error )
2798 FT_Load_Glyph( FT_Face face,
2799 FT_UInt glyph_index,
2800 FT_Int32 load_flags );
2803 /*************************************************************************/
2809 /* Load a glyph into the glyph slot of a face object, accessed by its */
2810 /* character code. */
2813 /* face :: A handle to a target face object where the glyph */
2817 /* char_code :: The glyph's character code, according to the */
2818 /* current charmap used in the face. */
2820 /* load_flags :: A flag indicating what to load for this glyph. The */
2821 /* @FT_LOAD_XXX constants can be used to control the */
2822 /* glyph loading process (e.g., whether the outline */
2823 /* should be scaled, whether to load bitmaps or not, */
2824 /* whether to hint the outline, etc). */
2827 /* FreeType error code. 0~means success. */
2830 /* This function simply calls @FT_Get_Char_Index and @FT_Load_Glyph. */
2832 /* Many fonts contain glyphs that can't be loaded by this function */
2833 /* since its glyph indices are not listed in any of the font's */
2836 FT_EXPORT( FT_Error )
2837 FT_Load_Char( FT_Face face,
2839 FT_Int32 load_flags );
2842 /*************************************************************************
2848 * A list of bit field constants for @FT_Load_Glyph to indicate what
2849 * kind of operations to perform during glyph loading.
2852 * FT_LOAD_DEFAULT ::
2853 * Corresponding to~0, this value is used as the default glyph load
2854 * operation. In this case, the following happens:
2856 * 1. FreeType looks for a bitmap for the glyph corresponding to the
2857 * face's current size. If one is found, the function returns.
2858 * The bitmap data can be accessed from the glyph slot (see note
2861 * 2. If no embedded bitmap is searched for or found, FreeType looks
2862 * for a scalable outline. If one is found, it is loaded from
2863 * the font file, scaled to device pixels, then `hinted' to the
2864 * pixel grid in order to optimize it. The outline data can be
2865 * accessed from the glyph slot (see note below).
2867 * Note that by default the glyph loader doesn't render outlines into
2868 * bitmaps. The following flags are used to modify this default
2869 * behaviour to more specific and useful cases.
2871 * FT_LOAD_NO_SCALE ::
2872 * Don't scale the loaded outline glyph but keep it in font units.
2874 * This flag implies @FT_LOAD_NO_HINTING and @FT_LOAD_NO_BITMAP, and
2875 * unsets @FT_LOAD_RENDER.
2877 * If the font is `tricky' (see @FT_FACE_FLAG_TRICKY for more), using
2878 * FT_LOAD_NO_SCALE usually yields meaningless outlines because the
2879 * subglyphs must be scaled and positioned with hinting instructions.
2880 * This can be solved by loading the font without FT_LOAD_NO_SCALE and
2881 * setting the character size to `font->units_per_EM'.
2883 * FT_LOAD_NO_HINTING ::
2884 * Disable hinting. This generally generates `blurrier' bitmap glyphs
2885 * when the glyph are rendered in any of the anti-aliased modes. See
2886 * also the note below.
2888 * This flag is implied by @FT_LOAD_NO_SCALE.
2891 * Call @FT_Render_Glyph after the glyph is loaded. By default, the
2892 * glyph is rendered in @FT_RENDER_MODE_NORMAL mode. This can be
2893 * overridden by @FT_LOAD_TARGET_XXX or @FT_LOAD_MONOCHROME.
2895 * This flag is unset by @FT_LOAD_NO_SCALE.
2897 * FT_LOAD_NO_BITMAP ::
2898 * Ignore bitmap strikes when loading. Bitmap-only fonts ignore this
2901 * @FT_LOAD_NO_SCALE always sets this flag.
2903 * FT_LOAD_VERTICAL_LAYOUT ::
2904 * Load the glyph for vertical text layout. In particular, the
2905 * `advance' value in the @FT_GlyphSlotRec structure is set to the
2906 * `vertAdvance' value of the `metrics' field.
2908 * In case @FT_HAS_VERTICAL doesn't return true, you shouldn't use
2909 * this flag currently. Reason is that in this case vertical metrics
2910 * get synthesized, and those values are not always consistent across
2911 * various font formats.
2913 * FT_LOAD_FORCE_AUTOHINT ::
2914 * Prefer the auto-hinter over the font's native hinter. See also
2917 * FT_LOAD_PEDANTIC ::
2918 * Make the font driver perform pedantic verifications during glyph
2919 * loading. This is mostly used to detect broken glyphs in fonts.
2920 * By default, FreeType tries to handle broken fonts also.
2922 * In particular, errors from the TrueType bytecode engine are not
2923 * passed to the application if this flag is not set; this might
2924 * result in partially hinted or distorted glyphs in case a glyph's
2925 * bytecode is buggy.
2927 * FT_LOAD_NO_RECURSE ::
2928 * Don't load composite glyphs recursively. Instead, the font
2929 * driver should set the `num_subglyph' and `subglyphs' values of
2930 * the glyph slot accordingly, and set `glyph->format' to
2931 * @FT_GLYPH_FORMAT_COMPOSITE. The description of subglyphs can
2932 * then be accessed with @FT_Get_SubGlyph_Info.
2934 * This flag implies @FT_LOAD_NO_SCALE and @FT_LOAD_IGNORE_TRANSFORM.
2936 * FT_LOAD_IGNORE_TRANSFORM ::
2937 * Ignore the transform matrix set by @FT_Set_Transform.
2939 * FT_LOAD_MONOCHROME ::
2940 * This flag is used with @FT_LOAD_RENDER to indicate that you want to
2941 * render an outline glyph to a 1-bit monochrome bitmap glyph, with
2942 * 8~pixels packed into each byte of the bitmap data.
2944 * Note that this has no effect on the hinting algorithm used. You
2945 * should rather use @FT_LOAD_TARGET_MONO so that the
2946 * monochrome-optimized hinting algorithm is used.
2948 * FT_LOAD_LINEAR_DESIGN ::
2949 * Keep `linearHoriAdvance' and `linearVertAdvance' fields of
2950 * @FT_GlyphSlotRec in font units. See @FT_GlyphSlotRec for
2953 * FT_LOAD_NO_AUTOHINT ::
2954 * Disable the auto-hinter. See also the note below.
2957 * [Since 2.5] Load embedded color bitmap images. The resulting color
2958 * bitmaps, if available, will have the @FT_PIXEL_MODE_BGRA format.
2959 * If the flag is not set and color bitmaps are found, they are
2960 * converted to 256-level gray bitmaps transparently, using the
2961 * @FT_PIXEL_MODE_GRAY format.
2963 * FT_LOAD_COMPUTE_METRICS ::
2964 * [Since 2.6.1] Compute glyph metrics from the glyph data, without
2965 * the use of bundled metrics tables (for example, the `hdmx' table in
2966 * TrueType fonts). This flag is mainly used by font validating or
2967 * font editing applications, which need to ignore, verify, or edit
2970 * Currently, this flag is only implemented for TrueType fonts.
2972 * FT_LOAD_BITMAP_METRICS_ONLY ::
2973 * [Since 2.7.1] Request loading of the metrics and bitmap image
2974 * information of a (possibly embedded) bitmap glyph without
2975 * allocating or copying the bitmap image data itself. No effect if
2976 * the target glyph is not a bitmap image.
2978 * This flag unsets @FT_LOAD_RENDER.
2980 * FT_LOAD_CROP_BITMAP ::
2981 * Ignored. Deprecated.
2983 * FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ::
2984 * Ignored. Deprecated.
2987 * By default, hinting is enabled and the font's native hinter (see
2988 * @FT_FACE_FLAG_HINTER) is preferred over the auto-hinter. You can
2989 * disable hinting by setting @FT_LOAD_NO_HINTING or change the
2990 * precedence by setting @FT_LOAD_FORCE_AUTOHINT. You can also set
2991 * @FT_LOAD_NO_AUTOHINT in case you don't want the auto-hinter to be
2994 * See the description of @FT_FACE_FLAG_TRICKY for a special exception
2995 * (affecting only a handful of Asian fonts).
2997 * Besides deciding which hinter to use, you can also decide which
2998 * hinting algorithm to use. See @FT_LOAD_TARGET_XXX for details.
3000 * Note that the auto-hinter needs a valid Unicode cmap (either a native
3001 * one or synthesized by FreeType) for producing correct results. If a
3002 * font provides an incorrect mapping (for example, assigning the
3003 * character code U+005A, LATIN CAPITAL LETTER Z, to a glyph depicting a
3004 * mathematical integral sign), the auto-hinter might produce useless
3008 #define FT_LOAD_DEFAULT 0x0
3009 #define FT_LOAD_NO_SCALE ( 1L << 0 )
3010 #define FT_LOAD_NO_HINTING ( 1L << 1 )
3011 #define FT_LOAD_RENDER ( 1L << 2 )
3012 #define FT_LOAD_NO_BITMAP ( 1L << 3 )
3013 #define FT_LOAD_VERTICAL_LAYOUT ( 1L << 4 )
3014 #define FT_LOAD_FORCE_AUTOHINT ( 1L << 5 )
3015 #define FT_LOAD_CROP_BITMAP ( 1L << 6 )
3016 #define FT_LOAD_PEDANTIC ( 1L << 7 )
3017 #define FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ( 1L << 9 )
3018 #define FT_LOAD_NO_RECURSE ( 1L << 10 )
3019 #define FT_LOAD_IGNORE_TRANSFORM ( 1L << 11 )
3020 #define FT_LOAD_MONOCHROME ( 1L << 12 )
3021 #define FT_LOAD_LINEAR_DESIGN ( 1L << 13 )
3022 #define FT_LOAD_NO_AUTOHINT ( 1L << 15 )
3023 /* Bits 16-19 are used by `FT_LOAD_TARGET_' */
3024 #define FT_LOAD_COLOR ( 1L << 20 )
3025 #define FT_LOAD_COMPUTE_METRICS ( 1L << 21 )
3026 #define FT_LOAD_BITMAP_METRICS_ONLY ( 1L << 22 )
3030 /* used internally only by certain font drivers */
3031 #define FT_LOAD_ADVANCE_ONLY ( 1L << 8 )
3032 #define FT_LOAD_SBITS_ONLY ( 1L << 14 )
3035 /**************************************************************************
3038 * FT_LOAD_TARGET_XXX
3041 * A list of values to select a specific hinting algorithm for the
3042 * hinter. You should OR one of these values to your `load_flags'
3043 * when calling @FT_Load_Glyph.
3045 * Note that a font's native hinters may ignore the hinting algorithm
3046 * you have specified (e.g., the TrueType bytecode interpreter). You
3047 * can set @FT_LOAD_FORCE_AUTOHINT to ensure that the auto-hinter is
3051 * FT_LOAD_TARGET_NORMAL ::
3052 * The default hinting algorithm, optimized for standard gray-level
3053 * rendering. For monochrome output, use @FT_LOAD_TARGET_MONO
3056 * FT_LOAD_TARGET_LIGHT ::
3057 * A lighter hinting algorithm for gray-level modes. Many generated
3058 * glyphs are fuzzier but better resemble their original shape. This
3059 * is achieved by snapping glyphs to the pixel grid only vertically
3060 * (Y-axis), as is done by FreeType's new CFF engine or Microsoft's
3061 * ClearType font renderer. This preserves inter-glyph spacing in
3062 * horizontal text. The snapping is done either by the native font
3063 * driver, if the driver itself and the font support it, or by the
3066 * Advance widths are rounded to integer values; however, using the
3067 * `lsb_delta' and `rsb_delta' fields of @FT_GlyphSlotRec, it is
3068 * possible to get fractional advance widths for sub-pixel positioning
3069 * (which is recommended to use).
3071 * If configuration option AF_CONFIG_OPTION_TT_SIZE_METRICS is active,
3072 * TrueType-like metrics are used to make this mode behave similarly
3073 * as in unpatched FreeType versions between 2.4.6 and 2.7.1
3076 * FT_LOAD_TARGET_MONO ::
3077 * Strong hinting algorithm that should only be used for monochrome
3078 * output. The result is probably unpleasant if the glyph is rendered
3079 * in non-monochrome modes.
3081 * FT_LOAD_TARGET_LCD ::
3082 * A variant of @FT_LOAD_TARGET_LIGHT optimized for horizontally
3083 * decimated LCD displays.
3085 * FT_LOAD_TARGET_LCD_V ::
3086 * A variant of @FT_LOAD_TARGET_NORMAL optimized for vertically
3087 * decimated LCD displays.
3090 * You should use only _one_ of the FT_LOAD_TARGET_XXX values in your
3091 * `load_flags'. They can't be ORed.
3093 * If @FT_LOAD_RENDER is also set, the glyph is rendered in the
3094 * corresponding mode (i.e., the mode that matches the used algorithm
3095 * best). An exception is FT_LOAD_TARGET_MONO since it implies
3096 * @FT_LOAD_MONOCHROME.
3098 * You can use a hinting algorithm that doesn't correspond to the same
3099 * rendering mode. As an example, it is possible to use the `light'
3100 * hinting algorithm and have the results rendered in horizontal LCD
3101 * pixel mode, with code like
3104 * FT_Load_Glyph( face, glyph_index,
3105 * load_flags | FT_LOAD_TARGET_LIGHT );
3107 * FT_Render_Glyph( face->glyph, FT_RENDER_MODE_LCD );
3110 * In general, you should stick with one rendering mode. For example,
3111 * switching between @FT_LOAD_TARGET_NORMAL and @FT_LOAD_TARGET_MONO
3112 * enforces a lot of recomputation for TrueType fonts, which is slow.
3113 * Another reason is caching: Selecting a different mode usually causes
3114 * changes in both the outlines and the rasterized bitmaps; it is thus
3115 * necessary to empty the cache after a mode switch to avoid false hits.
3118 #define FT_LOAD_TARGET_( x ) ( (FT_Int32)( (x) & 15 ) << 16 )
3120 #define FT_LOAD_TARGET_NORMAL FT_LOAD_TARGET_( FT_RENDER_MODE_NORMAL )
3121 #define FT_LOAD_TARGET_LIGHT FT_LOAD_TARGET_( FT_RENDER_MODE_LIGHT )
3122 #define FT_LOAD_TARGET_MONO FT_LOAD_TARGET_( FT_RENDER_MODE_MONO )
3123 #define FT_LOAD_TARGET_LCD FT_LOAD_TARGET_( FT_RENDER_MODE_LCD )
3124 #define FT_LOAD_TARGET_LCD_V FT_LOAD_TARGET_( FT_RENDER_MODE_LCD_V )
3127 /**************************************************************************
3130 * FT_LOAD_TARGET_MODE
3133 * Return the @FT_Render_Mode corresponding to a given
3134 * @FT_LOAD_TARGET_XXX value.
3137 #define FT_LOAD_TARGET_MODE( x ) ( (FT_Render_Mode)( ( (x) >> 16 ) & 15 ) )
3140 /*************************************************************************/
3143 /* FT_Set_Transform */
3146 /* Set the transformation that is applied to glyph images when they */
3147 /* are loaded into a glyph slot through @FT_Load_Glyph. */
3150 /* face :: A handle to the source face object. */
3153 /* matrix :: A pointer to the transformation's 2x2 matrix. Use NULL */
3154 /* for the identity matrix. */
3155 /* delta :: A pointer to the translation vector. Use NULL for the */
3159 /* The transformation is only applied to scalable image formats after */
3160 /* the glyph has been loaded. It means that hinting is unaltered by */
3161 /* the transformation and is performed on the character size given in */
3162 /* the last call to @FT_Set_Char_Size or @FT_Set_Pixel_Sizes. */
3164 /* Note that this also transforms the `face.glyph.advance' field, but */
3165 /* *not* the values in `face.glyph.metrics'. */
3168 FT_Set_Transform( FT_Face face,
3173 /*************************************************************************/
3176 /* FT_Render_Mode */
3179 /* Render modes supported by FreeType~2. Each mode corresponds to a */
3180 /* specific type of scanline conversion performed on the outline. */
3182 /* For bitmap fonts and embedded bitmaps the `bitmap->pixel_mode' */
3183 /* field in the @FT_GlyphSlotRec structure gives the format of the */
3184 /* returned bitmap. */
3186 /* All modes except @FT_RENDER_MODE_MONO use 256 levels of opacity, */
3187 /* indicating pixel coverage. Use linear alpha blending and gamma */
3188 /* correction to correctly render non-monochrome glyph bitmaps onto a */
3189 /* surface; see @FT_Render_Glyph. */
3192 /* FT_RENDER_MODE_NORMAL :: */
3193 /* Default render mode; it corresponds to 8-bit anti-aliased */
3196 /* FT_RENDER_MODE_LIGHT :: */
3197 /* This is equivalent to @FT_RENDER_MODE_NORMAL. It is only */
3198 /* defined as a separate value because render modes are also used */
3199 /* indirectly to define hinting algorithm selectors. See */
3200 /* @FT_LOAD_TARGET_XXX for details. */
3202 /* FT_RENDER_MODE_MONO :: */
3203 /* This mode corresponds to 1-bit bitmaps (with 2~levels of */
3206 /* FT_RENDER_MODE_LCD :: */
3207 /* This mode corresponds to horizontal RGB and BGR sub-pixel */
3208 /* displays like LCD screens. It produces 8-bit bitmaps that are */
3209 /* 3~times the width of the original glyph outline in pixels, and */
3210 /* which use the @FT_PIXEL_MODE_LCD mode. */
3212 /* FT_RENDER_MODE_LCD_V :: */
3213 /* This mode corresponds to vertical RGB and BGR sub-pixel displays */
3214 /* (like PDA screens, rotated LCD displays, etc.). It produces */
3215 /* 8-bit bitmaps that are 3~times the height of the original */
3216 /* glyph outline in pixels and use the @FT_PIXEL_MODE_LCD_V mode. */
3219 /* Should you define FT_CONFIG_OPTION_SUBPIXEL_RENDERING in your */
3220 /* `ftoption.h', which enables patented ClearType-style rendering, */
3221 /* the LCD-optimized glyph bitmaps should be filtered to reduce color */
3222 /* fringes inherent to this technology. You can either set up LCD */
3223 /* filtering with @FT_Library_SetLcdFilter or @FT_Face_Properties, */
3224 /* or do the filtering yourself. The default FreeType LCD rendering */
3225 /* technology does not require filtering. */
3227 /* The selected render mode only affects vector glyphs of a font. */
3228 /* Embedded bitmaps often have a different pixel mode like */
3229 /* @FT_PIXEL_MODE_MONO. You can use @FT_Bitmap_Convert to transform */
3230 /* them into 8-bit pixmaps. */
3232 typedef enum FT_Render_Mode_
3234 FT_RENDER_MODE_NORMAL = 0,
3235 FT_RENDER_MODE_LIGHT,
3236 FT_RENDER_MODE_MONO,
3238 FT_RENDER_MODE_LCD_V,
3245 /* these constants are deprecated; use the corresponding */
3246 /* `FT_Render_Mode' values instead */
3247 #define ft_render_mode_normal FT_RENDER_MODE_NORMAL
3248 #define ft_render_mode_mono FT_RENDER_MODE_MONO
3251 /*************************************************************************/
3254 /* FT_Render_Glyph */
3257 /* Convert a given glyph image to a bitmap. It does so by inspecting */
3258 /* the glyph image format, finding the relevant renderer, and */
3262 /* slot :: A handle to the glyph slot containing the image to */
3266 /* render_mode :: The render mode used to render the glyph image into */
3267 /* a bitmap. See @FT_Render_Mode for a list of */
3268 /* possible values. */
3271 /* FreeType error code. 0~means success. */
3274 /* To get meaningful results, font scaling values must be set with */
3275 /* functions like @FT_Set_Char_Size before calling `FT_Render_Glyph'. */
3277 /* When FreeType outputs a bitmap of a glyph, it really outputs an */
3278 /* alpha coverage map. If a pixel is completely covered by a */
3279 /* filled-in outline, the bitmap contains 0xFF at that pixel, meaning */
3280 /* that 0xFF/0xFF fraction of that pixel is covered, meaning the */
3281 /* pixel is 100% black (or 0% bright). If a pixel is only 50% */
3282 /* covered (value 0x80), the pixel is made 50% black (50% bright or a */
3283 /* middle shade of grey). 0% covered means 0% black (100% bright or */
3286 /* On high-DPI screens like on smartphones and tablets, the pixels */
3287 /* are so small that their chance of being completely covered and */
3288 /* therefore completely black are fairly good. On the low-DPI */
3289 /* screens, however, the situation is different. The pixels are too */
3290 /* large for most of the details of a glyph and shades of gray are */
3291 /* the norm rather than the exception. */
3293 /* This is relevant because all our screens have a second problem: */
3294 /* they are not linear. 1~+~1 is not~2. Twice the value does not */
3295 /* result in twice the brightness. When a pixel is only 50% covered, */
3296 /* the coverage map says 50% black, and this translates to a pixel */
3297 /* value of 128 when you use 8~bits per channel (0-255). However, */
3298 /* this does not translate to 50% brightness for that pixel on our */
3299 /* sRGB and gamma~2.2 screens. Due to their non-linearity, they */
3300 /* dwell longer in the darks and only a pixel value of about 186 */
3301 /* results in 50% brightness -- 128 ends up too dark on both bright */
3302 /* and dark backgrounds. The net result is that dark text looks */
3303 /* burnt-out, pixely and blotchy on bright background, bright text */
3304 /* too frail on dark backgrounds, and colored text on colored */
3305 /* background (for example, red on green) seems to have dark halos or */
3306 /* `dirt' around it. The situation is especially ugly for diagonal */
3307 /* stems like in `w' glyph shapes where the quality of FreeType's */
3308 /* anti-aliasing depends on the correct display of grays. On */
3309 /* high-DPI screens where smaller, fully black pixels reign supreme, */
3310 /* this doesn't matter, but on our low-DPI screens with all the gray */
3311 /* shades, it does. 0% and 100% brightness are the same things in */
3312 /* linear and non-linear space, just all the shades in-between */
3315 /* The blending function for placing text over a background is */
3318 /* dst = alpha * src + (1 - alpha) * dst , */
3321 /* which is known as the OVER operator. */
3323 /* To correctly composite an antialiased pixel of a glyph onto a */
3326 /* 1. take the foreground and background colors (e.g., in sRGB space) */
3327 /* and apply gamma to get them in a linear space, */
3329 /* 2. use OVER to blend the two linear colors using the glyph pixel */
3330 /* as the alpha value (remember, the glyph bitmap is an alpha */
3331 /* coverage bitmap), and */
3333 /* 3. apply inverse gamma to the blended pixel and write it back to */
3336 /* Internal testing at Adobe found that a target inverse gamma of~1.8 */
3337 /* for step~3 gives good results across a wide range of displays with */
3338 /* an sRGB gamma curve or a similar one. */
3340 /* This process can cost performance. There is an approximation that */
3341 /* does not need to know about the background color; see */
3342 /* https://bel.fi/alankila/lcd/ and */
3343 /* https://bel.fi/alankila/lcd/alpcor.html for details. */
3345 /* *ATTENTION*: Linear blending is even more important when dealing */
3346 /* with subpixel-rendered glyphs to prevent color-fringing! A */
3347 /* subpixel-rendered glyph must first be filtered with a filter that */
3348 /* gives equal weight to the three color primaries and does not */
3349 /* exceed a sum of 0x100, see section @lcd_filtering. Then the */
3350 /* only difference to gray linear blending is that subpixel-rendered */
3351 /* linear blending is done 3~times per pixel: red foreground subpixel */
3352 /* to red background subpixel and so on for green and blue. */
3354 FT_EXPORT( FT_Error )
3355 FT_Render_Glyph( FT_GlyphSlot slot,
3356 FT_Render_Mode render_mode );
3359 /*************************************************************************/
3362 /* FT_Kerning_Mode */
3365 /* An enumeration to specify the format of kerning values returned by */
3366 /* @FT_Get_Kerning. */
3369 /* FT_KERNING_DEFAULT :: Return grid-fitted kerning distances in */
3370 /* 26.6 fractional pixels. */
3372 /* FT_KERNING_UNFITTED :: Return un-grid-fitted kerning distances in */
3373 /* 26.6 fractional pixels. */
3375 /* FT_KERNING_UNSCALED :: Return the kerning vector in original font */
3379 /* FT_KERNING_DEFAULT returns full pixel values; it also makes */
3380 /* FreeType heuristically scale down kerning distances at small ppem */
3381 /* values so that they don't become too big. */
3383 /* Both FT_KERNING_DEFAULT and FT_KERNING_UNFITTED use the current */
3384 /* horizontal scaling factor (as set e.g. with @FT_Set_Char_Size) to */
3385 /* convert font units to pixels. */
3387 typedef enum FT_Kerning_Mode_
3389 FT_KERNING_DEFAULT = 0,
3390 FT_KERNING_UNFITTED,
3396 /* these constants are deprecated; use the corresponding */
3397 /* `FT_Kerning_Mode' values instead */
3398 #define ft_kerning_default FT_KERNING_DEFAULT
3399 #define ft_kerning_unfitted FT_KERNING_UNFITTED
3400 #define ft_kerning_unscaled FT_KERNING_UNSCALED
3403 /*************************************************************************/
3406 /* FT_Get_Kerning */
3409 /* Return the kerning vector between two glyphs of the same face. */
3412 /* face :: A handle to a source face object. */
3414 /* left_glyph :: The index of the left glyph in the kern pair. */
3416 /* right_glyph :: The index of the right glyph in the kern pair. */
3418 /* kern_mode :: See @FT_Kerning_Mode for more information. */
3419 /* Determines the scale and dimension of the returned */
3420 /* kerning vector. */
3423 /* akerning :: The kerning vector. This is either in font units, */
3424 /* fractional pixels (26.6 format), or pixels for */
3425 /* scalable formats, and in pixels for fixed-sizes */
3429 /* FreeType error code. 0~means success. */
3432 /* Only horizontal layouts (left-to-right & right-to-left) are */
3433 /* supported by this method. Other layouts, or more sophisticated */
3434 /* kernings, are out of the scope of this API function -- they can be */
3435 /* implemented through format-specific interfaces. */
3437 /* Kerning for OpenType fonts implemented in a `GPOS' table is not */
3438 /* supported; use @FT_HAS_KERNING to find out whether a font has data */
3439 /* that can be extracted with `FT_Get_Kerning'. */
3441 FT_EXPORT( FT_Error )
3442 FT_Get_Kerning( FT_Face face,
3444 FT_UInt right_glyph,
3446 FT_Vector *akerning );
3449 /*************************************************************************/
3452 /* FT_Get_Track_Kerning */
3455 /* Return the track kerning for a given face object at a given size. */
3458 /* face :: A handle to a source face object. */
3460 /* point_size :: The point size in 16.16 fractional points. */
3462 /* degree :: The degree of tightness. Increasingly negative */
3463 /* values represent tighter track kerning, while */
3464 /* increasingly positive values represent looser track */
3465 /* kerning. Value zero means no track kerning. */
3468 /* akerning :: The kerning in 16.16 fractional points, to be */
3469 /* uniformly applied between all glyphs. */
3472 /* FreeType error code. 0~means success. */
3475 /* Currently, only the Type~1 font driver supports track kerning, */
3476 /* using data from AFM files (if attached with @FT_Attach_File or */
3477 /* @FT_Attach_Stream). */
3479 /* Only very few AFM files come with track kerning data; please refer */
3480 /* to Adobe's AFM specification for more details. */
3482 FT_EXPORT( FT_Error )
3483 FT_Get_Track_Kerning( FT_Face face,
3484 FT_Fixed point_size,
3486 FT_Fixed* akerning );
3489 /*************************************************************************/
3492 /* FT_Get_Glyph_Name */
3495 /* Retrieve the ASCII name of a given glyph in a face. This only */
3496 /* works for those faces where @FT_HAS_GLYPH_NAMES(face) returns~1. */
3499 /* face :: A handle to a source face object. */
3501 /* glyph_index :: The glyph index. */
3503 /* buffer_max :: The maximum number of bytes available in the */
3507 /* buffer :: A pointer to a target buffer where the name is */
3511 /* FreeType error code. 0~means success. */
3514 /* An error is returned if the face doesn't provide glyph names or if */
3515 /* the glyph index is invalid. In all cases of failure, the first */
3516 /* byte of `buffer' is set to~0 to indicate an empty name. */
3518 /* The glyph name is truncated to fit within the buffer if it is too */
3519 /* long. The returned string is always zero-terminated. */
3521 /* Be aware that FreeType reorders glyph indices internally so that */
3522 /* glyph index~0 always corresponds to the `missing glyph' (called */
3525 /* This function always returns an error if the config macro */
3526 /* `FT_CONFIG_OPTION_NO_GLYPH_NAMES' is not defined in `ftoption.h'. */
3528 FT_EXPORT( FT_Error )
3529 FT_Get_Glyph_Name( FT_Face face,
3530 FT_UInt glyph_index,
3532 FT_UInt buffer_max );
3535 /*************************************************************************/
3538 /* FT_Get_Postscript_Name */
3541 /* Retrieve the ASCII PostScript name of a given face, if available. */
3542 /* This only works with PostScript, TrueType, and OpenType fonts. */
3545 /* face :: A handle to the source face object. */
3548 /* A pointer to the face's PostScript name. NULL if unavailable. */
3551 /* The returned pointer is owned by the face and is destroyed with */
3554 /* For variation fonts, this string changes if you select a different */
3555 /* instance, and you have to call `FT_Get_PostScript_Name' again to */
3556 /* retrieve it. FreeType follows Adobe TechNote #5902, `Generating */
3557 /* PostScript Names for Fonts Using OpenType Font Variations'. */
3559 /* https://download.macromedia.com/pub/developer/opentype/tech-notes/5902.AdobePSNameGeneration.html */
3561 /* [Since 2.9] Special PostScript names for named instances are only */
3562 /* returned if the named instance is set with @FT_Set_Named_Instance */
3563 /* (and the font has corresponding entries in its `fvar' table). If */
3564 /* @FT_IS_VARIATION returns true, the algorithmically derived */
3565 /* PostScript name is provided, not looking up special entries for */
3566 /* named instances. */
3568 FT_EXPORT( const char* )
3569 FT_Get_Postscript_Name( FT_Face face );
3572 /*************************************************************************/
3575 /* FT_Select_Charmap */
3578 /* Select a given charmap by its encoding tag (as listed in */
3579 /* `freetype.h'). */
3582 /* face :: A handle to the source face object. */
3585 /* encoding :: A handle to the selected encoding. */
3588 /* FreeType error code. 0~means success. */
3591 /* This function returns an error if no charmap in the face */
3592 /* corresponds to the encoding queried here. */
3594 /* Because many fonts contain more than a single cmap for Unicode */
3595 /* encoding, this function has some special code to select the one */
3596 /* that covers Unicode best (`best' in the sense that a UCS-4 cmap is */
3597 /* preferred to a UCS-2 cmap). It is thus preferable to */
3598 /* @FT_Set_Charmap in this case. */
3600 FT_EXPORT( FT_Error )
3601 FT_Select_Charmap( FT_Face face,
3602 FT_Encoding encoding );
3605 /*************************************************************************/
3608 /* FT_Set_Charmap */
3611 /* Select a given charmap for character code to glyph index mapping. */
3614 /* face :: A handle to the source face object. */
3617 /* charmap :: A handle to the selected charmap. */
3620 /* FreeType error code. 0~means success. */
3623 /* This function returns an error if the charmap is not part of */
3624 /* the face (i.e., if it is not listed in the `face->charmaps' */
3627 /* It also fails if an OpenType type~14 charmap is selected (which */
3628 /* doesn't map character codes to glyph indices at all). */
3630 FT_EXPORT( FT_Error )
3631 FT_Set_Charmap( FT_Face face,
3632 FT_CharMap charmap );
3635 /*************************************************************************
3638 * FT_Get_Charmap_Index
3641 * Retrieve index of a given charmap.
3645 * A handle to a charmap.
3648 * The index into the array of character maps within the face to which
3649 * `charmap' belongs. If an error occurs, -1 is returned.
3653 FT_Get_Charmap_Index( FT_CharMap charmap );
3656 /*************************************************************************/
3659 /* FT_Get_Char_Index */
3662 /* Return the glyph index of a given character code. This function */
3663 /* uses the currently selected charmap to do the mapping. */
3666 /* face :: A handle to the source face object. */
3668 /* charcode :: The character code. */
3671 /* The glyph index. 0~means `undefined character code'. */
3674 /* If you use FreeType to manipulate the contents of font files */
3675 /* directly, be aware that the glyph index returned by this function */
3676 /* doesn't always correspond to the internal indices used within the */
3677 /* file. This is done to ensure that value~0 always corresponds to */
3678 /* the `missing glyph'. If the first glyph is not named `.notdef', */
3679 /* then for Type~1 and Type~42 fonts, `.notdef' will be moved into */
3680 /* the glyph ID~0 position, and whatever was there will be moved to */
3681 /* the position `.notdef' had. For Type~1 fonts, if there is no */
3682 /* `.notdef' glyph at all, then one will be created at index~0 and */
3683 /* whatever was there will be moved to the last index -- Type~42 */
3684 /* fonts are considered invalid under this condition. */
3686 FT_EXPORT( FT_UInt )
3687 FT_Get_Char_Index( FT_Face face,
3688 FT_ULong charcode );
3691 /*************************************************************************/
3694 /* FT_Get_First_Char */
3697 /* Return the first character code in the current charmap of a given */
3698 /* face, together with its corresponding glyph index. */
3701 /* face :: A handle to the source face object. */
3704 /* agindex :: Glyph index of first character code. 0~if charmap is */
3708 /* The charmap's first character code. */
3711 /* You should use this function together with @FT_Get_Next_Char to */
3712 /* parse all character codes available in a given charmap. The code */
3713 /* should look like this: */
3716 /* FT_ULong charcode; */
3717 /* FT_UInt gindex; */
3720 /* charcode = FT_Get_First_Char( face, &gindex ); */
3721 /* while ( gindex != 0 ) */
3723 /* ... do something with (charcode,gindex) pair ... */
3725 /* charcode = FT_Get_Next_Char( face, charcode, &gindex ); */
3729 /* Be aware that character codes can have values up to 0xFFFFFFFF; */
3730 /* this might happen for non-Unicode or malformed cmaps. However, */
3731 /* even with regular Unicode encoding, so-called `last resort fonts' */
3732 /* (using SFNT cmap format 13, see function @FT_Get_CMap_Format) */
3733 /* normally have entries for all Unicode characters up to 0x1FFFFF, */
3734 /* which can cause *a lot* of iterations. */
3736 /* Note that `*agindex' is set to~0 if the charmap is empty. The */
3737 /* result itself can be~0 in two cases: if the charmap is empty or */
3738 /* if the value~0 is the first valid character code. */
3740 FT_EXPORT( FT_ULong )
3741 FT_Get_First_Char( FT_Face face,
3745 /*************************************************************************/
3748 /* FT_Get_Next_Char */
3751 /* Return the next character code in the current charmap of a given */
3752 /* face following the value `char_code', as well as the corresponding */
3756 /* face :: A handle to the source face object. */
3758 /* char_code :: The starting character code. */
3761 /* agindex :: Glyph index of next character code. 0~if charmap */
3765 /* The charmap's next character code. */
3768 /* You should use this function with @FT_Get_First_Char to walk */
3769 /* over all character codes available in a given charmap. See the */
3770 /* note for that function for a simple code example. */
3772 /* Note that `*agindex' is set to~0 when there are no more codes in */
3775 FT_EXPORT( FT_ULong )
3776 FT_Get_Next_Char( FT_Face face,
3781 /*************************************************************************
3784 * FT_Face_Properties
3787 * Set or override certain (library or module-wide) properties on a
3788 * face-by-face basis. Useful for finer-grained control and avoiding
3789 * locks on shared structures (threads can modify their own faces as
3792 * Contrary to @FT_Property_Set, this function uses @FT_Parameter so
3793 * that you can pass multiple properties to the target face in one call.
3794 * Note that only a subset of the available properties can be
3797 * * @FT_PARAM_TAG_STEM_DARKENING (stem darkening, corresponding to the
3798 * property `no-stem-darkening' provided by the `autofit', `cff',
3799 * `type1', and `t1cid' modules; see @no-stem-darkening).
3801 * * @FT_PARAM_TAG_LCD_FILTER_WEIGHTS (LCD filter weights, corresponding
3802 * to function @FT_Library_SetLcdFilterWeights).
3804 * * @FT_PARAM_TAG_RANDOM_SEED (seed value for the CFF, Type~1, and CID
3805 * `random' operator, corresponding to the `random-seed' property
3806 * provided by the `cff', `type1', and `t1cid' modules; see
3809 * Pass NULL as `data' in @FT_Parameter for a given tag to reset the
3810 * option and use the library or module default again.
3814 * A handle to the source face object.
3817 * The number of properties that follow.
3820 * A handle to an @FT_Parameter array with `num_properties' elements.
3823 * FreeType error code. 0~means success.
3826 * Here an example that sets three properties. You must define
3827 * FT_CONFIG_OPTION_SUBPIXEL_RENDERING to make the LCD filter examples
3831 * FT_Parameter property1;
3832 * FT_Bool darken_stems = 1;
3834 * FT_Parameter property2;
3835 * FT_LcdFiveTapFilter custom_weight =
3836 * { 0x11, 0x44, 0x56, 0x44, 0x11 };
3838 * FT_Parameter property3;
3839 * FT_Int32 random_seed = 314159265;
3841 * FT_Parameter properties[3] = { property1,
3846 * property1.tag = FT_PARAM_TAG_STEM_DARKENING;
3847 * property1.data = &darken_stems;
3849 * property2.tag = FT_PARAM_TAG_LCD_FILTER_WEIGHTS;
3850 * property2.data = custom_weight;
3852 * property3.tag = FT_PARAM_TAG_RANDOM_SEED;
3853 * property3.data = &random_seed;
3855 * FT_Face_Properties( face, 3, properties );
3858 * The next example resets a single property to its default value.
3861 * FT_Parameter property;
3864 * property.tag = FT_PARAM_TAG_LCD_FILTER_WEIGHTS;
3865 * property.data = NULL;
3867 * FT_Face_Properties( face, 1, &property );
3874 FT_EXPORT( FT_Error )
3875 FT_Face_Properties( FT_Face face,
3876 FT_UInt num_properties,
3877 FT_Parameter* properties );
3880 /*************************************************************************/
3883 /* FT_Get_Name_Index */
3886 /* Return the glyph index of a given glyph name. */
3889 /* face :: A handle to the source face object. */
3891 /* glyph_name :: The glyph name. */
3894 /* The glyph index. 0~means `undefined character code'. */
3896 FT_EXPORT( FT_UInt )
3897 FT_Get_Name_Index( FT_Face face,
3898 FT_String* glyph_name );
3901 /*************************************************************************
3904 * FT_SUBGLYPH_FLAG_XXX
3907 * A list of constants describing subglyphs. Please refer to the
3908 * `glyf' table description in the OpenType specification for the
3909 * meaning of the various flags (which get synthesized for
3910 * non-OpenType subglyphs).
3913 * FT_SUBGLYPH_FLAG_ARGS_ARE_WORDS ::
3914 * FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES ::
3915 * FT_SUBGLYPH_FLAG_ROUND_XY_TO_GRID ::
3916 * FT_SUBGLYPH_FLAG_SCALE ::
3917 * FT_SUBGLYPH_FLAG_XY_SCALE ::
3918 * FT_SUBGLYPH_FLAG_2X2 ::
3919 * FT_SUBGLYPH_FLAG_USE_MY_METRICS ::
3922 #define FT_SUBGLYPH_FLAG_ARGS_ARE_WORDS 1
3923 #define FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES 2
3924 #define FT_SUBGLYPH_FLAG_ROUND_XY_TO_GRID 4
3925 #define FT_SUBGLYPH_FLAG_SCALE 8
3926 #define FT_SUBGLYPH_FLAG_XY_SCALE 0x40
3927 #define FT_SUBGLYPH_FLAG_2X2 0x80
3928 #define FT_SUBGLYPH_FLAG_USE_MY_METRICS 0x200
3931 /*************************************************************************
3934 * FT_Get_SubGlyph_Info
3937 * Retrieve a description of a given subglyph. Only use it if
3938 * `glyph->format' is @FT_GLYPH_FORMAT_COMPOSITE; an error is
3939 * returned otherwise.
3943 * The source glyph slot.
3946 * The index of the subglyph. Must be less than
3947 * `glyph->num_subglyphs'.
3951 * The glyph index of the subglyph.
3954 * The subglyph flags, see @FT_SUBGLYPH_FLAG_XXX.
3957 * The subglyph's first argument (if any).
3960 * The subglyph's second argument (if any).
3963 * The subglyph transformation (if any).
3966 * FreeType error code. 0~means success.
3969 * The values of `*p_arg1', `*p_arg2', and `*p_transform' must be
3970 * interpreted depending on the flags returned in `*p_flags'. See the
3971 * OpenType specification for details.
3974 FT_EXPORT( FT_Error )
3975 FT_Get_SubGlyph_Info( FT_GlyphSlot glyph,
3981 FT_Matrix *p_transform );
3984 /*************************************************************************/
3990 /* A list of bit flags used in the `fsType' field of the OS/2 table */
3991 /* in a TrueType or OpenType font and the `FSType' entry in a */
3992 /* PostScript font. These bit flags are returned by */
3993 /* @FT_Get_FSType_Flags; they inform client applications of embedding */
3994 /* and subsetting restrictions associated with a font. */
3997 /* https://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/FontPolicies.pdf */
3998 /* for more details. */
4001 /* FT_FSTYPE_INSTALLABLE_EMBEDDING :: */
4002 /* Fonts with no fsType bit set may be embedded and permanently */
4003 /* installed on the remote system by an application. */
4005 /* FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING :: */
4006 /* Fonts that have only this bit set must not be modified, embedded */
4007 /* or exchanged in any manner without first obtaining permission of */
4008 /* the font software copyright owner. */
4010 /* FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING :: */
4011 /* The font may be embedded and temporarily loaded on the remote */
4012 /* system. Documents containing Preview & Print fonts must be */
4013 /* opened `read-only'; no edits can be applied to the document. */
4015 /* FT_FSTYPE_EDITABLE_EMBEDDING :: */
4016 /* The font may be embedded but must only be installed temporarily */
4017 /* on other systems. In contrast to Preview & Print fonts, */
4018 /* documents containing editable fonts may be opened for reading, */
4019 /* editing is permitted, and changes may be saved. */
4021 /* FT_FSTYPE_NO_SUBSETTING :: */
4022 /* The font may not be subsetted prior to embedding. */
4024 /* FT_FSTYPE_BITMAP_EMBEDDING_ONLY :: */
4025 /* Only bitmaps contained in the font may be embedded; no outline */
4026 /* data may be embedded. If there are no bitmaps available in the */
4027 /* font, then the font is unembeddable. */
4030 /* The flags are ORed together, thus more than a single value can be */
4033 /* While the `fsType' flags can indicate that a font may be embedded, */
4034 /* a license with the font vendor may be separately required to use */
4035 /* the font in this way. */
4037 #define FT_FSTYPE_INSTALLABLE_EMBEDDING 0x0000
4038 #define FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING 0x0002
4039 #define FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING 0x0004
4040 #define FT_FSTYPE_EDITABLE_EMBEDDING 0x0008
4041 #define FT_FSTYPE_NO_SUBSETTING 0x0100
4042 #define FT_FSTYPE_BITMAP_EMBEDDING_ONLY 0x0200
4045 /*************************************************************************/
4048 /* FT_Get_FSType_Flags */
4051 /* Return the `fsType' flags for a font. */
4054 /* face :: A handle to the source face object. */
4057 /* The `fsType' flags, see @FT_FSTYPE_XXX. */
4060 /* Use this function rather than directly reading the `fs_type' field */
4061 /* in the @PS_FontInfoRec structure, which is only guaranteed to */
4062 /* return the correct results for Type~1 fonts. */
4067 FT_EXPORT( FT_UShort )
4068 FT_Get_FSType_Flags( FT_Face face );
4071 /*************************************************************************/
4074 /* glyph_variants */
4077 /* Unicode Variation Sequences */
4080 /* The FreeType~2 interface to Unicode Variation Sequences (UVS), */
4081 /* using the SFNT cmap format~14. */
4084 /* Many characters, especially for CJK scripts, have variant forms. */
4085 /* They are a sort of grey area somewhere between being totally */
4086 /* irrelevant and semantically distinct; for this reason, the Unicode */
4087 /* consortium decided to introduce Variation Sequences (VS), */
4088 /* consisting of a Unicode base character and a variation selector */
4089 /* instead of further extending the already huge number of */
4092 /* Unicode maintains two different sets, namely `Standardized */
4093 /* Variation Sequences' and registered `Ideographic Variation */
4094 /* Sequences' (IVS), collected in the `Ideographic Variation */
4095 /* Database' (IVD). */
4097 /* https://unicode.org/Public/UCD/latest/ucd/StandardizedVariants.txt */
4098 /* https://unicode.org/reports/tr37/ */
4099 /* https://unicode.org/ivd/ */
4101 /* To date (January 2017), the character with the most ideographic */
4102 /* variations is U+9089, having 32 such IVS. */
4104 /* Three Mongolian Variation Selectors have the values U+180B-U+180D; */
4105 /* 256 generic Variation Selectors are encoded in the ranges */
4106 /* U+FE00-U+FE0F and U+E0100-U+E01EF. IVS currently use Variation */
4107 /* Selectors from the range U+E0100-U+E01EF only. */
4109 /* A VS consists of the base character value followed by a single */
4110 /* Variation Selector. For example, to get the first variation of */
4111 /* U+9089, you have to write the character sequence `U+9089 U+E0100'. */
4113 /* Adobe and MS decided to support both standardized and ideographic */
4114 /* VS with a new cmap subtable (format~14). It is an odd subtable */
4115 /* because it is not a mapping of input code points to glyphs, but */
4116 /* contains lists of all variations supported by the font. */
4118 /* A variation may be either `default' or `non-default' for a given */
4119 /* font. A default variation is the one you will get for that code */
4120 /* point if you look it up in the standard Unicode cmap. A */
4121 /* non-default variation is a different glyph. */
4123 /*************************************************************************/
4126 /*************************************************************************/
4129 /* FT_Face_GetCharVariantIndex */
4132 /* Return the glyph index of a given character code as modified by */
4133 /* the variation selector. */
4137 /* A handle to the source face object. */
4140 /* The character code point in Unicode. */
4142 /* variantSelector :: */
4143 /* The Unicode code point of the variation selector. */
4146 /* The glyph index. 0~means either `undefined character code', or */
4147 /* `undefined selector code', or `no variation selector cmap */
4148 /* subtable', or `current CharMap is not Unicode'. */
4151 /* If you use FreeType to manipulate the contents of font files */
4152 /* directly, be aware that the glyph index returned by this function */
4153 /* doesn't always correspond to the internal indices used within */
4154 /* the file. This is done to ensure that value~0 always corresponds */
4155 /* to the `missing glyph'. */
4157 /* This function is only meaningful if */
4158 /* a) the font has a variation selector cmap sub table, */
4160 /* b) the current charmap has a Unicode encoding. */
4165 FT_EXPORT( FT_UInt )
4166 FT_Face_GetCharVariantIndex( FT_Face face,
4168 FT_ULong variantSelector );
4171 /*************************************************************************/
4174 /* FT_Face_GetCharVariantIsDefault */
4177 /* Check whether this variation of this Unicode character is the one */
4178 /* to be found in the `cmap'. */
4182 /* A handle to the source face object. */
4185 /* The character codepoint in Unicode. */
4187 /* variantSelector :: */
4188 /* The Unicode codepoint of the variation selector. */
4191 /* 1~if found in the standard (Unicode) cmap, 0~if found in the */
4192 /* variation selector cmap, or -1 if it is not a variation. */
4195 /* This function is only meaningful if the font has a variation */
4196 /* selector cmap subtable. */
4202 FT_Face_GetCharVariantIsDefault( FT_Face face,
4204 FT_ULong variantSelector );
4207 /*************************************************************************/
4210 /* FT_Face_GetVariantSelectors */
4213 /* Return a zero-terminated list of Unicode variation selectors found */
4218 /* A handle to the source face object. */
4221 /* A pointer to an array of selector code points, or NULL if there is */
4222 /* no valid variation selector cmap subtable. */
4225 /* The last item in the array is~0; the array is owned by the */
4226 /* @FT_Face object but can be overwritten or released on the next */
4227 /* call to a FreeType function. */
4232 FT_EXPORT( FT_UInt32* )
4233 FT_Face_GetVariantSelectors( FT_Face face );
4236 /*************************************************************************/
4239 /* FT_Face_GetVariantsOfChar */
4242 /* Return a zero-terminated list of Unicode variation selectors found */
4243 /* for the specified character code. */
4247 /* A handle to the source face object. */
4250 /* The character codepoint in Unicode. */
4253 /* A pointer to an array of variation selector code points that are */
4254 /* active for the given character, or NULL if the corresponding list */
4258 /* The last item in the array is~0; the array is owned by the */
4259 /* @FT_Face object but can be overwritten or released on the next */
4260 /* call to a FreeType function. */
4265 FT_EXPORT( FT_UInt32* )
4266 FT_Face_GetVariantsOfChar( FT_Face face,
4267 FT_ULong charcode );
4270 /*************************************************************************/
4273 /* FT_Face_GetCharsOfVariant */
4276 /* Return a zero-terminated list of Unicode character codes found for */
4277 /* the specified variation selector. */
4281 /* A handle to the source face object. */
4283 /* variantSelector :: */
4284 /* The variation selector code point in Unicode. */
4287 /* A list of all the code points that are specified by this selector */
4288 /* (both default and non-default codes are returned) or NULL if there */
4289 /* is no valid cmap or the variation selector is invalid. */
4292 /* The last item in the array is~0; the array is owned by the */
4293 /* @FT_Face object but can be overwritten or released on the next */
4294 /* call to a FreeType function. */
4299 FT_EXPORT( FT_UInt32* )
4300 FT_Face_GetCharsOfVariant( FT_Face face,
4301 FT_ULong variantSelector );
4304 /*************************************************************************/
4313 /* Crunching fixed numbers and vectors. */
4316 /* This section contains various functions used to perform */
4317 /* computations on 16.16 fixed-float numbers or 2d vectors. */
4326 /* FT_Vector_Transform */
4327 /* FT_Matrix_Multiply */
4328 /* FT_Matrix_Invert */
4330 /*************************************************************************/
4333 /*************************************************************************/
4339 /* Compute `(a*b)/c' with maximum accuracy, using a 64-bit */
4340 /* intermediate integer whenever necessary. */
4342 /* This function isn't necessarily as fast as some processor specific */
4343 /* operations, but is at least completely portable. */
4346 /* a :: The first multiplier. */
4348 /* b :: The second multiplier. */
4350 /* c :: The divisor. */
4353 /* The result of `(a*b)/c'. This function never traps when trying to */
4354 /* divide by zero; it simply returns `MaxInt' or `MinInt' depending */
4355 /* on the signs of `a' and `b'. */
4357 FT_EXPORT( FT_Long )
4358 FT_MulDiv( FT_Long a,
4363 /*************************************************************************/
4369 /* Compute `(a*b)/0x10000' with maximum accuracy. Its main use is to */
4370 /* multiply a given value by a 16.16 fixed-point factor. */
4373 /* a :: The first multiplier. */
4375 /* b :: The second multiplier. Use a 16.16 factor here whenever */
4376 /* possible (see note below). */
4379 /* The result of `(a*b)/0x10000'. */
4382 /* This function has been optimized for the case where the absolute */
4383 /* value of `a' is less than 2048, and `b' is a 16.16 scaling factor. */
4384 /* As this happens mainly when scaling from notional units to */
4385 /* fractional pixels in FreeType, it resulted in noticeable speed */
4386 /* improvements between versions 2.x and 1.x. */
4388 /* As a conclusion, always try to place a 16.16 factor as the */
4389 /* _second_ argument of this function; this can make a great */
4392 FT_EXPORT( FT_Long )
4393 FT_MulFix( FT_Long a,
4397 /*************************************************************************/
4403 /* Compute `(a*0x10000)/b' with maximum accuracy. Its main use is to */
4404 /* divide a given value by a 16.16 fixed-point factor. */
4407 /* a :: The numerator. */
4409 /* b :: The denominator. Use a 16.16 factor here. */
4412 /* The result of `(a*0x10000)/b'. */
4414 FT_EXPORT( FT_Long )
4415 FT_DivFix( FT_Long a,
4419 /*************************************************************************/
4425 /* Round a 16.16 fixed number. */
4428 /* a :: The number to be rounded. */
4431 /* `a' rounded to the nearest 16.16 fixed integer, halfway cases away */
4435 /* The function uses wrap-around arithmetic. */
4437 FT_EXPORT( FT_Fixed )
4438 FT_RoundFix( FT_Fixed a );
4441 /*************************************************************************/
4447 /* Compute the smallest following integer of a 16.16 fixed number. */
4450 /* a :: The number for which the ceiling function is to be computed. */
4453 /* `a' rounded towards plus infinity. */
4456 /* The function uses wrap-around arithmetic. */
4458 FT_EXPORT( FT_Fixed )
4459 FT_CeilFix( FT_Fixed a );
4462 /*************************************************************************/
4468 /* Compute the largest previous integer of a 16.16 fixed number. */
4471 /* a :: The number for which the floor function is to be computed. */
4474 /* `a' rounded towards minus infinity. */
4476 FT_EXPORT( FT_Fixed )
4477 FT_FloorFix( FT_Fixed a );
4480 /*************************************************************************/
4483 /* FT_Vector_Transform */
4486 /* Transform a single vector through a 2x2 matrix. */
4489 /* vector :: The target vector to transform. */
4492 /* matrix :: A pointer to the source 2x2 matrix. */
4495 /* The result is undefined if either `vector' or `matrix' is invalid. */
4498 FT_Vector_Transform( FT_Vector* vec,
4499 const FT_Matrix* matrix );
4502 /*************************************************************************/
4508 /* FreeType Version */
4511 /* Functions and macros related to FreeType versions. */
4514 /* Note that those functions and macros are of limited use because */
4515 /* even a new release of FreeType with only documentation changes */
4516 /* increases the version number. */
4519 /* FT_Library_Version */
4521 /* FREETYPE_MAJOR */
4522 /* FREETYPE_MINOR */
4523 /* FREETYPE_PATCH */
4525 /* FT_Face_CheckTrueTypePatents */
4526 /* FT_Face_SetUnpatentedHinting */
4530 /*************************************************************************/
4533 /*************************************************************************
4539 * These three macros identify the FreeType source code version.
4540 * Use @FT_Library_Version to access them at runtime.
4543 * FREETYPE_MAJOR :: The major version number.
4544 * FREETYPE_MINOR :: The minor version number.
4545 * FREETYPE_PATCH :: The patch level.
4548 * The version number of FreeType if built as a dynamic link library
4549 * with the `libtool' package is _not_ controlled by these three
4553 #define FREETYPE_MAJOR 2
4554 #define FREETYPE_MINOR 9
4555 #define FREETYPE_PATCH 0
4558 /*************************************************************************/
4561 /* FT_Library_Version */
4564 /* Return the version of the FreeType library being used. This is */
4565 /* useful when dynamically linking to the library, since one cannot */
4566 /* use the macros @FREETYPE_MAJOR, @FREETYPE_MINOR, and */
4567 /* @FREETYPE_PATCH. */
4570 /* library :: A source library handle. */
4573 /* amajor :: The major version number. */
4575 /* aminor :: The minor version number. */
4577 /* apatch :: The patch version number. */
4580 /* The reason why this function takes a `library' argument is because */
4581 /* certain programs implement library initialization in a custom way */
4582 /* that doesn't use @FT_Init_FreeType. */
4584 /* In such cases, the library version might not be available before */
4585 /* the library object has been created. */
4588 FT_Library_Version( FT_Library library,
4594 /*************************************************************************/
4597 /* FT_Face_CheckTrueTypePatents */
4600 /* Deprecated, does nothing. */
4603 /* face :: A face handle. */
4606 /* Always returns false. */
4609 /* Since May 2010, TrueType hinting is no longer patented. */
4614 FT_EXPORT( FT_Bool )
4615 FT_Face_CheckTrueTypePatents( FT_Face face );
4618 /*************************************************************************/
4621 /* FT_Face_SetUnpatentedHinting */
4624 /* Deprecated, does nothing. */
4627 /* face :: A face handle. */
4629 /* value :: New boolean setting. */
4632 /* Always returns false. */
4635 /* Since May 2010, TrueType hinting is no longer patented. */
4640 FT_EXPORT( FT_Bool )
4641 FT_Face_SetUnpatentedHinting( FT_Face face,
4649 #endif /* FREETYPE_H_ */