1 /***************************************************************************/
5 /* FreeType high-level API and common types (specification only). */
7 /* Copyright 1996-2013 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 /***************************************************************************/
19 #ifndef __FREETYPE_H__
20 #define __FREETYPE_H__
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"
32 #include "../ft2build.h"
33 #include "config/ftconfig.h"
42 /*************************************************************************/
51 /* How client applications should allocate FreeType data structures. */
54 /* FreeType assumes that structures allocated by the user and passed */
55 /* as arguments are zeroed out except for the actual data. In other */
56 /* words, it is recommended to use `calloc' (or variants of it) */
57 /* instead of `malloc' for allocation. */
59 /*************************************************************************/
63 /*************************************************************************/
64 /*************************************************************************/
66 /* B A S I C T Y P E S */
68 /*************************************************************************/
69 /*************************************************************************/
72 /*************************************************************************/
81 /* The FreeType~2 base font interface. */
84 /* This section describes the public high-level API of FreeType~2. */
96 /* FT_FACE_FLAG_SCALABLE */
97 /* FT_FACE_FLAG_FIXED_SIZES */
98 /* FT_FACE_FLAG_FIXED_WIDTH */
99 /* FT_FACE_FLAG_HORIZONTAL */
100 /* FT_FACE_FLAG_VERTICAL */
101 /* FT_FACE_FLAG_SFNT */
102 /* FT_FACE_FLAG_KERNING */
103 /* FT_FACE_FLAG_MULTIPLE_MASTERS */
104 /* FT_FACE_FLAG_GLYPH_NAMES */
105 /* FT_FACE_FLAG_EXTERNAL_STREAM */
106 /* FT_FACE_FLAG_FAST_GLYPHS */
107 /* FT_FACE_FLAG_HINTER */
109 /* FT_STYLE_FLAG_BOLD */
110 /* FT_STYLE_FLAG_ITALIC */
113 /* FT_Size_Metrics */
115 /* FT_GlyphSlotRec */
116 /* FT_Glyph_Metrics */
121 /* FT_Init_FreeType */
122 /* FT_Done_FreeType */
126 /* FT_New_Memory_Face */
131 /* FT_Attach_Stream */
133 /* FT_Set_Char_Size */
134 /* FT_Set_Pixel_Sizes */
135 /* FT_Request_Size */
137 /* FT_Size_Request_Type */
138 /* FT_Size_Request */
139 /* FT_Set_Transform */
141 /* FT_Get_Char_Index */
142 /* FT_Get_Name_Index */
147 /* FT_OPEN_PATHNAME */
151 /* FT_LOAD_DEFAULT */
153 /* FT_LOAD_MONOCHROME */
154 /* FT_LOAD_LINEAR_DESIGN */
155 /* FT_LOAD_NO_SCALE */
156 /* FT_LOAD_NO_HINTING */
157 /* FT_LOAD_NO_BITMAP */
158 /* FT_LOAD_CROP_BITMAP */
160 /* FT_LOAD_VERTICAL_LAYOUT */
161 /* FT_LOAD_IGNORE_TRANSFORM */
162 /* FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH */
163 /* FT_LOAD_FORCE_AUTOHINT */
164 /* FT_LOAD_NO_RECURSE */
165 /* FT_LOAD_PEDANTIC */
167 /* FT_LOAD_TARGET_NORMAL */
168 /* FT_LOAD_TARGET_LIGHT */
169 /* FT_LOAD_TARGET_MONO */
170 /* FT_LOAD_TARGET_LCD */
171 /* FT_LOAD_TARGET_LCD_V */
173 /* FT_Render_Glyph */
176 /* FT_Kerning_Mode */
177 /* FT_Get_Track_Kerning */
178 /* FT_Get_Glyph_Name */
179 /* FT_Get_Postscript_Name */
182 /* FT_Select_Charmap */
184 /* FT_Get_Charmap_Index */
186 /* FT_FSTYPE_INSTALLABLE_EMBEDDING */
187 /* FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING */
188 /* FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING */
189 /* FT_FSTYPE_EDITABLE_EMBEDDING */
190 /* FT_FSTYPE_NO_SUBSETTING */
191 /* FT_FSTYPE_BITMAP_EMBEDDING_ONLY */
193 /* FT_Get_FSType_Flags */
195 /*************************************************************************/
198 /*************************************************************************/
201 /* FT_Glyph_Metrics */
204 /* A structure used to model the metrics of a single glyph. The */
205 /* values are expressed in 26.6 fractional pixel format; if the flag */
206 /* @FT_LOAD_NO_SCALE has been used while loading the glyph, values */
207 /* are expressed in font units instead. */
211 /* The glyph's width. */
214 /* The glyph's height. */
216 /* horiBearingX :: */
217 /* Left side bearing for horizontal layout. */
219 /* horiBearingY :: */
220 /* Top side bearing for horizontal layout. */
223 /* Advance width for horizontal layout. */
225 /* vertBearingX :: */
226 /* Left side bearing for vertical layout. */
228 /* vertBearingY :: */
229 /* Top side bearing for vertical layout. Larger positive values */
230 /* mean further below the vertical glyph origin. */
233 /* Advance height for vertical layout. Positive values mean the */
234 /* glyph has a positive advance downward. */
237 /* If not disabled with @FT_LOAD_NO_HINTING, the values represent */
238 /* dimensions of the hinted glyph (in case hinting is applicable). */
240 /* Stroking a glyph with an outside border does not increase */
241 /* `horiAdvance' or `vertAdvance'; you have to manually adjust these */
242 /* values to account for the added width and height. */
244 typedef struct FT_Glyph_Metrics_
260 /*************************************************************************/
266 /* This structure models the metrics of a bitmap strike (i.e., a set */
267 /* of glyphs for a given point size and resolution) in a bitmap font. */
268 /* It is used for the `available_sizes' field of @FT_Face. */
271 /* height :: The vertical distance, in pixels, between two */
272 /* consecutive baselines. It is always positive. */
274 /* width :: The average width, in pixels, of all glyphs in the */
277 /* size :: The nominal size of the strike in 26.6 fractional */
278 /* points. This field is not very useful. */
280 /* x_ppem :: The horizontal ppem (nominal width) in 26.6 fractional */
283 /* y_ppem :: The vertical ppem (nominal height) in 26.6 fractional */
288 /* The nominal size given in a FNT font is not reliable. Thus when */
289 /* the driver finds it incorrect, it sets `size' to some calculated */
290 /* values and sets `x_ppem' and `y_ppem' to the pixel width and */
291 /* height given in the font, respectively. */
293 /* TrueType embedded bitmaps: */
294 /* `size', `width', and `height' values are not contained in the */
295 /* bitmap strike itself. They are computed from the global font */
298 typedef struct FT_Bitmap_Size_
311 /*************************************************************************/
312 /*************************************************************************/
314 /* O B J E C T C L A S S E S */
316 /*************************************************************************/
317 /*************************************************************************/
319 /*************************************************************************/
325 /* A handle to a FreeType library instance. Each `library' is */
326 /* completely independent from the others; it is the `root' of a set */
327 /* of objects like fonts, faces, sizes, etc. */
329 /* It also embeds a memory manager (see @FT_Memory), as well as a */
330 /* scan-line converter object (see @FT_Raster). */
332 /* In multi-threaded applications, make sure that the same FT_Library */
333 /* object or any of its children doesn't get accessed in parallel. */
336 /* Library objects are normally created by @FT_Init_FreeType, and */
337 /* destroyed with @FT_Done_FreeType. If you need reference-counting */
338 /* (cf. @FT_Reference_Library), use @FT_New_Library and */
339 /* @FT_Done_Library. */
341 typedef struct FT_LibraryRec_ *FT_Library;
344 /*************************************************************************/
350 /* A handle to a given FreeType module object. Each module can be a */
351 /* font driver, a renderer, or anything else that provides services */
352 /* to the formers. */
354 typedef struct FT_ModuleRec_* FT_Module;
357 /*************************************************************************/
363 /* A handle to a given FreeType font driver object. Each font driver */
364 /* is a special module capable of creating faces from font files. */
366 typedef struct FT_DriverRec_* FT_Driver;
369 /*************************************************************************/
375 /* A handle to a given FreeType renderer. A renderer is a special */
376 /* module in charge of converting a glyph image to a bitmap, when */
377 /* necessary. Each renderer supports a given glyph image format, and */
378 /* one or more target surface depths. */
380 typedef struct FT_RendererRec_* FT_Renderer;
383 /*************************************************************************/
389 /* A handle to a given typographic face object. A face object models */
390 /* a given typeface, in a given style. */
393 /* Each face object also owns a single @FT_GlyphSlot object, as well */
394 /* as one or more @FT_Size objects. */
396 /* Use @FT_New_Face or @FT_Open_Face to create a new face object from */
397 /* a given filepathname or a custom input stream. */
399 /* Use @FT_Done_Face to destroy it (along with its slot and sizes). */
402 /* See @FT_FaceRec for the publicly accessible fields of a given face */
405 typedef struct FT_FaceRec_* FT_Face;
408 /*************************************************************************/
414 /* A handle to an object used to model a face scaled to a given */
415 /* character size. */
418 /* Each @FT_Face has an _active_ @FT_Size object that is used by */
419 /* functions like @FT_Load_Glyph to determine the scaling */
420 /* transformation which is used to load and hint glyphs and metrics. */
422 /* You can use @FT_Set_Char_Size, @FT_Set_Pixel_Sizes, */
423 /* @FT_Request_Size or even @FT_Select_Size to change the content */
424 /* (i.e., the scaling values) of the active @FT_Size. */
426 /* You can use @FT_New_Size to create additional size objects for a */
427 /* given @FT_Face, but they won't be used by other functions until */
428 /* you activate it through @FT_Activate_Size. Only one size can be */
429 /* activated at any given time per face. */
432 /* See @FT_SizeRec for the publicly accessible fields of a given size */
435 typedef struct FT_SizeRec_* FT_Size;
438 /*************************************************************************/
444 /* A handle to a given `glyph slot'. A slot is a container where it */
445 /* is possible to load any of the glyphs contained in its parent */
448 /* In other words, each time you call @FT_Load_Glyph or */
449 /* @FT_Load_Char, the slot's content is erased by the new glyph data, */
450 /* i.e., the glyph's metrics, its image (bitmap or outline), and */
451 /* other control information. */
454 /* See @FT_GlyphSlotRec for the publicly accessible glyph fields. */
456 typedef struct FT_GlyphSlotRec_* FT_GlyphSlot;
459 /*************************************************************************/
465 /* A handle to a given character map. A charmap is used to translate */
466 /* character codes in a given encoding into glyph indexes for its */
467 /* parent's face. Some font formats may provide several charmaps per */
470 /* Each face object owns zero or more charmaps, but only one of them */
471 /* can be `active' and used by @FT_Get_Char_Index or @FT_Load_Char. */
473 /* The list of available charmaps in a face is available through the */
474 /* `face->num_charmaps' and `face->charmaps' fields of @FT_FaceRec. */
476 /* The currently active charmap is available as `face->charmap'. */
477 /* You should call @FT_Set_Charmap to change it. */
480 /* When a new face is created (either through @FT_New_Face or */
481 /* @FT_Open_Face), the library looks for a Unicode charmap within */
482 /* the list and automatically activates it. */
485 /* See @FT_CharMapRec for the publicly accessible fields of a given */
488 typedef struct FT_CharMapRec_* FT_CharMap;
491 /*************************************************************************/
497 /* This macro converts four-letter tags into an unsigned long. It is */
498 /* used to define `encoding' identifiers (see @FT_Encoding). */
501 /* Since many 16-bit compilers don't like 32-bit enumerations, you */
502 /* should redefine this macro in case of problems to something like */
506 /* #define FT_ENC_TAG( value, a, b, c, d ) value */
509 /* to get a simple enumeration without assigning special numbers. */
513 #define FT_ENC_TAG( value, a, b, c, d ) \
514 value = ( ( (FT_UInt32)(a) << 24 ) | \
515 ( (FT_UInt32)(b) << 16 ) | \
516 ( (FT_UInt32)(c) << 8 ) | \
519 #endif /* FT_ENC_TAG */
522 /*************************************************************************/
528 /* An enumeration used to specify character sets supported by */
529 /* charmaps. Used in the @FT_Select_Charmap API function. */
532 /* Despite the name, this enumeration lists specific character */
533 /* repertories (i.e., charsets), and not text encoding methods (e.g., */
534 /* UTF-8, UTF-16, etc.). */
536 /* Other encodings might be defined in the future. */
539 /* FT_ENCODING_NONE :: */
540 /* The encoding value~0 is reserved. */
542 /* FT_ENCODING_UNICODE :: */
543 /* Corresponds to the Unicode character set. This value covers */
544 /* all versions of the Unicode repertoire, including ASCII and */
545 /* Latin-1. Most fonts include a Unicode charmap, but not all */
548 /* For example, if you want to access Unicode value U+1F028 (and */
549 /* the font contains it), use value 0x1F028 as the input value for */
550 /* @FT_Get_Char_Index. */
552 /* FT_ENCODING_MS_SYMBOL :: */
553 /* Corresponds to the Microsoft Symbol encoding, used to encode */
554 /* mathematical symbols in the 32..255 character code range. For */
555 /* more information, see `http://www.ceviz.net/symbol.htm'. */
557 /* FT_ENCODING_SJIS :: */
558 /* Corresponds to Japanese SJIS encoding. More info at */
559 /* at `http://langsupport.japanreference.com/encoding.shtml'. */
560 /* See note on multi-byte encodings below. */
562 /* FT_ENCODING_GB2312 :: */
563 /* Corresponds to an encoding system for Simplified Chinese as used */
564 /* used in mainland China. */
566 /* FT_ENCODING_BIG5 :: */
567 /* Corresponds to an encoding system for Traditional Chinese as */
568 /* used in Taiwan and Hong Kong. */
570 /* FT_ENCODING_WANSUNG :: */
571 /* Corresponds to the Korean encoding system known as Wansung. */
572 /* For more information see */
573 /* `http://www.microsoft.com/typography/unicode/949.txt'. */
575 /* FT_ENCODING_JOHAB :: */
576 /* The Korean standard character set (KS~C 5601-1992), which */
577 /* corresponds to MS Windows code page 1361. This character set */
578 /* includes all possible Hangeul character combinations. */
580 /* FT_ENCODING_ADOBE_LATIN_1 :: */
581 /* Corresponds to a Latin-1 encoding as defined in a Type~1 */
582 /* PostScript font. It is limited to 256 character codes. */
584 /* FT_ENCODING_ADOBE_STANDARD :: */
585 /* Corresponds to the Adobe Standard encoding, as found in Type~1, */
586 /* CFF, and OpenType/CFF fonts. It is limited to 256 character */
589 /* FT_ENCODING_ADOBE_EXPERT :: */
590 /* Corresponds to the Adobe Expert encoding, as found in Type~1, */
591 /* CFF, and OpenType/CFF fonts. It is limited to 256 character */
594 /* FT_ENCODING_ADOBE_CUSTOM :: */
595 /* Corresponds to a custom encoding, as found in Type~1, CFF, and */
596 /* OpenType/CFF fonts. It is limited to 256 character codes. */
598 /* FT_ENCODING_APPLE_ROMAN :: */
599 /* Corresponds to the 8-bit Apple roman encoding. Many TrueType */
600 /* and OpenType fonts contain a charmap for this encoding, since */
601 /* older versions of Mac OS are able to use it. */
603 /* FT_ENCODING_OLD_LATIN_2 :: */
604 /* This value is deprecated and was never used nor reported by */
605 /* FreeType. Don't use or test for it. */
607 /* FT_ENCODING_MS_SJIS :: */
608 /* Same as FT_ENCODING_SJIS. Deprecated. */
610 /* FT_ENCODING_MS_GB2312 :: */
611 /* Same as FT_ENCODING_GB2312. Deprecated. */
613 /* FT_ENCODING_MS_BIG5 :: */
614 /* Same as FT_ENCODING_BIG5. Deprecated. */
616 /* FT_ENCODING_MS_WANSUNG :: */
617 /* Same as FT_ENCODING_WANSUNG. Deprecated. */
619 /* FT_ENCODING_MS_JOHAB :: */
620 /* Same as FT_ENCODING_JOHAB. Deprecated. */
623 /* By default, FreeType automatically synthesizes a Unicode charmap */
624 /* for PostScript fonts, using their glyph names dictionaries. */
625 /* However, it also reports the encodings defined explicitly in the */
626 /* font file, for the cases when they are needed, with the Adobe */
627 /* values as well. */
629 /* FT_ENCODING_NONE is set by the BDF and PCF drivers if the charmap */
630 /* is neither Unicode nor ISO-8859-1 (otherwise it is set to */
631 /* FT_ENCODING_UNICODE). Use @FT_Get_BDF_Charset_ID to find out */
632 /* which encoding is really present. If, for example, the */
633 /* `cs_registry' field is `KOI8' and the `cs_encoding' field is `R', */
634 /* the font is encoded in KOI8-R. */
636 /* FT_ENCODING_NONE is always set (with a single exception) by the */
637 /* winfonts driver. Use @FT_Get_WinFNT_Header and examine the */
638 /* `charset' field of the @FT_WinFNT_HeaderRec structure to find out */
639 /* which encoding is really present. For example, */
640 /* @FT_WinFNT_ID_CP1251 (204) means Windows code page 1251 (for */
643 /* FT_ENCODING_NONE is set if `platform_id' is @TT_PLATFORM_MACINTOSH */
644 /* and `encoding_id' is not @TT_MAC_ID_ROMAN (otherwise it is set to */
645 /* FT_ENCODING_APPLE_ROMAN). */
647 /* If `platform_id' is @TT_PLATFORM_MACINTOSH, use the function */
648 /* @FT_Get_CMap_Language_ID to query the Mac language ID which may */
649 /* be needed to be able to distinguish Apple encoding variants. See */
651 /* http://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/README.TXT */
653 /* to get an idea how to do that. Basically, if the language ID */
654 /* is~0, don't use it, otherwise subtract 1 from the language ID. */
655 /* Then examine `encoding_id'. If, for example, `encoding_id' is */
656 /* @TT_MAC_ID_ROMAN and the language ID (minus~1) is */
657 /* `TT_MAC_LANGID_GREEK', it is the Greek encoding, not Roman. */
658 /* @TT_MAC_ID_ARABIC with `TT_MAC_LANGID_FARSI' means the Farsi */
659 /* variant the Arabic encoding. */
661 typedef enum FT_Encoding_
663 FT_ENC_TAG( FT_ENCODING_NONE, 0, 0, 0, 0 ),
665 FT_ENC_TAG( FT_ENCODING_MS_SYMBOL, 's', 'y', 'm', 'b' ),
666 FT_ENC_TAG( FT_ENCODING_UNICODE, 'u', 'n', 'i', 'c' ),
668 FT_ENC_TAG( FT_ENCODING_SJIS, 's', 'j', 'i', 's' ),
669 FT_ENC_TAG( FT_ENCODING_GB2312, 'g', 'b', ' ', ' ' ),
670 FT_ENC_TAG( FT_ENCODING_BIG5, 'b', 'i', 'g', '5' ),
671 FT_ENC_TAG( FT_ENCODING_WANSUNG, 'w', 'a', 'n', 's' ),
672 FT_ENC_TAG( FT_ENCODING_JOHAB, 'j', 'o', 'h', 'a' ),
674 /* for backwards compatibility */
675 FT_ENCODING_MS_SJIS = FT_ENCODING_SJIS,
676 FT_ENCODING_MS_GB2312 = FT_ENCODING_GB2312,
677 FT_ENCODING_MS_BIG5 = FT_ENCODING_BIG5,
678 FT_ENCODING_MS_WANSUNG = FT_ENCODING_WANSUNG,
679 FT_ENCODING_MS_JOHAB = FT_ENCODING_JOHAB,
681 FT_ENC_TAG( FT_ENCODING_ADOBE_STANDARD, 'A', 'D', 'O', 'B' ),
682 FT_ENC_TAG( FT_ENCODING_ADOBE_EXPERT, 'A', 'D', 'B', 'E' ),
683 FT_ENC_TAG( FT_ENCODING_ADOBE_CUSTOM, 'A', 'D', 'B', 'C' ),
684 FT_ENC_TAG( FT_ENCODING_ADOBE_LATIN_1, 'l', 'a', 't', '1' ),
686 FT_ENC_TAG( FT_ENCODING_OLD_LATIN_2, 'l', 'a', 't', '2' ),
688 FT_ENC_TAG( FT_ENCODING_APPLE_ROMAN, 'a', 'r', 'm', 'n' )
693 /*************************************************************************/
696 /* ft_encoding_xxx */
699 /* These constants are deprecated; use the corresponding @FT_Encoding */
700 /* values instead. */
702 #define ft_encoding_none FT_ENCODING_NONE
703 #define ft_encoding_unicode FT_ENCODING_UNICODE
704 #define ft_encoding_symbol FT_ENCODING_MS_SYMBOL
705 #define ft_encoding_latin_1 FT_ENCODING_ADOBE_LATIN_1
706 #define ft_encoding_latin_2 FT_ENCODING_OLD_LATIN_2
707 #define ft_encoding_sjis FT_ENCODING_SJIS
708 #define ft_encoding_gb2312 FT_ENCODING_GB2312
709 #define ft_encoding_big5 FT_ENCODING_BIG5
710 #define ft_encoding_wansung FT_ENCODING_WANSUNG
711 #define ft_encoding_johab FT_ENCODING_JOHAB
713 #define ft_encoding_adobe_standard FT_ENCODING_ADOBE_STANDARD
714 #define ft_encoding_adobe_expert FT_ENCODING_ADOBE_EXPERT
715 #define ft_encoding_adobe_custom FT_ENCODING_ADOBE_CUSTOM
716 #define ft_encoding_apple_roman FT_ENCODING_APPLE_ROMAN
719 /*************************************************************************/
725 /* The base charmap structure. */
728 /* face :: A handle to the parent face object. */
730 /* encoding :: An @FT_Encoding tag identifying the charmap. Use */
731 /* this with @FT_Select_Charmap. */
733 /* platform_id :: An ID number describing the platform for the */
734 /* following encoding ID. This comes directly from */
735 /* the TrueType specification and should be emulated */
736 /* for other formats. */
738 /* encoding_id :: A platform specific encoding number. This also */
739 /* comes from the TrueType specification and should be */
740 /* emulated similarly. */
742 typedef struct FT_CharMapRec_
745 FT_Encoding encoding;
746 FT_UShort platform_id;
747 FT_UShort encoding_id;
752 /*************************************************************************/
753 /*************************************************************************/
755 /* B A S E O B J E C T C L A S S E S */
757 /*************************************************************************/
758 /*************************************************************************/
761 /*************************************************************************/
764 /* FT_Face_Internal */
767 /* An opaque handle to an `FT_Face_InternalRec' structure, used to */
768 /* model private data of a given @FT_Face object. */
770 /* This structure might change between releases of FreeType~2 and is */
771 /* not generally available to client applications. */
773 typedef struct FT_Face_InternalRec_* FT_Face_Internal;
776 /*************************************************************************/
782 /* FreeType root face class structure. A face object models a */
783 /* typeface in a font file. */
786 /* num_faces :: The number of faces in the font file. Some */
787 /* font formats can have multiple faces in */
790 /* face_index :: The index of the face in the font file. It */
791 /* is set to~0 if there is only one face in */
794 /* face_flags :: A set of bit flags that give important */
795 /* information about the face; see */
796 /* @FT_FACE_FLAG_XXX for the details. */
798 /* style_flags :: A set of bit flags indicating the style of */
799 /* the face; see @FT_STYLE_FLAG_XXX for the */
802 /* num_glyphs :: The number of glyphs in the face. If the */
803 /* face is scalable and has sbits (see */
804 /* `num_fixed_sizes'), it is set to the number */
805 /* of outline glyphs. */
807 /* For CID-keyed fonts, this value gives the */
808 /* highest CID used in the font. */
810 /* family_name :: The face's family name. This is an ASCII */
811 /* string, usually in English, which describes */
812 /* the typeface's family (like `Times New */
813 /* Roman', `Bodoni', `Garamond', etc). This */
814 /* is a least common denominator used to list */
815 /* fonts. Some formats (TrueType & OpenType) */
816 /* provide localized and Unicode versions of */
817 /* this string. Applications should use the */
818 /* format specific interface to access them. */
819 /* Can be NULL (e.g., in fonts embedded in a */
822 /* style_name :: The face's style name. This is an ASCII */
823 /* string, usually in English, which describes */
824 /* the typeface's style (like `Italic', */
825 /* `Bold', `Condensed', etc). Not all font */
826 /* formats provide a style name, so this field */
827 /* is optional, and can be set to NULL. As */
828 /* for `family_name', some formats provide */
829 /* localized and Unicode versions of this */
830 /* string. Applications should use the format */
831 /* specific interface to access them. */
833 /* num_fixed_sizes :: The number of bitmap strikes in the face. */
834 /* Even if the face is scalable, there might */
835 /* still be bitmap strikes, which are called */
836 /* `sbits' in that case. */
838 /* available_sizes :: An array of @FT_Bitmap_Size for all bitmap */
839 /* strikes in the face. It is set to NULL if */
840 /* there is no bitmap strike. */
842 /* num_charmaps :: The number of charmaps in the face. */
844 /* charmaps :: An array of the charmaps of the face. */
846 /* generic :: A field reserved for client uses. See the */
847 /* @FT_Generic type description. */
849 /* bbox :: The font bounding box. Coordinates are */
850 /* expressed in font units (see */
851 /* `units_per_EM'). The box is large enough */
852 /* to contain any glyph from the font. Thus, */
853 /* `bbox.yMax' can be seen as the `maximum */
854 /* ascender', and `bbox.yMin' as the `minimum */
855 /* descender'. Only relevant for scalable */
858 /* Note that the bounding box might be off by */
859 /* (at least) one pixel for hinted fonts. See */
860 /* @FT_Size_Metrics for further discussion. */
862 /* units_per_EM :: The number of font units per EM square for */
863 /* this face. This is typically 2048 for */
864 /* TrueType fonts, and 1000 for Type~1 fonts. */
865 /* Only relevant for scalable formats. */
867 /* ascender :: The typographic ascender of the face, */
868 /* expressed in font units. For font formats */
869 /* not having this information, it is set to */
870 /* `bbox.yMax'. Only relevant for scalable */
873 /* descender :: The typographic descender of the face, */
874 /* expressed in font units. For font formats */
875 /* not having this information, it is set to */
876 /* `bbox.yMin'. Note that this field is */
877 /* usually negative. Only relevant for */
878 /* scalable formats. */
880 /* height :: This value is the vertical distance */
881 /* between two consecutive baselines, */
882 /* expressed in font units. It is always */
883 /* positive. Only relevant for scalable */
886 /* If you want the global glyph height, use */
887 /* `ascender - descender'. */
889 /* max_advance_width :: The maximum advance width, in font units, */
890 /* for all glyphs in this face. This can be */
891 /* used to make word wrapping computations */
892 /* faster. Only relevant for scalable */
895 /* max_advance_height :: The maximum advance height, in font units, */
896 /* for all glyphs in this face. This is only */
897 /* relevant for vertical layouts, and is set */
898 /* to `height' for fonts that do not provide */
899 /* vertical metrics. Only relevant for */
900 /* scalable formats. */
902 /* underline_position :: The position, in font units, of the */
903 /* underline line for this face. It is the */
904 /* center of the underlining stem. Only */
905 /* relevant for scalable formats. */
907 /* underline_thickness :: The thickness, in font units, of the */
908 /* underline for this face. Only relevant for */
909 /* scalable formats. */
911 /* glyph :: The face's associated glyph slot(s). */
913 /* size :: The current active size for this face. */
915 /* charmap :: The current active charmap for this face. */
918 /* Fields may be changed after a call to @FT_Attach_File or */
919 /* @FT_Attach_Stream. */
921 typedef struct FT_FaceRec_
931 FT_String* family_name;
932 FT_String* style_name;
934 FT_Int num_fixed_sizes;
935 FT_Bitmap_Size* available_sizes;
938 FT_CharMap* charmaps;
940 #ifdef _FX_MANAGED_CODE_
941 #define generic generic_data
946 /*# The following member variables (down to `underline_thickness') */
947 /*# are only relevant to scalable outlines; cf. @FT_Bitmap_Size */
948 /*# for bitmap fonts. */
951 FT_UShort units_per_EM;
956 FT_Short max_advance_width;
957 FT_Short max_advance_height;
959 FT_Short underline_position;
960 FT_Short underline_thickness;
972 FT_ListRec sizes_list;
974 FT_Generic autohint; /* face-specific auto-hinter data */
975 void* extensions; /* unused */
977 FT_Face_Internal internal;
984 /*************************************************************************/
987 /* FT_FACE_FLAG_XXX */
990 /* A list of bit flags used in the `face_flags' field of the */
991 /* @FT_FaceRec structure. They inform client applications of */
992 /* properties of the corresponding face. */
995 /* FT_FACE_FLAG_SCALABLE :: */
996 /* Indicates that the face contains outline glyphs. This doesn't */
997 /* prevent bitmap strikes, i.e., a face can have both this and */
998 /* and @FT_FACE_FLAG_FIXED_SIZES set. */
1000 /* FT_FACE_FLAG_FIXED_SIZES :: */
1001 /* Indicates that the face contains bitmap strikes. See also the */
1002 /* `num_fixed_sizes' and `available_sizes' fields of @FT_FaceRec. */
1004 /* FT_FACE_FLAG_FIXED_WIDTH :: */
1005 /* Indicates that the face contains fixed-width characters (like */
1006 /* Courier, Lucido, MonoType, etc.). */
1008 /* FT_FACE_FLAG_SFNT :: */
1009 /* Indicates that the face uses the `sfnt' storage scheme. For */
1010 /* now, this means TrueType and OpenType. */
1012 /* FT_FACE_FLAG_HORIZONTAL :: */
1013 /* Indicates that the face contains horizontal glyph metrics. This */
1014 /* should be set for all common formats. */
1016 /* FT_FACE_FLAG_VERTICAL :: */
1017 /* Indicates that the face contains vertical glyph metrics. This */
1018 /* is only available in some formats, not all of them. */
1020 /* FT_FACE_FLAG_KERNING :: */
1021 /* Indicates that the face contains kerning information. If set, */
1022 /* the kerning distance can be retrieved through the function */
1023 /* @FT_Get_Kerning. Otherwise the function always return the */
1024 /* vector (0,0). Note that FreeType doesn't handle kerning data */
1025 /* from the `GPOS' table (as present in some OpenType fonts). */
1027 /* FT_FACE_FLAG_FAST_GLYPHS :: */
1028 /* THIS FLAG IS DEPRECATED. DO NOT USE OR TEST IT. */
1030 /* FT_FACE_FLAG_MULTIPLE_MASTERS :: */
1031 /* Indicates that the font contains multiple masters and is capable */
1032 /* of interpolating between them. See the multiple-masters */
1033 /* specific API for details. */
1035 /* FT_FACE_FLAG_GLYPH_NAMES :: */
1036 /* Indicates that the font contains glyph names that can be */
1037 /* retrieved through @FT_Get_Glyph_Name. Note that some TrueType */
1038 /* fonts contain broken glyph name tables. Use the function */
1039 /* @FT_Has_PS_Glyph_Names when needed. */
1041 /* FT_FACE_FLAG_EXTERNAL_STREAM :: */
1042 /* Used internally by FreeType to indicate that a face's stream was */
1043 /* provided by the client application and should not be destroyed */
1044 /* when @FT_Done_Face is called. Don't read or test this flag. */
1046 /* FT_FACE_FLAG_HINTER :: */
1047 /* Set if the font driver has a hinting machine of its own. For */
1048 /* example, with TrueType fonts, it makes sense to use data from */
1049 /* the SFNT `gasp' table only if the native TrueType hinting engine */
1050 /* (with the bytecode interpreter) is available and active. */
1052 /* FT_FACE_FLAG_CID_KEYED :: */
1053 /* Set if the font is CID-keyed. In that case, the font is not */
1054 /* accessed by glyph indices but by CID values. For subsetted */
1055 /* CID-keyed fonts this has the consequence that not all index */
1056 /* values are a valid argument to FT_Load_Glyph. Only the CID */
1057 /* values for which corresponding glyphs in the subsetted font */
1058 /* exist make FT_Load_Glyph return successfully; in all other cases */
1059 /* you get an `FT_Err_Invalid_Argument' error. */
1061 /* Note that CID-keyed fonts which are in an SFNT wrapper don't */
1062 /* have this flag set since the glyphs are accessed in the normal */
1063 /* way (using contiguous indices); the `CID-ness' isn't visible to */
1064 /* the application. */
1066 /* FT_FACE_FLAG_TRICKY :: */
1067 /* Set if the font is `tricky', this is, it always needs the */
1068 /* font format's native hinting engine to get a reasonable result. */
1069 /* A typical example is the Chinese font `mingli.ttf' which uses */
1070 /* TrueType bytecode instructions to move and scale all of its */
1073 /* It is not possible to autohint such fonts using */
1074 /* @FT_LOAD_FORCE_AUTOHINT; it will also ignore */
1075 /* @FT_LOAD_NO_HINTING. You have to set both @FT_LOAD_NO_HINTING */
1076 /* and @FT_LOAD_NO_AUTOHINT to really disable hinting; however, you */
1077 /* probably never want this except for demonstration purposes. */
1079 /* Currently, there are about a dozen TrueType fonts in the list of */
1080 /* tricky fonts; they are hard-coded in file `ttobjs.c'. */
1082 #define FT_FACE_FLAG_SCALABLE ( 1L << 0 )
1083 #define FT_FACE_FLAG_FIXED_SIZES ( 1L << 1 )
1084 #define FT_FACE_FLAG_FIXED_WIDTH ( 1L << 2 )
1085 #define FT_FACE_FLAG_SFNT ( 1L << 3 )
1086 #define FT_FACE_FLAG_HORIZONTAL ( 1L << 4 )
1087 #define FT_FACE_FLAG_VERTICAL ( 1L << 5 )
1088 #define FT_FACE_FLAG_KERNING ( 1L << 6 )
1089 #define FT_FACE_FLAG_FAST_GLYPHS ( 1L << 7 )
1090 #define FT_FACE_FLAG_MULTIPLE_MASTERS ( 1L << 8 )
1091 #define FT_FACE_FLAG_GLYPH_NAMES ( 1L << 9 )
1092 #define FT_FACE_FLAG_EXTERNAL_STREAM ( 1L << 10 )
1093 #define FT_FACE_FLAG_HINTER ( 1L << 11 )
1094 #define FT_FACE_FLAG_CID_KEYED ( 1L << 12 )
1095 #define FT_FACE_FLAG_TRICKY ( 1L << 13 )
1098 /*************************************************************************
1101 * FT_HAS_HORIZONTAL( face )
1104 * A macro that returns true whenever a face object contains
1105 * horizontal metrics (this is true for all font formats though).
1108 * @FT_HAS_VERTICAL can be used to check for vertical metrics.
1111 #define FT_HAS_HORIZONTAL( face ) \
1112 ( face->face_flags & FT_FACE_FLAG_HORIZONTAL )
1115 /*************************************************************************
1118 * FT_HAS_VERTICAL( face )
1121 * A macro that returns true whenever a face object contains real
1122 * vertical metrics (and not only synthesized ones).
1125 #define FT_HAS_VERTICAL( face ) \
1126 ( face->face_flags & FT_FACE_FLAG_VERTICAL )
1129 /*************************************************************************
1132 * FT_HAS_KERNING( face )
1135 * A macro that returns true whenever a face object contains kerning
1136 * data that can be accessed with @FT_Get_Kerning.
1139 #define FT_HAS_KERNING( face ) \
1140 ( face->face_flags & FT_FACE_FLAG_KERNING )
1143 /*************************************************************************
1146 * FT_IS_SCALABLE( face )
1149 * A macro that returns true whenever a face object contains a scalable
1150 * font face (true for TrueType, Type~1, Type~42, CID, OpenType/CFF,
1151 * and PFR font formats.
1154 #define FT_IS_SCALABLE( face ) \
1155 ( face->face_flags & FT_FACE_FLAG_SCALABLE )
1158 /*************************************************************************
1161 * FT_IS_SFNT( face )
1164 * A macro that returns true whenever a face object contains a font
1165 * whose format is based on the SFNT storage scheme. This usually
1166 * means: TrueType fonts, OpenType fonts, as well as SFNT-based embedded
1169 * If this macro is true, all functions defined in @FT_SFNT_NAMES_H and
1170 * @FT_TRUETYPE_TABLES_H are available.
1173 #define FT_IS_SFNT( face ) \
1174 ( face->face_flags & FT_FACE_FLAG_SFNT )
1177 /*************************************************************************
1180 * FT_IS_FIXED_WIDTH( face )
1183 * A macro that returns true whenever a face object contains a font face
1184 * that contains fixed-width (or `monospace', `fixed-pitch', etc.)
1188 #define FT_IS_FIXED_WIDTH( face ) \
1189 ( face->face_flags & FT_FACE_FLAG_FIXED_WIDTH )
1192 /*************************************************************************
1195 * FT_HAS_FIXED_SIZES( face )
1198 * A macro that returns true whenever a face object contains some
1199 * embedded bitmaps. See the `available_sizes' field of the
1200 * @FT_FaceRec structure.
1203 #define FT_HAS_FIXED_SIZES( face ) \
1204 ( face->face_flags & FT_FACE_FLAG_FIXED_SIZES )
1207 /*************************************************************************
1210 * FT_HAS_FAST_GLYPHS( face )
1216 #define FT_HAS_FAST_GLYPHS( face ) 0
1219 /*************************************************************************
1222 * FT_HAS_GLYPH_NAMES( face )
1225 * A macro that returns true whenever a face object contains some glyph
1226 * names that can be accessed through @FT_Get_Glyph_Name.
1229 #define FT_HAS_GLYPH_NAMES( face ) \
1230 ( face->face_flags & FT_FACE_FLAG_GLYPH_NAMES )
1233 /*************************************************************************
1236 * FT_HAS_MULTIPLE_MASTERS( face )
1239 * A macro that returns true whenever a face object contains some
1240 * multiple masters. The functions provided by @FT_MULTIPLE_MASTERS_H
1241 * are then available to choose the exact design you want.
1244 #define FT_HAS_MULTIPLE_MASTERS( face ) \
1245 ( face->face_flags & FT_FACE_FLAG_MULTIPLE_MASTERS )
1248 /*************************************************************************
1251 * FT_IS_CID_KEYED( face )
1254 * A macro that returns true whenever a face object contains a CID-keyed
1255 * font. See the discussion of @FT_FACE_FLAG_CID_KEYED for more
1258 * If this macro is true, all functions defined in @FT_CID_H are
1262 #define FT_IS_CID_KEYED( face ) \
1263 ( face->face_flags & FT_FACE_FLAG_CID_KEYED )
1266 /*************************************************************************
1269 * FT_IS_TRICKY( face )
1272 * A macro that returns true whenever a face represents a `tricky' font.
1273 * See the discussion of @FT_FACE_FLAG_TRICKY for more details.
1276 #define FT_IS_TRICKY( face ) \
1277 ( face->face_flags & FT_FACE_FLAG_TRICKY )
1280 /*************************************************************************/
1283 /* FT_STYLE_FLAG_XXX */
1286 /* A list of bit-flags used to indicate the style of a given face. */
1287 /* These are used in the `style_flags' field of @FT_FaceRec. */
1290 /* FT_STYLE_FLAG_ITALIC :: */
1291 /* Indicates that a given face style is italic or oblique. */
1293 /* FT_STYLE_FLAG_BOLD :: */
1294 /* Indicates that a given face is bold. */
1297 /* The style information as provided by FreeType is very basic. More */
1298 /* details are beyond the scope and should be done on a higher level */
1299 /* (for example, by analyzing various fields of the `OS/2' table in */
1300 /* SFNT based fonts). */
1302 #define FT_STYLE_FLAG_ITALIC ( 1 << 0 )
1303 #define FT_STYLE_FLAG_BOLD ( 1 << 1 )
1306 /*************************************************************************/
1309 /* FT_Size_Internal */
1312 /* An opaque handle to an `FT_Size_InternalRec' structure, used to */
1313 /* model private data of a given @FT_Size object. */
1315 typedef struct FT_Size_InternalRec_* FT_Size_Internal;
1318 /*************************************************************************/
1321 /* FT_Size_Metrics */
1324 /* The size metrics structure gives the metrics of a size object. */
1327 /* x_ppem :: The width of the scaled EM square in pixels, hence */
1328 /* the term `ppem' (pixels per EM). It is also */
1329 /* referred to as `nominal width'. */
1331 /* y_ppem :: The height of the scaled EM square in pixels, */
1332 /* hence the term `ppem' (pixels per EM). It is also */
1333 /* referred to as `nominal height'. */
1335 /* x_scale :: A 16.16 fractional scaling value used to convert */
1336 /* horizontal metrics from font units to 26.6 */
1337 /* fractional pixels. Only relevant for scalable */
1340 /* y_scale :: A 16.16 fractional scaling value used to convert */
1341 /* vertical metrics from font units to 26.6 */
1342 /* fractional pixels. Only relevant for scalable */
1345 /* ascender :: The ascender in 26.6 fractional pixels. See */
1346 /* @FT_FaceRec for the details. */
1348 /* descender :: The descender in 26.6 fractional pixels. See */
1349 /* @FT_FaceRec for the details. */
1351 /* height :: The height in 26.6 fractional pixels. See */
1352 /* @FT_FaceRec for the details. */
1354 /* max_advance :: The maximum advance width in 26.6 fractional */
1355 /* pixels. See @FT_FaceRec for the details. */
1358 /* The scaling values, if relevant, are determined first during a */
1359 /* size changing operation. The remaining fields are then set by the */
1360 /* driver. For scalable formats, they are usually set to scaled */
1361 /* values of the corresponding fields in @FT_FaceRec. */
1363 /* Note that due to glyph hinting, these values might not be exact */
1364 /* for certain fonts. Thus they must be treated as unreliable */
1365 /* with an error margin of at least one pixel! */
1367 /* Indeed, the only way to get the exact metrics is to render _all_ */
1368 /* glyphs. As this would be a definite performance hit, it is up to */
1369 /* client applications to perform such computations. */
1371 /* The FT_Size_Metrics structure is valid for bitmap fonts also. */
1373 typedef struct FT_Size_Metrics_
1375 FT_UShort x_ppem; /* horizontal pixels per EM */
1376 FT_UShort y_ppem; /* vertical pixels per EM */
1378 FT_Fixed x_scale; /* scaling values used to convert font */
1379 FT_Fixed y_scale; /* units to 26.6 fractional pixels */
1381 FT_Pos ascender; /* ascender in 26.6 frac. pixels */
1382 FT_Pos descender; /* descender in 26.6 frac. pixels */
1383 FT_Pos height; /* text height in 26.6 frac. pixels */
1384 FT_Pos max_advance; /* max horizontal advance, in 26.6 pixels */
1389 /*************************************************************************/
1395 /* FreeType root size class structure. A size object models a face */
1396 /* object at a given size. */
1399 /* face :: Handle to the parent face object. */
1401 /* generic :: A typeless pointer, which is unused by the FreeType */
1402 /* library or any of its drivers. It can be used by */
1403 /* client applications to link their own data to each size */
1406 /* metrics :: Metrics for this size object. This field is read-only. */
1408 typedef struct FT_SizeRec_
1410 FT_Face face; /* parent face object */
1411 FT_Generic generic; /* generic pointer for client uses */
1412 FT_Size_Metrics metrics; /* size metrics */
1413 FT_Size_Internal internal;
1418 /*************************************************************************/
1424 /* The subglyph structure is an internal object used to describe */
1425 /* subglyphs (for example, in the case of composites). */
1428 /* The subglyph implementation is not part of the high-level API, */
1429 /* hence the forward structure declaration. */
1431 /* You can however retrieve subglyph information with */
1432 /* @FT_Get_SubGlyph_Info. */
1434 typedef struct FT_SubGlyphRec_* FT_SubGlyph;
1437 /*************************************************************************/
1440 /* FT_Slot_Internal */
1443 /* An opaque handle to an `FT_Slot_InternalRec' structure, used to */
1444 /* model private data of a given @FT_GlyphSlot object. */
1446 typedef struct FT_Slot_InternalRec_* FT_Slot_Internal;
1449 /*************************************************************************/
1452 /* FT_GlyphSlotRec */
1455 /* FreeType root glyph slot class structure. A glyph slot is a */
1456 /* container where individual glyphs can be loaded, be they in */
1457 /* outline or bitmap format. */
1460 /* library :: A handle to the FreeType library instance */
1461 /* this slot belongs to. */
1463 /* face :: A handle to the parent face object. */
1465 /* next :: In some cases (like some font tools), several */
1466 /* glyph slots per face object can be a good */
1467 /* thing. As this is rare, the glyph slots are */
1468 /* listed through a direct, single-linked list */
1469 /* using its `next' field. */
1471 /* generic :: A typeless pointer which is unused by the */
1472 /* FreeType library or any of its drivers. It */
1473 /* can be used by client applications to link */
1474 /* their own data to each glyph slot object. */
1476 /* metrics :: The metrics of the last loaded glyph in the */
1477 /* slot. The returned values depend on the last */
1478 /* load flags (see the @FT_Load_Glyph API */
1479 /* function) and can be expressed either in 26.6 */
1480 /* fractional pixels or font units. */
1482 /* Note that even when the glyph image is */
1483 /* transformed, the metrics are not. */
1485 /* linearHoriAdvance :: The advance width of the unhinted glyph. */
1486 /* Its value is expressed in 16.16 fractional */
1487 /* pixels, unless @FT_LOAD_LINEAR_DESIGN is set */
1488 /* when loading the glyph. This field can be */
1489 /* important to perform correct WYSIWYG layout. */
1490 /* Only relevant for outline glyphs. */
1492 /* linearVertAdvance :: The advance height of the unhinted glyph. */
1493 /* Its value is expressed in 16.16 fractional */
1494 /* pixels, unless @FT_LOAD_LINEAR_DESIGN is set */
1495 /* when loading the glyph. This field can be */
1496 /* important to perform correct WYSIWYG layout. */
1497 /* Only relevant for outline glyphs. */
1499 /* advance :: This shorthand is, depending on */
1500 /* @FT_LOAD_IGNORE_TRANSFORM, the transformed */
1501 /* advance width for the glyph (in 26.6 */
1502 /* fractional pixel format). As specified with */
1503 /* @FT_LOAD_VERTICAL_LAYOUT, it uses either the */
1504 /* `horiAdvance' or the `vertAdvance' value of */
1505 /* `metrics' field. */
1507 /* format :: This field indicates the format of the image */
1508 /* contained in the glyph slot. Typically */
1509 /* @FT_GLYPH_FORMAT_BITMAP, */
1510 /* @FT_GLYPH_FORMAT_OUTLINE, or */
1511 /* @FT_GLYPH_FORMAT_COMPOSITE, but others are */
1514 /* bitmap :: This field is used as a bitmap descriptor */
1515 /* when the slot format is */
1516 /* @FT_GLYPH_FORMAT_BITMAP. Note that the */
1517 /* address and content of the bitmap buffer can */
1518 /* change between calls of @FT_Load_Glyph and a */
1519 /* few other functions. */
1521 /* bitmap_left :: This is the bitmap's left bearing expressed */
1522 /* in integer pixels. Of course, this is only */
1523 /* valid if the format is */
1524 /* @FT_GLYPH_FORMAT_BITMAP. */
1526 /* bitmap_top :: This is the bitmap's top bearing expressed in */
1527 /* integer pixels. Remember that this is the */
1528 /* distance from the baseline to the top-most */
1529 /* glyph scanline, upwards y~coordinates being */
1532 /* outline :: The outline descriptor for the current glyph */
1533 /* image if its format is */
1534 /* @FT_GLYPH_FORMAT_OUTLINE. Once a glyph is */
1535 /* loaded, `outline' can be transformed, */
1536 /* distorted, embolded, etc. However, it must */
1539 /* num_subglyphs :: The number of subglyphs in a composite glyph. */
1540 /* This field is only valid for the composite */
1541 /* glyph format that should normally only be */
1542 /* loaded with the @FT_LOAD_NO_RECURSE flag. */
1543 /* For now this is internal to FreeType. */
1545 /* subglyphs :: An array of subglyph descriptors for */
1546 /* composite glyphs. There are `num_subglyphs' */
1547 /* elements in there. Currently internal to */
1550 /* control_data :: Certain font drivers can also return the */
1551 /* control data for a given glyph image (e.g. */
1552 /* TrueType bytecode, Type~1 charstrings, etc.). */
1553 /* This field is a pointer to such data. */
1555 /* control_len :: This is the length in bytes of the control */
1558 /* other :: Really wicked formats can use this pointer to */
1559 /* present their own glyph image to client */
1560 /* applications. Note that the application */
1561 /* needs to know about the image format. */
1563 /* lsb_delta :: The difference between hinted and unhinted */
1564 /* left side bearing while autohinting is */
1565 /* active. Zero otherwise. */
1567 /* rsb_delta :: The difference between hinted and unhinted */
1568 /* right side bearing while autohinting is */
1569 /* active. Zero otherwise. */
1572 /* If @FT_Load_Glyph is called with default flags (see */
1573 /* @FT_LOAD_DEFAULT) the glyph image is loaded in the glyph slot in */
1574 /* its native format (e.g., an outline glyph for TrueType and Type~1 */
1577 /* This image can later be converted into a bitmap by calling */
1578 /* @FT_Render_Glyph. This function finds the current renderer for */
1579 /* the native image's format, then invokes it. */
1581 /* The renderer is in charge of transforming the native image through */
1582 /* the slot's face transformation fields, then converting it into a */
1583 /* bitmap that is returned in `slot->bitmap'. */
1585 /* Note that `slot->bitmap_left' and `slot->bitmap_top' are also used */
1586 /* to specify the position of the bitmap relative to the current pen */
1587 /* position (e.g., coordinates (0,0) on the baseline). Of course, */
1588 /* `slot->format' is also changed to @FT_GLYPH_FORMAT_BITMAP. */
1591 /* Here a small pseudo code fragment which shows how to use */
1592 /* `lsb_delta' and `rsb_delta': */
1595 /* FT_Pos origin_x = 0; */
1596 /* FT_Pos prev_rsb_delta = 0; */
1599 /* for all glyphs do */
1600 /* <compute kern between current and previous glyph and add it to */
1603 /* <load glyph with `FT_Load_Glyph'> */
1605 /* if ( prev_rsb_delta - face->glyph->lsb_delta >= 32 ) */
1606 /* origin_x -= 64; */
1607 /* else if ( prev_rsb_delta - face->glyph->lsb_delta < -32 ) */
1608 /* origin_x += 64; */
1610 /* prev_rsb_delta = face->glyph->rsb_delta; */
1612 /* <save glyph image, or render glyph, or ...> */
1614 /* origin_x += face->glyph->advance.x; */
1618 typedef struct FT_GlyphSlotRec_
1623 FT_UInt reserved; /* retained for binary compatibility */
1626 FT_Glyph_Metrics metrics;
1627 FT_Fixed linearHoriAdvance;
1628 FT_Fixed linearVertAdvance;
1631 FT_Glyph_Format format;
1639 FT_UInt num_subglyphs;
1640 FT_SubGlyph subglyphs;
1650 FT_Slot_Internal internal;
1655 /*************************************************************************/
1656 /*************************************************************************/
1658 /* F U N C T I O N S */
1660 /*************************************************************************/
1661 /*************************************************************************/
1664 /*************************************************************************/
1667 /* FT_Init_FreeType */
1670 /* Initialize a new FreeType library object. The set of modules */
1671 /* that are registered by this function is determined at build time. */
1674 /* alibrary :: A handle to a new library object. */
1677 /* FreeType error code. 0~means success. */
1680 /* In case you want to provide your own memory allocating routines, */
1681 /* use @FT_New_Library instead, followed by a call to */
1682 /* @FT_Add_Default_Modules (or a series of calls to @FT_Add_Module). */
1684 /* For multi-threading applications each thread should have its own */
1685 /* FT_Library object. */
1687 /* If you need reference-counting (cf. @FT_Reference_Library), use */
1688 /* @FT_New_Library and @FT_Done_Library. */
1690 FT_EXPORT( FT_Error )
1691 FT_Init_FreeType( FT_Library *alibrary );
1694 /*************************************************************************/
1697 /* FT_Done_FreeType */
1700 /* Destroy a given FreeType library object and all of its children, */
1701 /* including resources, drivers, faces, sizes, etc. */
1704 /* library :: A handle to the target library object. */
1707 /* FreeType error code. 0~means success. */
1709 FT_EXPORT( FT_Error )
1710 FT_Done_FreeType( FT_Library library );
1713 /*************************************************************************/
1719 /* A list of bit-field constants used within the `flags' field of the */
1720 /* @FT_Open_Args structure. */
1723 /* FT_OPEN_MEMORY :: This is a memory-based stream. */
1725 /* FT_OPEN_STREAM :: Copy the stream from the `stream' field. */
1727 /* FT_OPEN_PATHNAME :: Create a new input stream from a C~path */
1730 /* FT_OPEN_DRIVER :: Use the `driver' field. */
1732 /* FT_OPEN_PARAMS :: Use the `num_params' and `params' fields. */
1734 /* ft_open_memory :: Deprecated; use @FT_OPEN_MEMORY instead. */
1736 /* ft_open_stream :: Deprecated; use @FT_OPEN_STREAM instead. */
1738 /* ft_open_pathname :: Deprecated; use @FT_OPEN_PATHNAME instead. */
1740 /* ft_open_driver :: Deprecated; use @FT_OPEN_DRIVER instead. */
1742 /* ft_open_params :: Deprecated; use @FT_OPEN_PARAMS instead. */
1745 /* The `FT_OPEN_MEMORY', `FT_OPEN_STREAM', and `FT_OPEN_PATHNAME' */
1746 /* flags are mutually exclusive. */
1748 #define FT_OPEN_MEMORY 0x1
1749 #define FT_OPEN_STREAM 0x2
1750 #define FT_OPEN_PATHNAME 0x4
1751 #define FT_OPEN_DRIVER 0x8
1752 #define FT_OPEN_PARAMS 0x10
1754 #define ft_open_memory FT_OPEN_MEMORY /* deprecated */
1755 #define ft_open_stream FT_OPEN_STREAM /* deprecated */
1756 #define ft_open_pathname FT_OPEN_PATHNAME /* deprecated */
1757 #define ft_open_driver FT_OPEN_DRIVER /* deprecated */
1758 #define ft_open_params FT_OPEN_PARAMS /* deprecated */
1761 /*************************************************************************/
1767 /* A simple structure used to pass more or less generic parameters to */
1768 /* @FT_Open_Face. */
1771 /* tag :: A four-byte identification tag. */
1773 /* data :: A pointer to the parameter data. */
1776 /* The ID and function of parameters are driver-specific. See the */
1777 /* various FT_PARAM_TAG_XXX flags for more information. */
1779 typedef struct FT_Parameter_
1787 /*************************************************************************/
1793 /* A structure used to indicate how to open a new font file or */
1794 /* stream. A pointer to such a structure can be used as a parameter */
1795 /* for the functions @FT_Open_Face and @FT_Attach_Stream. */
1798 /* flags :: A set of bit flags indicating how to use the */
1801 /* memory_base :: The first byte of the file in memory. */
1803 /* memory_size :: The size in bytes of the file in memory. */
1805 /* pathname :: A pointer to an 8-bit file pathname. */
1807 /* stream :: A handle to a source stream object. */
1809 /* driver :: This field is exclusively used by @FT_Open_Face; */
1810 /* it simply specifies the font driver to use to open */
1811 /* the face. If set to~0, FreeType tries to load the */
1812 /* face with each one of the drivers in its list. */
1814 /* num_params :: The number of extra parameters. */
1816 /* params :: Extra parameters passed to the font driver when */
1817 /* opening a new face. */
1820 /* The stream type is determined by the contents of `flags' which */
1821 /* are tested in the following order by @FT_Open_Face: */
1823 /* If the `FT_OPEN_MEMORY' bit is set, assume that this is a */
1824 /* memory file of `memory_size' bytes, located at `memory_address'. */
1825 /* The data are are not copied, and the client is responsible for */
1826 /* releasing and destroying them _after_ the corresponding call to */
1827 /* @FT_Done_Face. */
1829 /* Otherwise, if the `FT_OPEN_STREAM' bit is set, assume that a */
1830 /* custom input stream `stream' is used. */
1832 /* Otherwise, if the `FT_OPEN_PATHNAME' bit is set, assume that this */
1833 /* is a normal file and use `pathname' to open it. */
1835 /* If the `FT_OPEN_DRIVER' bit is set, @FT_Open_Face only tries to */
1836 /* open the file with the driver whose handler is in `driver'. */
1838 /* If the `FT_OPEN_PARAMS' bit is set, the parameters given by */
1839 /* `num_params' and `params' is used. They are ignored otherwise. */
1841 /* Ideally, both the `pathname' and `params' fields should be tagged */
1842 /* as `const'; this is missing for API backwards compatibility. In */
1843 /* other words, applications should treat them as read-only. */
1845 typedef struct FT_Open_Args_
1848 const FT_Byte* memory_base;
1849 FT_Long memory_size;
1850 FT_String* pathname;
1854 FT_Parameter* params;
1859 /*************************************************************************/
1865 /* This function calls @FT_Open_Face to open a font by its pathname. */
1868 /* library :: A handle to the library resource. */
1871 /* pathname :: A path to the font file. */
1873 /* face_index :: The index of the face within the font. The first */
1874 /* face has index~0. */
1877 /* aface :: A handle to a new face object. If `face_index' is */
1878 /* greater than or equal to zero, it must be non-NULL. */
1879 /* See @FT_Open_Face for more details. */
1882 /* FreeType error code. 0~means success. */
1885 /* Use @FT_Done_Face to destroy the created @FT_Face object (along */
1886 /* with its slot and sizes). */
1888 FT_EXPORT( FT_Error )
1889 FT_New_Face( FT_Library library,
1890 const char* filepathname,
1895 /*************************************************************************/
1898 /* FT_New_Memory_Face */
1901 /* This function calls @FT_Open_Face to open a font which has been */
1902 /* loaded into memory. */
1905 /* library :: A handle to the library resource. */
1908 /* file_base :: A pointer to the beginning of the font data. */
1910 /* file_size :: The size of the memory chunk used by the font data. */
1912 /* face_index :: The index of the face within the font. The first */
1913 /* face has index~0. */
1916 /* aface :: A handle to a new face object. If `face_index' is */
1917 /* greater than or equal to zero, it must be non-NULL. */
1918 /* See @FT_Open_Face for more details. */
1921 /* FreeType error code. 0~means success. */
1924 /* You must not deallocate the memory before calling @FT_Done_Face. */
1926 FT_EXPORT( FT_Error )
1927 FT_New_Memory_Face( FT_Library library,
1928 const FT_Byte* file_base,
1934 /*************************************************************************/
1940 /* Create a face object from a given resource described by */
1941 /* @FT_Open_Args. */
1944 /* library :: A handle to the library resource. */
1947 /* args :: A pointer to an `FT_Open_Args' structure which must */
1948 /* be filled by the caller. */
1950 /* face_index :: The index of the face within the font. The first */
1951 /* face has index~0. */
1954 /* aface :: A handle to a new face object. If `face_index' is */
1955 /* greater than or equal to zero, it must be non-NULL. */
1956 /* See note below. */
1959 /* FreeType error code. 0~means success. */
1962 /* Unlike FreeType 1.x, this function automatically creates a glyph */
1963 /* slot for the face object which can be accessed directly through */
1964 /* `face->glyph'. */
1966 /* FT_Open_Face can be used to quickly check whether the font */
1967 /* format of a given font resource is supported by FreeType. If the */
1968 /* `face_index' field is negative, the function's return value is~0 */
1969 /* if the font format is recognized, or non-zero otherwise; */
1970 /* the function returns a more or less empty face handle in `*aface' */
1971 /* (if `aface' isn't NULL). The only useful field in this special */
1972 /* case is `face->num_faces' which gives the number of faces within */
1973 /* the font file. After examination, the returned @FT_Face structure */
1974 /* should be deallocated with a call to @FT_Done_Face. */
1976 /* Each new face object created with this function also owns a */
1977 /* default @FT_Size object, accessible as `face->size'. */
1979 /* One @FT_Library instance can have multiple face objects, this is, */
1980 /* @FT_Open_Face and its siblings can be called multiple times using */
1981 /* the same `library' argument. */
1983 /* See the discussion of reference counters in the description of */
1984 /* @FT_Reference_Face. */
1986 FT_EXPORT( FT_Error )
1987 FT_Open_Face( FT_Library library,
1988 const FT_Open_Args* args,
1993 /*************************************************************************/
1996 /* FT_Attach_File */
1999 /* This function calls @FT_Attach_Stream to attach a file. */
2002 /* face :: The target face object. */
2005 /* filepathname :: The pathname. */
2008 /* FreeType error code. 0~means success. */
2010 FT_EXPORT( FT_Error )
2011 FT_Attach_File( FT_Face face,
2012 const char* filepathname );
2015 /*************************************************************************/
2018 /* FT_Attach_Stream */
2021 /* `Attach' data to a face object. Normally, this is used to read */
2022 /* additional information for the face object. For example, you can */
2023 /* attach an AFM file that comes with a Type~1 font to get the */
2024 /* kerning values and other metrics. */
2027 /* face :: The target face object. */
2030 /* parameters :: A pointer to @FT_Open_Args which must be filled by */
2034 /* FreeType error code. 0~means success. */
2037 /* The meaning of the `attach' (i.e., what really happens when the */
2038 /* new file is read) is not fixed by FreeType itself. It really */
2039 /* depends on the font format (and thus the font driver). */
2041 /* Client applications are expected to know what they are doing */
2042 /* when invoking this function. Most drivers simply do not implement */
2043 /* file attachments. */
2045 FT_EXPORT( FT_Error )
2046 FT_Attach_Stream( FT_Face face,
2047 FT_Open_Args* parameters );
2050 /*************************************************************************/
2053 /* FT_Reference_Face */
2056 /* A counter gets initialized to~1 at the time an @FT_Face structure */
2057 /* is created. This function increments the counter. @FT_Done_Face */
2058 /* then only destroys a face if the counter is~1, otherwise it simply */
2059 /* decrements the counter. */
2061 /* This function helps in managing life-cycles of structures which */
2062 /* reference @FT_Face objects. */
2065 /* face :: A handle to a target face object. */
2068 /* FreeType error code. 0~means success. */
2073 FT_EXPORT( FT_Error )
2074 FT_Reference_Face( FT_Face face );
2077 /*************************************************************************/
2083 /* Discard a given face object, as well as all of its child slots and */
2087 /* face :: A handle to a target face object. */