1 /***************************************************************************/
5 /* FreeType high-level API and common types (specification only). */
7 /* Copyright 1996-2001, 2002, 2003, 2004, 2005 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 /***************************************************************************/
20 #error "`ft2build.h' hasn't been included yet!"
21 #error "Please always use macros to include FreeType header files."
23 #error " #include <ft2build.h>"
24 #error " #include FT_FREETYPE_H"
28 #ifndef __FREETYPE_H__
29 #define __FREETYPE_H__
32 /*************************************************************************/
34 /* The `raster' component duplicates some of the declarations in */
35 /* freetype.h for stand-alone use if _FREETYPE_ isn't defined. */
39 /*************************************************************************/
41 /* The FREETYPE_MAJOR and FREETYPE_MINOR macros are used to version the */
42 /* new FreeType design, which is able to host several kinds of font */
43 /* drivers. It starts at 2.0. */
45 #define FREETYPE_MAJOR 2
46 #define FREETYPE_MINOR 1
47 #define FREETYPE_PATCH 10
51 #include FT_CONFIG_CONFIG_H
59 /*************************************************************************/
60 /*************************************************************************/
62 /* B A S I C T Y P E S */
64 /*************************************************************************/
65 /*************************************************************************/
68 /*************************************************************************/
77 /* The FreeType 2 base font interface. */
80 /* This section describes the public high-level API of FreeType 2. */
92 /* FT_FACE_FLAG_SCALABLE */
93 /* FT_FACE_FLAG_FIXED_SIZES */
94 /* FT_FACE_FLAG_FIXED_WIDTH */
95 /* FT_FACE_FLAG_HORIZONTAL */
96 /* FT_FACE_FLAG_VERTICAL */
97 /* FT_FACE_FLAG_SFNT */
98 /* FT_FACE_FLAG_KERNING */
99 /* FT_FACE_FLAG_MULTIPLE_MASTERS */
100 /* FT_FACE_FLAG_GLYPH_NAMES */
101 /* FT_FACE_FLAG_EXTERNAL_STREAM */
102 /* FT_FACE_FLAG_FAST_GLYPHS */
104 /* FT_STYLE_FLAG_BOLD */
105 /* FT_STYLE_FLAG_ITALIC */
108 /* FT_Size_Metrics */
110 /* FT_GlyphSlotRec */
111 /* FT_Glyph_Metrics */
116 /* FT_Init_FreeType */
117 /* FT_Done_FreeType */
118 /* FT_Library_Version */
122 /* FT_New_Memory_Face */
127 /* FT_Attach_Stream */
129 /* FT_Set_Char_Size */
130 /* FT_Set_Pixel_Sizes */
131 /* FT_Set_Transform */
133 /* FT_Get_Char_Index */
134 /* FT_Get_Name_Index */
139 /* FT_OPEN_PATHNAME */
143 /* FT_LOAD_DEFAULT */
145 /* FT_LOAD_MONOCHROME */
146 /* FT_LOAD_LINEAR_DESIGN */
147 /* FT_LOAD_NO_SCALE */
148 /* FT_LOAD_NO_HINTING */
149 /* FT_LOAD_NO_BITMAP */
150 /* FT_LOAD_CROP_BITMAP */
152 /* FT_LOAD_VERTICAL_LAYOUT */
153 /* FT_LOAD_IGNORE_TRANSFORM */
154 /* FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH */
155 /* FT_LOAD_FORCE_AUTOHINT */
156 /* FT_LOAD_NO_RECURSE */
157 /* FT_LOAD_PEDANTIC */
159 /* FT_LOAD_TARGET_NORMAL */
160 /* FT_LOAD_TARGET_LIGHT */
161 /* FT_LOAD_TARGET_MONO */
162 /* FT_LOAD_TARGET_LCD */
163 /* FT_LOAD_TARGET_LCD_V */
165 /* FT_Render_Glyph */
168 /* FT_Kerning_Mode */
169 /* FT_Get_Glyph_Name */
170 /* FT_Get_Postscript_Name */
173 /* FT_Select_Charmap */
175 /* FT_Get_Charmap_Index */
177 /*************************************************************************/
180 /*************************************************************************/
183 /* FT_Glyph_Metrics */
186 /* A structure used to model the metrics of a single glyph. The */
187 /* values are expressed in 26.6 fractional pixel format; if the flag */
188 /* FT_LOAD_NO_SCALE is used, values are returned in font units */
193 /* The glyph's width. */
196 /* The glyph's height. */
198 /* horiBearingX :: */
199 /* Left side bearing for horizontal layout. */
201 /* horiBearingY :: */
202 /* Top side bearing for horizontal layout. */
205 /* Advance width for horizontal layout. */
207 /* vertBearingX :: */
208 /* Left side bearing for vertical layout. */
210 /* vertBearingY :: */
211 /* Top side bearing for vertical layout. */
214 /* Advance height for vertical layout. */
216 typedef struct FT_Glyph_Metrics_
232 /*************************************************************************/
238 /* This structure models the size of a bitmap strike (i.e., a bitmap */
239 /* instance of the font for a given resolution) in a fixed-size font */
240 /* face. It is used for the `available_sizes' field of the */
241 /* @FT_FaceRec structure. */
244 /* height :: The (vertical) baseline-to-baseline distance in pixels. */
245 /* It makes most sense to define the height of a bitmap */
246 /* font in this way. */
248 /* width :: The average width of the font (in pixels). Since the */
249 /* algorithms to compute this value are different for the */
250 /* various bitmap formats, it can only give an additional */
251 /* hint if the `height' value isn't sufficient to select */
252 /* the proper font. For monospaced fonts the average width */
253 /* is the same as the maximum width. */
255 /* size :: The point size in 26.6 fractional format this font shall */
256 /* represent (for a given vertical resolution). */
258 /* x_ppem :: The horizontal ppem value (in 26.6 fractional format). */
260 /* y_ppem :: The vertical ppem value (in 26.6 fractional format). */
261 /* Usually, this is the `nominal' pixel height of the font. */
264 /* The values in this structure are taken from the bitmap font. If */
265 /* the font doesn't provide a parameter it is set to zero to indicate */
266 /* that the information is not available. */
268 /* The following formula converts from dpi to ppem: */
270 /* ppem = size * dpi / 72 */
272 /* where `size' is in points. */
275 /* The `size' parameter is not reliable: There exist fonts (e.g., */
276 /* app850.fon) which have a wrong size for some subfonts; x_ppem */
277 /* and y_ppem are thus set equal to pixel width and height given in */
278 /* in the Windows FNT header. */
280 /* TrueType embedded bitmaps: */
281 /* `size', `width', and `height' values are not contained in the */
282 /* bitmap strike itself. They are computed from the global font */
285 typedef struct FT_Bitmap_Size_
298 /*************************************************************************/
299 /*************************************************************************/
301 /* O B J E C T C L A S S E S */
303 /*************************************************************************/
304 /*************************************************************************/
306 /*************************************************************************/
312 /* A handle to a FreeType library instance. Each `library' is */
313 /* completely independent from the others; it is the `root' of a set */
314 /* of objects like fonts, faces, sizes, etc. */
316 /* It also embeds a memory manager (see @FT_Memory), as well as a */
317 /* scan-line converter object (see @FT_Raster). */
320 /* Library objects are normally created by @FT_Init_FreeType, and */
321 /* destroyed with @FT_Done_FreeType. */
323 typedef struct FT_LibraryRec_ *FT_Library;
326 /*************************************************************************/
332 /* A handle to a given FreeType module object. Each module can be a */
333 /* font driver, a renderer, or anything else that provides services */
334 /* to the formers. */
336 typedef struct FT_ModuleRec_* FT_Module;
339 /*************************************************************************/
345 /* A handle to a given FreeType font driver object. Each font driver */
346 /* is a special module capable of creating faces from font files. */
348 typedef struct FT_DriverRec_* FT_Driver;
351 /*************************************************************************/
357 /* A handle to a given FreeType renderer. A renderer is a special */
358 /* module in charge of converting a glyph image to a bitmap, when */
359 /* necessary. Each renderer supports a given glyph image format, and */
360 /* one or more target surface depths. */
362 typedef struct FT_RendererRec_* FT_Renderer;
365 /*************************************************************************/
371 /* A handle to a given typographic face object. A face object models */
372 /* a given typeface, in a given style. */
375 /* Each face object also owns a single @FT_GlyphSlot object, as well */
376 /* as one or more @FT_Size objects. */
378 /* Use @FT_New_Face or @FT_Open_Face to create a new face object from */
379 /* a given filepathname or a custom input stream. */
381 /* Use @FT_Done_Face to destroy it (along with its slot and sizes). */
384 /* The @FT_FaceRec details the publicly accessible fields of a given */
387 typedef struct FT_FaceRec_* FT_Face;
390 /*************************************************************************/
396 /* A handle to a given size object. Such an object models the data */
397 /* that depends on the current _resolution_ and _character size_ in a */
398 /* given @FT_Face. */
401 /* Each face object owns one or more sizes. There is however a */
402 /* single _active_ size for the face at any time that will be used by */
403 /* functions like @FT_Load_Glyph, @FT_Get_Kerning, etc. */
405 /* You can use the @FT_Activate_Size API to change the current */
406 /* active size of any given face. */
409 /* The @FT_SizeRec structure details the publicly accessible fields */
410 /* of a given face object. */
412 typedef struct FT_SizeRec_* FT_Size;
415 /*************************************************************************/
421 /* A handle to a given `glyph slot'. A slot is a container where it */
422 /* is possible to load any one of the glyphs contained in its parent */
425 /* In other words, each time you call @FT_Load_Glyph or */
426 /* @FT_Load_Char, the slot's content is erased by the new glyph data, */
427 /* i.e. the glyph's metrics, its image (bitmap or outline), and */
428 /* other control information. */
431 /* @FT_GlyphSlotRec details the publicly accessible glyph fields. */
433 typedef struct FT_GlyphSlotRec_* FT_GlyphSlot;
436 /*************************************************************************/
442 /* A handle to a given character map. A charmap is used to translate */
443 /* character codes in a given encoding into glyph indexes for its */
444 /* parent's face. Some font formats may provide several charmaps per */
447 /* Each face object owns zero or more charmaps, but only one of them */
448 /* can be "active" and used by @FT_Get_Char_Index or @FT_Load_Char. */
450 /* The list of available charmaps in a face is available through the */
451 /* "face->num_charmaps" and "face->charmaps" fields of @FT_FaceRec. */
453 /* The currently active charmap is available as "face->charmap". */
454 /* You should call @FT_Set_Charmap to change it. */
457 /* When a new face is created (either through @FT_New_Face or */
458 /* @FT_Open_Face), the library looks for a Unicode charmap within */
459 /* the list and automatically activates it. */
462 /* The @FT_CharMapRec details the publicly accessible fields of a */
463 /* given character map. */
465 typedef struct FT_CharMapRec_* FT_CharMap;
468 /*************************************************************************/
474 /* This macro converts four letter tags into an unsigned long. It is */
475 /* used to define "encoding" identifiers (see @FT_Encoding). */
478 /* Since many 16bit compilers don't like 32bit enumerations, you */
479 /* should redefine this macro in case of problems to something like */
482 /* #define FT_ENC_TAG( value, a, b, c, d ) value */
484 /* to get a simple enumeration without assigning special numbers. */
488 #define FT_ENC_TAG( value, a, b, c, d ) \
489 value = ( ( (FT_UInt32)(a) << 24 ) | \
490 ( (FT_UInt32)(b) << 16 ) | \
491 ( (FT_UInt32)(c) << 8 ) | \
494 #endif /* FT_ENC_TAG */
497 /*************************************************************************/
503 /* An enumeration used to specify encodings supported by charmaps. */
504 /* Used in the @FT_Select_Charmap API function. */
507 /* Because of 32-bit charcodes defined in Unicode (i.e., surrogates), */
508 /* all character codes must be expressed as FT_Longs. */
510 /* The values of this type correspond to specific character */
511 /* repertories (i.e. charsets), and not to text encoding methods */
512 /* (like UTF-8, UTF-16, GB2312_EUC, etc.). */
514 /* Other encodings might be defined in the future. */
517 /* FT_ENCODING_NONE :: */
518 /* The encoding value 0 is reserved. */
520 /* FT_ENCODING_UNICODE :: */
521 /* Corresponds to the Unicode character set. This value covers */
522 /* all versions of the Unicode repertoire, including ASCII and */
523 /* Latin-1. Most fonts include a Unicode charmap, but not all */
526 /* FT_ENCODING_MS_SYMBOL :: */
527 /* Corresponds to the Microsoft Symbol encoding, used to encode */
528 /* mathematical symbols in the 32..255 character code range. For */
529 /* more information, see `http://www.ceviz.net/symbol.htm'. */
531 /* FT_ENCODING_SJIS :: */
532 /* Corresponds to Japanese SJIS encoding. More info at */
533 /* at `http://langsupport.japanreference.com/encoding.shtml'. */
534 /* See note on multi-byte encodings below. */
536 /* FT_ENCODING_GB2312 :: */
537 /* Corresponds to an encoding system for Simplified Chinese as used */
538 /* used in mainland China. */
540 /* FT_ENCODING_BIG5 :: */
541 /* Corresponds to an encoding system for Traditional Chinese as used */
542 /* in Taiwan and Hong Kong. */
544 /* FT_ENCODING_WANSUNG :: */
545 /* Corresponds to the Korean encoding system known as Wansung. */
546 /* For more information see */
547 /* `http://www.microsoft.com/typography/unicode/949.txt'. */
549 /* FT_ENCODING_JOHAB :: */
550 /* The Korean standard character set (KS C-5601-1992), which */
551 /* corresponds to MS Windows code page 1361. This character set */
552 /* includes all possible Hangeul character combinations. */
554 /* FT_ENCODING_ADOBE_LATIN_1 :: */
555 /* Corresponds to a Latin-1 encoding as defined in a Type 1 */
556 /* Postscript font. It is limited to 256 character codes. */
558 /* FT_ENCODING_ADOBE_STANDARD :: */
559 /* Corresponds to the Adobe Standard encoding, as found in Type 1, */
560 /* CFF, and OpenType/CFF fonts. It is limited to 256 character */
563 /* FT_ENCODING_ADOBE_EXPERT :: */
564 /* Corresponds to the Adobe Expert encoding, as found in Type 1, */
565 /* CFF, and OpenType/CFF fonts. It is limited to 256 character */
568 /* FT_ENCODING_ADOBE_CUSTOM :: */
569 /* Corresponds to a custom encoding, as found in Type 1, CFF, and */
570 /* OpenType/CFF fonts. It is limited to 256 character codes. */
572 /* FT_ENCODING_APPLE_ROMAN :: */
573 /* Corresponds to the 8-bit Apple roman encoding. Many TrueType and */
574 /* OpenType fonts contain a charmap for this encoding, since older */
575 /* versions of Mac OS are able to use it. */
577 /* FT_ENCODING_OLD_LATIN_2 :: */
578 /* This value is deprecated and was never used nor reported by */
579 /* FreeType. Don't use or test for it. */
581 /* FT_ENCODING_MS_SJIS :: */
582 /* Same as FT_ENCODING_SJIS. Deprecated. */
584 /* FT_ENCODING_MS_GB2312 :: */
585 /* Same as FT_ENCODING_GB2312. Deprecated. */
587 /* FT_ENCODING_MS_BIG5 :: */
588 /* Same as FT_ENCODING_BIG5. Deprecated. */
590 /* FT_ENCODING_MS_WANSUNG :: */
591 /* Same as FT_ENCODING_WANSUNG. Deprecated. */
593 /* FT_ENCODING_MS_JOHAB :: */
594 /* Same as FT_ENCODING_JOHAB. Deprecated. */
597 /* By default, FreeType automatically synthetizes a Unicode charmap */
598 /* for Postscript fonts, using their glyph names dictionaries. */
599 /* However, it will also report the encodings defined explicitly in */
600 /* the font file, for the cases when they are needed, with the Adobe */
601 /* values as well. */
603 /* FT_ENCODING_NONE is set by the BDF and PCF drivers if the charmap */
604 /* is neither Unicode nor ISO-8859-1 (otherwise it is set to */
605 /* FT_ENCODING_UNICODE). Use `FT_Get_BDF_Charset_ID' to find out */
606 /* which encoding is really present. If, for example, the */
607 /* `cs_registry' field is `KOI8' and the `cs_encoding' field is `R', */
608 /* the font is encoded in KOI8-R. */
610 /* FT_ENCODING_NONE is always set (with a single exception) by the */
611 /* winfonts driver. Use `FT_Get_WinFNT_Header' and examine the */
612 /* `charset' field of the `FT_WinFNT_HeaderRec' structure to find out */
613 /* which encoding is really present. For example, FT_WinFNT_ID_CP1251 */
614 /* (204) means Windows code page 1251 (for Russian). */
616 /* FT_ENCODING_NONE is set if `platform_id' is `TT_PLATFORM_MACINTOSH' */
617 /* and `encoding_id' is not `TT_MAC_ID_ROMAN' (otherwise it is set to */
618 /* FT_ENCODING_APPLE_ROMAN). */
620 /* If `platform_id' is `TT_PLATFORM_MACINTOSH', use the function */
621 /* `FT_Get_CMap_Language_ID' to query the Mac language ID which may be */
622 /* needed to be able to distinguish Apple encoding variants. See */
624 /* http://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/README.TXT */
626 /* to get an idea how to do that. Basically, if the language ID is 0, */
627 /* dont use it, otherwise subtract 1 from the language ID. Then */
628 /* examine `encoding_id'. If, for example, `encoding_id' is */
629 /* `TT_MAC_ID_ROMAN' and the language ID (minus 1) is */
630 /* `TT_MAC_LANGID_GREEK', it is the Greek encoding, not Roman. */
631 /* `TT_MAC_ID_ARABIC' with `TT_MAC_LANGID_FARSI' means the Farsi */
632 /* variant the Arabic encoding. */
634 typedef enum FT_Encoding_
636 FT_ENC_TAG( FT_ENCODING_NONE, 0, 0, 0, 0 ),
638 FT_ENC_TAG( FT_ENCODING_MS_SYMBOL, 's', 'y', 'm', 'b' ),
639 FT_ENC_TAG( FT_ENCODING_UNICODE, 'u', 'n', 'i', 'c' ),
641 FT_ENC_TAG( FT_ENCODING_SJIS, 's', 'j', 'i', 's' ),
642 FT_ENC_TAG( FT_ENCODING_GB2312, 'g', 'b', ' ', ' ' ),
643 FT_ENC_TAG( FT_ENCODING_BIG5, 'b', 'i', 'g', '5' ),
644 FT_ENC_TAG( FT_ENCODING_WANSUNG, 'w', 'a', 'n', 's' ),
645 FT_ENC_TAG( FT_ENCODING_JOHAB, 'j', 'o', 'h', 'a' ),
647 /* for backwards compatibility */
648 FT_ENCODING_MS_SJIS = FT_ENCODING_SJIS,
649 FT_ENCODING_MS_GB2312 = FT_ENCODING_GB2312,
650 FT_ENCODING_MS_BIG5 = FT_ENCODING_BIG5,
651 FT_ENCODING_MS_WANSUNG = FT_ENCODING_WANSUNG,
652 FT_ENCODING_MS_JOHAB = FT_ENCODING_JOHAB,
654 FT_ENC_TAG( FT_ENCODING_ADOBE_STANDARD, 'A', 'D', 'O', 'B' ),
655 FT_ENC_TAG( FT_ENCODING_ADOBE_EXPERT, 'A', 'D', 'B', 'E' ),
656 FT_ENC_TAG( FT_ENCODING_ADOBE_CUSTOM, 'A', 'D', 'B', 'C' ),
657 FT_ENC_TAG( FT_ENCODING_ADOBE_LATIN_1, 'l', 'a', 't', '1' ),
659 FT_ENC_TAG( FT_ENCODING_OLD_LATIN_2, 'l', 'a', 't', '2' ),
661 FT_ENC_TAG( FT_ENCODING_APPLE_ROMAN, 'a', 'r', 'm', 'n' )
666 /*************************************************************************/
669 /* ft_encoding_xxx */
672 /* These constants are deprecated; use the corresponding @FT_Encoding */
673 /* values instead. */
676 /* ft_encoding_none :: see @FT_ENCODING_NONE */
677 /* ft_encoding_unicode :: see @FT_ENCODING_UNICODE */
678 /* ft_encoding_latin_2 :: see @FT_ENCODING_OLD_LATIN_2 */
679 /* ft_encoding_symbol :: see @FT_ENCODING_MS_SYMBOL */
680 /* ft_encoding_sjis :: see @FT_ENCODING_SJIS */
681 /* ft_encoding_gb2312 :: see @FT_ENCODING_GB2312 */
682 /* ft_encoding_big5 :: see @FT_ENCODING_BIG5 */
683 /* ft_encoding_wansung :: see @FT_ENCODING_WANSUNG */
684 /* ft_encoding_johab :: see @FT_ENCODING_JOHAB */
686 /* ft_encoding_adobe_standard :: see @FT_ENCODING_ADOBE_STANDARD */
687 /* ft_encoding_adobe_expert :: see @FT_ENCODING_ADOBE_EXPERT */
688 /* ft_encoding_adobe_custom :: see @FT_ENCODING_ADOBE_CUSTOM */
689 /* ft_encoding_latin_1 :: see @FT_ENCODING_ADOBE_LATIN_1 */
691 /* ft_encoding_apple_roman :: see @FT_ENCODING_APPLE_ROMAN */
693 #define ft_encoding_none FT_ENCODING_NONE
694 #define ft_encoding_unicode FT_ENCODING_UNICODE
695 #define ft_encoding_symbol FT_ENCODING_MS_SYMBOL
696 #define ft_encoding_latin_1 FT_ENCODING_ADOBE_LATIN_1
697 #define ft_encoding_latin_2 FT_ENCODING_OLD_LATIN_2
698 #define ft_encoding_sjis FT_ENCODING_SJIS
699 #define ft_encoding_gb2312 FT_ENCODING_GB2312
700 #define ft_encoding_big5 FT_ENCODING_BIG5
701 #define ft_encoding_wansung FT_ENCODING_WANSUNG
702 #define ft_encoding_johab FT_ENCODING_JOHAB
704 #define ft_encoding_adobe_standard FT_ENCODING_ADOBE_STANDARD
705 #define ft_encoding_adobe_expert FT_ENCODING_ADOBE_EXPERT
706 #define ft_encoding_adobe_custom FT_ENCODING_ADOBE_CUSTOM
707 #define ft_encoding_apple_roman FT_ENCODING_APPLE_ROMAN
710 /*************************************************************************/
716 /* The base charmap structure. */
719 /* face :: A handle to the parent face object. */
721 /* encoding :: An @FT_Encoding tag identifying the charmap. Use */
722 /* this with @FT_Select_Charmap. */
724 /* platform_id :: An ID number describing the platform for the */
725 /* following encoding ID. This comes directly from */
726 /* the TrueType specification and should be emulated */
727 /* for other formats. */
729 /* encoding_id :: A platform specific encoding number. This also */
730 /* comes from the TrueType specification and should be */
731 /* emulated similarly. */
733 typedef struct FT_CharMapRec_
736 FT_Encoding encoding;
737 FT_UShort platform_id;
738 FT_UShort encoding_id;
743 /*************************************************************************/
744 /*************************************************************************/
746 /* B A S E O B J E C T C L A S S E S */
748 /*************************************************************************/
749 /*************************************************************************/
752 /*************************************************************************/
755 /* FT_Face_Internal */
758 /* An opaque handle to an FT_Face_InternalRec structure, used to */
759 /* model private data of a given @FT_Face object. */
761 /* This structure might change between releases of FreeType 2 and is */
762 /* not generally available to client applications. */
764 typedef struct FT_Face_InternalRec_* FT_Face_Internal;
767 /*************************************************************************/
773 /* FreeType root face class structure. A face object models the */
774 /* resolution and point-size independent data found in a font file. */
777 /* num_faces :: In the case where the face is located in a */
778 /* collection (i.e., a file which embeds */
779 /* several faces), this is the total number of */
780 /* faces found in the resource. 1 by default. */
781 /* Accessing non-existent face indices causes */
784 /* face_index :: The index of the face in its font file. */
785 /* Usually, this is 0 for all normal font */
786 /* formats. It can be > 0 in the case of */
787 /* collections (which embed several fonts in a */
788 /* single resource/file). */
790 /* face_flags :: A set of bit flags that give important */
791 /* information about the face; see the */
792 /* @FT_FACE_FLAG_XXX constants for details. */
794 /* style_flags :: A set of bit flags indicating the style of */
795 /* the face (i.e., italic, bold, underline, */
796 /* etc). See the @FT_STYLE_FLAG_XXX */
799 /* num_glyphs :: The total number of glyphs in the face. */
801 /* family_name :: The face's family name. This is an ASCII */
802 /* string, usually in English, which describes */
803 /* the typeface's family (like `Times New */
804 /* Roman', `Bodoni', `Garamond', etc). This */
805 /* is a least common denominator used to list */
806 /* fonts. Some formats (TrueType & OpenType) */
807 /* provide localized and Unicode versions of */
808 /* this string. Applications should use the */
809 /* format specific interface to access them. */
811 /* style_name :: The face's style name. This is an ASCII */
812 /* string, usually in English, which describes */
813 /* the typeface's style (like `Italic', */
814 /* `Bold', `Condensed', etc). Not all font */
815 /* formats provide a style name, so this field */
816 /* is optional, and can be set to NULL. As */
817 /* for `family_name', some formats provide */
818 /* localized/Unicode versions of this string. */
819 /* Applications should use the format specific */
820 /* interface to access them. */
822 /* num_fixed_sizes :: The number of fixed sizes available in this */
823 /* face. This should be set to 0 for scalable */
824 /* fonts, unless its face includes a set of */
825 /* glyphs (called a `strike') for the */
826 /* specified sizes. */
828 /* available_sizes :: An array of sizes specifying the available */
829 /* bitmap/graymap sizes that are contained in */
830 /* in the font face. Should be set to NULL if */
831 /* the field `num_fixed_sizes' is set to 0. */
833 /* num_charmaps :: The total number of character maps in the */
836 /* charmaps :: A table of pointers to the face's charmaps. */
837 /* Used to scan the list of available charmaps */
838 /* -- this table might change after a call to */
839 /* @FT_Attach_File or @FT_Attach_Stream (e.g. */
840 /* if used to hook an additional encoding or */
841 /* CMap to the face object). */
843 /* generic :: A field reserved for client uses. See the */
844 /* @FT_Generic type description. */
846 /* bbox :: The font bounding box. Coordinates are */
847 /* expressed in font units (see units_per_EM). */
848 /* The box is large enough to contain any */
849 /* glyph from the font. Thus, bbox.yMax can */
850 /* be seen as the `maximal ascender', */
851 /* bbox.yMin as the `minimal descender', and */
852 /* the maximal glyph width is given by */
853 /* `bbox.xMax-bbox.xMin' (not to be confused */
854 /* with the maximal _advance_width_). Only */
855 /* relevant for scalable formats. */
857 /* units_per_EM :: The number of font units per EM square for */
858 /* this face. This is typically 2048 for */
859 /* TrueType fonts, 1000 for Type1 fonts, and */
860 /* should be set to the (unrealistic) value 1 */
861 /* for fixed-sizes fonts. Only relevant for */
862 /* scalable formats. */
864 /* ascender :: The face's ascender is the vertical */
865 /* distance from the baseline to the topmost */
866 /* point of any glyph in the face. This */
867 /* field's value is positive, expressed in */
868 /* font units. Some font designs use a value */
869 /* different from `bbox.yMax'. Only relevant */
870 /* for scalable formats. */
872 /* descender :: The face's descender is the vertical */
873 /* distance from the baseline to the */
874 /* bottommost point of any glyph in the face. */
875 /* This field's value is *negative* for values */
876 /* below the baseline. It is expressed in */
877 /* font units. Some font designs use a value */
878 /* different from `bbox.yMin'. Only relevant */
879 /* for scalable formats. */
881 /* height :: The face's height is the vertical distance */
882 /* from one baseline to the next when writing */
883 /* several lines of text. Its value is always */
884 /* positive, expressed in font units. The */
885 /* value can be computed as */
886 /* `ascender+descender+line_gap' where the */
887 /* value of `line_gap' is also called */
888 /* `external leading'. Only relevant for */
889 /* scalable formats. */
891 /* max_advance_width :: The maximal advance width, in font units, */
892 /* for all glyphs in this face. This can be */
893 /* used to make word wrapping computations */
894 /* faster. Only relevant for scalable */
897 /* max_advance_height :: The maximal advance height, in font units, */
898 /* for all glyphs in this face. This is only */
899 /* relevant for vertical layouts, and should */
900 /* be set to the `height' for fonts that do */
901 /* not provide vertical metrics. Only */
902 /* relevant for scalable formats. */
904 /* underline_position :: The position, in font units, of the */
905 /* underline line for this face. It's the */
906 /* center of the underlining stem. Only */
907 /* relevant for scalable formats. */
909 /* underline_thickness :: The thickness, in font units, of the */
910 /* underline for this face. Only relevant for */
911 /* scalable formats. */
913 /* glyph :: The face's associated glyph slot(s). This */
914 /* object is created automatically with a new */
915 /* face object. However, certain kinds of */
916 /* applications (mainly tools like converters) */
917 /* can need more than one slot to ease their */
920 /* size :: The current active size for this face. */
922 /* charmap :: The current active charmap for this face. */
924 typedef struct FT_FaceRec_
934 FT_String* family_name;
935 FT_String* style_name;
937 FT_Int num_fixed_sizes;
938 FT_Bitmap_Size* available_sizes;
941 FT_CharMap* charmaps;
945 /*# the following are only relevant to scalable outlines */
948 FT_UShort units_per_EM;
953 FT_Short max_advance_width;
954 FT_Short max_advance_height;
956 FT_Short underline_position;
957 FT_Short underline_thickness;
969 FT_ListRec sizes_list;
974 FT_Face_Internal internal;
981 /*************************************************************************/
984 /* FT_FACE_FLAG_XXX */
987 /* A list of bit flags used in the `face_flags' field of the */
988 /* @FT_FaceRec structure. They inform client applications of */
989 /* properties of the corresponding face. */
992 /* FT_FACE_FLAG_SCALABLE :: */
993 /* Indicates that the face provides vectorial outlines. This */
994 /* doesn't prevent embedded bitmaps, i.e., a face can have both */
995 /* this bit and @FT_FACE_FLAG_FIXED_SIZES set. */
997 /* FT_FACE_FLAG_FIXED_SIZES :: */
998 /* Indicates that the face contains `fixed sizes', i.e., bitmap */
999 /* strikes for some given pixel sizes. See the `num_fixed_sizes' */
1000 /* and `available_sizes' fields of @FT_FaceRec. */
1002 /* FT_FACE_FLAG_FIXED_WIDTH :: */
1003 /* Indicates that the face contains fixed-width characters (like */
1004 /* Courier, Lucido, MonoType, etc.). */
1006 /* FT_FACE_FLAG_SFNT :: */
1007 /* Indicates that the face uses the `sfnt' storage scheme. For */
1008 /* now, this means TrueType and OpenType. */
1010 /* FT_FACE_FLAG_HORIZONTAL :: */
1011 /* Indicates that the face contains horizontal glyph metrics. This */
1012 /* should be set for all common formats. */
1014 /* FT_FACE_FLAG_VERTICAL :: */
1015 /* Indicates that the face contains vertical glyph metrics. This */
1016 /* is only available in some formats, not all of them. */
1018 /* FT_FACE_FLAG_KERNING :: */
1019 /* Indicates that the face contains kerning information. If set, */
1020 /* the kerning distance can be retrieved through the function */
1021 /* @FT_Get_Kerning. Note that if unset, this function will always */
1022 /* return the vector (0,0). */
1024 /* FT_FACE_FLAG_FAST_GLYPHS :: */
1025 /* THIS FLAG IS DEPRECATED. DO NOT USE OR TEST IT. */
1027 /* FT_FACE_FLAG_MULTIPLE_MASTERS :: */
1028 /* Indicates that the font contains multiple masters and is capable */
1029 /* of interpolating between them. See the multiple-masters */
1030 /* specific API for details. */
1032 /* FT_FACE_FLAG_GLYPH_NAMES :: */
1033 /* Indicates that the font contains glyph names that can be */
1034 /* retrieved through @FT_Get_Glyph_Name. Note that some TrueType */
1035 /* fonts contain broken glyph name tables. Use the function */
1036 /* @FT_Has_PS_Glyph_Names when needed. */
1038 /* FT_FACE_FLAG_EXTERNAL_STREAM :: */
1039 /* Used internally by FreeType to indicate that a face's stream was */
1040 /* provided by the client application and should not be destroyed */
1041 /* when @FT_Done_Face is called. Don't read or test this flag. */
1043 #define FT_FACE_FLAG_SCALABLE ( 1L << 0 )
1044 #define FT_FACE_FLAG_FIXED_SIZES ( 1L << 1 )
1045 #define FT_FACE_FLAG_FIXED_WIDTH ( 1L << 2 )
1046 #define FT_FACE_FLAG_SFNT ( 1L << 3 )
1047 #define FT_FACE_FLAG_HORIZONTAL ( 1L << 4 )
1048 #define FT_FACE_FLAG_VERTICAL ( 1L << 5 )
1049 #define FT_FACE_FLAG_KERNING ( 1L << 6 )
1050 #define FT_FACE_FLAG_FAST_GLYPHS ( 1L << 7 )
1051 #define FT_FACE_FLAG_MULTIPLE_MASTERS ( 1L << 8 )
1052 #define FT_FACE_FLAG_GLYPH_NAMES ( 1L << 9 )
1053 #define FT_FACE_FLAG_EXTERNAL_STREAM ( 1L << 10 )
1058 /*************************************************************************/
1061 /* FT_HAS_HORIZONTAL( face ) */
1064 /* A macro that returns true whenever a face object contains */
1065 /* horizontal metrics (this is true for all font formats though). */
1068 /* @FT_HAS_VERTICAL can be used to check for vertical metrics. */
1070 #define FT_HAS_HORIZONTAL( face ) \
1071 ( face->face_flags & FT_FACE_FLAG_HORIZONTAL )
1074 /*************************************************************************/
1077 /* FT_HAS_VERTICAL( face ) */
1080 /* A macro that returns true whenever a face object contains vertical */
1083 #define FT_HAS_VERTICAL( face ) \
1084 ( face->face_flags & FT_FACE_FLAG_VERTICAL )
1087 /*************************************************************************/
1090 /* FT_HAS_KERNING( face ) */
1093 /* A macro that returns true whenever a face object contains kerning */
1094 /* data that can be accessed with @FT_Get_Kerning. */
1096 #define FT_HAS_KERNING( face ) \
1097 ( face->face_flags & FT_FACE_FLAG_KERNING )
1100 /*************************************************************************/
1103 /* FT_IS_SCALABLE( face ) */
1106 /* A macro that returns true whenever a face object contains a */
1107 /* scalable font face (true for TrueType, Type 1, CID, and */
1108 /* OpenType/CFF font formats. */
1110 #define FT_IS_SCALABLE( face ) \
1111 ( face->face_flags & FT_FACE_FLAG_SCALABLE )
1114 /*************************************************************************/
1117 /* FT_IS_SFNT( face ) */
1120 /* A macro that returns true whenever a face object contains a font */
1121 /* whose format is based on the SFNT storage scheme. This usually */
1122 /* means: TrueType fonts, OpenType fonts, as well as SFNT-based */
1123 /* embedded bitmap fonts. */
1125 /* If this macro is true, all functions defined in @FT_SFNT_NAMES_H */
1126 /* and @FT_TRUETYPE_TABLES_H are available. */
1128 #define FT_IS_SFNT( face ) \
1129 ( face->face_flags & FT_FACE_FLAG_SFNT )
1132 /*************************************************************************/
1135 /* FT_IS_FIXED_WIDTH( face ) */
1138 /* A macro that returns true whenever a face object contains a font */
1139 /* face that contains fixed-width (or "monospace", "fixed-pitch", */
1142 #define FT_IS_FIXED_WIDTH( face ) \
1143 ( face->face_flags & FT_FACE_FLAG_FIXED_WIDTH )
1146 /*************************************************************************/
1149 /* FT_HAS_FIXED_SIZES( face ) */
1152 /* A macro that returns true whenever a face object contains some */
1153 /* embedded bitmaps. See the `available_sizes' field of the */
1154 /* @FT_FaceRec structure. */
1156 #define FT_HAS_FIXED_SIZES( face ) \
1157 ( face->face_flags & FT_FACE_FLAG_FIXED_SIZES )
1163 /*************************************************************************/
1166 /* FT_HAS_FAST_GLYPHS( face ) */
1169 /* Deprecated; indicates that the face contains so-called "fast" */
1170 /* glyph bitmaps. */
1172 #define FT_HAS_FAST_GLYPHS( face ) \
1173 ( face->face_flags & FT_FACE_FLAG_FAST_GLYPHS )
1176 /*************************************************************************/
1179 /* FT_HAS_GLYPH_NAMES( face ) */
1182 /* A macro that returns true whenever a face object contains some */
1183 /* glyph names that can be accessed through @FT_Get_Glyph_Name. */
1185 #define FT_HAS_GLYPH_NAMES( face ) \
1186 ( face->face_flags & FT_FACE_FLAG_GLYPH_NAMES )
1189 /*************************************************************************/
1192 /* FT_HAS_MULTIPLE_MASTERS( face ) */
1195 /* A macro that returns true whenever a face object contains some */
1196 /* multiple masters. The functions provided by */
1197 /* @FT_MULTIPLE_MASTERS_H are then available to choose the exact */
1198 /* design you want. */
1200 #define FT_HAS_MULTIPLE_MASTERS( face ) \
1201 ( face->face_flags & FT_FACE_FLAG_MULTIPLE_MASTERS )
1204 /*************************************************************************/
1207 /* FT_STYLE_FLAG_XXX */
1210 /* A list of bit-flags used to indicate the style of a given face. */
1211 /* These are used in the `style_flags' field of @FT_FaceRec. */
1214 /* FT_STYLE_FLAG_ITALIC :: */
1215 /* Indicates that a given face is italicized. */
1217 /* FT_STYLE_FLAG_BOLD :: */
1218 /* Indicates that a given face is bold. */
1220 #define FT_STYLE_FLAG_ITALIC ( 1 << 0 )
1221 #define FT_STYLE_FLAG_BOLD ( 1 << 1 )
1224 /*************************************************************************/
1227 /* FT_Size_Internal */
1230 /* An opaque handle to an FT_Size_InternalRec structure, used to */
1231 /* model private data of a given FT_Size object. */
1233 typedef struct FT_Size_InternalRec_* FT_Size_Internal;
1236 /*************************************************************************/
1239 /* FT_Size_Metrics */
1242 /* The size metrics structure returned scaled important distances for */
1243 /* a given size object. */
1246 /* x_ppem :: The character width, expressed in integer pixels. */
1247 /* This is the width of the EM square expressed in */
1248 /* pixels, hence the term `ppem' (pixels per EM). */
1250 /* y_ppem :: The character height, expressed in integer pixels. */
1251 /* This is the height of the EM square expressed in */
1252 /* pixels, hence the term `ppem' (pixels per EM). */
1254 /* x_scale :: A simple 16.16 fixed point format coefficient used */
1255 /* to scale horizontal distances expressed in font */
1256 /* units to fractional (26.6) pixel coordinates. */
1258 /* y_scale :: A simple 16.16 fixed point format coefficient used */
1259 /* to scale vertical distances expressed in font */
1260 /* units to fractional (26.6) pixel coordinates. */
1262 /* ascender :: The ascender, expressed in 26.6 fixed point */
1263 /* pixels. Positive for ascenders above the */
1266 /* descender :: The descender, expressed in 26.6 fixed point */
1267 /* pixels. Negative for descenders below the */
1270 /* height :: The text height, expressed in 26.6 fixed point */
1271 /* pixels. Always positive. */
1273 /* max_advance :: Maximum horizontal advance, expressed in 26.6 */
1274 /* fixed point pixels. Always positive. */
1277 /* For scalable fonts, the values of `ascender', `descender', and */
1278 /* `height' are scaled versions of `face->ascender', */
1279 /* `face->descender', and `face->height', respectively. */
1281 /* Unfortunately, due to glyph hinting, these values might not be */
1282 /* exact for certain fonts. They thus must be treated as unreliable */
1283 /* with an error margin of at least one pixel! */
1285 /* Indeed, the only way to get the exact pixel ascender and descender */
1286 /* is to render _all_ glyphs. As this would be a definite */
1287 /* performance hit, it is up to client applications to perform such */
1290 typedef struct FT_Size_Metrics_
1292 FT_UShort x_ppem; /* horizontal pixels per EM */
1293 FT_UShort y_ppem; /* vertical pixels per EM */
1295 FT_Fixed x_scale; /* two scales used to convert font units */
1296 FT_Fixed y_scale; /* to 26.6 frac. pixel coordinates */
1298 FT_Pos ascender; /* ascender in 26.6 frac. pixels */
1299 FT_Pos descender; /* descender in 26.6 frac. pixels */
1300 FT_Pos height; /* text height in 26.6 frac. pixels */
1301 FT_Pos max_advance; /* max horizontal advance, in 26.6 pixels */
1306 /*************************************************************************/
1312 /* FreeType root size class structure. A size object models the */
1313 /* resolution and pointsize dependent data of a given face. */
1316 /* face :: Handle to the parent face object. */
1318 /* generic :: A typeless pointer, which is unused by the FreeType */
1319 /* library or any of its drivers. It can be used by */
1320 /* client applications to link their own data to each size */
1323 /* metrics :: Metrics for this size object. This field is read-only. */
1325 typedef struct FT_SizeRec_
1327 FT_Face face; /* parent face object */
1328 FT_Generic generic; /* generic pointer for client uses */
1329 FT_Size_Metrics metrics; /* size metrics */
1330 FT_Size_Internal internal;
1335 /*************************************************************************/
1341 /* The subglyph structure is an internal object used to describe */
1342 /* subglyphs (for example, in the case of composites). */
1345 /* The subglyph implementation is not part of the high-level API, */
1346 /* hence the forward structure declaration. */
1348 typedef struct FT_SubGlyphRec_* FT_SubGlyph;
1351 /*************************************************************************/
1354 /* FT_Slot_Internal */
1357 /* An opaque handle to an FT_Slot_InternalRec structure, used to */
1358 /* model private data of a given FT_GlyphSlot object. */
1360 typedef struct FT_Slot_InternalRec_* FT_Slot_Internal;
1363 /*************************************************************************/
1366 /* FT_GlyphSlotRec */
1369 /* FreeType root glyph slot class structure. A glyph slot is a */
1370 /* container where individual glyphs can be loaded, be they */
1371 /* vectorial or bitmap/graymaps. */
1374 /* library :: A handle to the FreeType library instance */
1375 /* this slot belongs to. */
1377 /* face :: A handle to the parent face object. */
1379 /* next :: In some cases (like some font tools), several */
1380 /* glyph slots per face object can be a good */
1381 /* thing. As this is rare, the glyph slots are */
1382 /* listed through a direct, single-linked list */
1383 /* using its `next' field. */
1385 /* generic :: A typeless pointer which is unused by the */
1386 /* FreeType library or any of its drivers. It */
1387 /* can be used by client applications to link */
1388 /* their own data to each glyph slot object. */
1390 /* metrics :: The metrics of the last loaded glyph in the */
1391 /* slot. The returned values depend on the last */
1392 /* load flags (see the @FT_Load_Glyph API */
1393 /* function) and can be expressed either in 26.6 */
1394 /* fractional pixels or font units. */
1396 /* Note that even when the glyph image is */
1397 /* transformed, the metrics are not. */
1399 /* linearHoriAdvance :: For scalable formats only, this field holds */
1400 /* the linearly scaled horizontal advance width */
1401 /* for the glyph (i.e. the scaled and unhinted */
1402 /* value of the hori advance). This can be */
1403 /* important to perform correct WYSIWYG layout. */
1405 /* Note that this value is expressed by default */
1406 /* in 16.16 pixels. However, when the glyph is */
1407 /* loaded with the FT_LOAD_LINEAR_DESIGN flag, */
1408 /* this field contains simply the value of the */
1409 /* advance in original font units. */
1411 /* linearVertAdvance :: For scalable formats only, this field holds */
1412 /* the linearly scaled vertical advance height */
1413 /* for the glyph. See linearHoriAdvance for */
1416 /* advance :: This is the transformed advance width for the */
1419 /* format :: This field indicates the format of the image */
1420 /* contained in the glyph slot. Typically */
1421 /* FT_GLYPH_FORMAT_BITMAP, */
1422 /* FT_GLYPH_FORMAT_OUTLINE, and */
1423 /* FT_GLYPH_FORMAT_COMPOSITE, but others are */
1426 /* bitmap :: This field is used as a bitmap descriptor */
1427 /* when the slot format is */
1428 /* FT_GLYPH_FORMAT_BITMAP. Note that the */
1429 /* address and content of the bitmap buffer can */
1430 /* change between calls of @FT_Load_Glyph and a */
1431 /* few other functions. */
1433 /* bitmap_left :: This is the bitmap's left bearing expressed */
1434 /* in integer pixels. Of course, this is only */
1435 /* valid if the format is */
1436 /* FT_GLYPH_FORMAT_BITMAP. */
1438 /* bitmap_top :: This is the bitmap's top bearing expressed in */
1439 /* integer pixels. Remember that this is the */
1440 /* distance from the baseline to the top-most */
1441 /* glyph scanline, upwards y-coordinates being */
1444 /* outline :: The outline descriptor for the current glyph */
1445 /* image if its format is */
1446 /* FT_GLYPH_FORMAT_OUTLINE. */
1448 /* num_subglyphs :: The number of subglyphs in a composite glyph. */
1449 /* This field is only valid for the composite */
1450 /* glyph format that should normally only be */
1451 /* loaded with the @FT_LOAD_NO_RECURSE flag. */
1452 /* For now this is internal to FreeType. */
1454 /* subglyphs :: An array of subglyph descriptors for */
1455 /* composite glyphs. There are `num_subglyphs' */
1456 /* elements in there. Currently internal to */
1459 /* control_data :: Certain font drivers can also return the */
1460 /* control data for a given glyph image (e.g. */
1461 /* TrueType bytecode, Type 1 charstrings, etc.). */
1462 /* This field is a pointer to such data. */
1464 /* control_len :: This is the length in bytes of the control */
1467 /* other :: Really wicked formats can use this pointer to */
1468 /* present their own glyph image to client apps. */
1469 /* Note that the app will need to know about the */
1472 /* lsb_delta :: The difference between hinted and unhinted */
1473 /* left side bearing while autohinting is */
1474 /* active. Zero otherwise. */
1476 /* rsb_delta :: The difference between hinted and unhinted */
1477 /* right side bearing while autohinting is */
1478 /* active. Zero otherwise. */
1481 /* If @FT_Load_Glyph is called with default flags (see */
1482 /* @FT_LOAD_DEFAULT) the glyph image is loaded in the glyph slot in */
1483 /* its native format (e.g. a vectorial outline for TrueType and */
1484 /* Type 1 formats). */
1486 /* This image can later be converted into a bitmap by calling */
1487 /* @FT_Render_Glyph. This function finds the current renderer for */
1488 /* the native image's format then invokes it. */
1490 /* The renderer is in charge of transforming the native image through */
1491 /* the slot's face transformation fields, then convert it into a */
1492 /* bitmap that is returned in `slot->bitmap'. */
1494 /* Note that `slot->bitmap_left' and `slot->bitmap_top' are also used */
1495 /* to specify the position of the bitmap relative to the current pen */
1496 /* position (e.g. coordinates [0,0] on the baseline). Of course, */
1497 /* `slot->format' is also changed to `FT_GLYPH_FORMAT_BITMAP' . */
1500 /* Here a small pseudo code fragment which shows how to use */
1501 /* `lsb_delta' and `rsb_delta': */
1504 /* FT_Pos origin_x = 0; */
1505 /* FT_Pos prev_rsb_delta = 0; */
1508 /* for all glyphs do */
1509 /* <compute kern between current and previous glyph and add it to */
1512 /* <load glyph with `FT_Load_Glyph'> */
1514 /* if ( prev_rsb_delta - face->glyph->lsb_delta >= 32 ) */
1515 /* origin_x -= 64; */
1516 /* else if ( prev_rsb_delta - face->glyph->lsb_delta < -32 ) */
1517 /* origin_x += 64; */
1519 /* prev_rsb_delta = face->glyph->rsb_delta; */
1521 /* <save glyph image, or render glyph, or ...> */
1523 /* origin_x += face->glyph->advance.x; */
1527 typedef struct FT_GlyphSlotRec_
1532 FT_UInt reserved; /* retained for binary compatibility */
1535 FT_Glyph_Metrics metrics;
1536 FT_Fixed linearHoriAdvance;
1537 FT_Fixed linearVertAdvance;
1540 FT_Glyph_Format format;
1548 FT_UInt num_subglyphs;
1549 FT_SubGlyph subglyphs;
1559 FT_Slot_Internal internal;
1564 /*************************************************************************/
1565 /*************************************************************************/
1567 /* F U N C T I O N S */
1569 /*************************************************************************/
1570 /*************************************************************************/
1573 /*************************************************************************/
1576 /* FT_Init_FreeType */
1579 /* Initializes a new FreeType library object. The set of modules */
1580 /* that are registered by this function is determined at build time. */
1583 /* alibrary :: A handle to a new library object. */
1586 /* FreeType error code. 0 means success. */
1588 FT_EXPORT( FT_Error )
1589 FT_Init_FreeType( FT_Library *alibrary );
1592 /*************************************************************************/
1595 /* FT_Library_Version */
1598 /* Return the version of the FreeType library being used. This is */
1599 /* useful when dynamically linking to the library, since one cannot */
1600 /* use the macros FT_FREETYPE_MAJOR, FT_FREETYPE_MINOR, and */
1601 /* FT_FREETYPE_PATCH. */
1604 /* library :: A source library handle. */
1607 /* amajor :: The major version number. */
1609 /* aminor :: The minor version number. */
1611 /* apatch :: The patch version number. */
1614 /* The reason why this function takes a 'library' argument is because */
1615 /* certain programs implement library initialization in a custom way */
1616 /* that doesn't use `FT_Init_FreeType'. */
1618 /* In such cases, the library version might not be available before */
1619 /* the library object has been created. */
1622 FT_Library_Version( FT_Library library,
1628 /*************************************************************************/
1631 /* FT_Done_FreeType */
1634 /* Destroys a given FreeType library object and all of its childs, */
1635 /* including resources, drivers, faces, sizes, etc. */
1638 /* library :: A handle to the target library object. */
1641 /* FreeType error code. 0 means success. */
1643 FT_EXPORT( FT_Error )
1644 FT_Done_FreeType( FT_Library library );
1647 /*************************************************************************/
1653 /* A list of bit-field constants used within the `flags' field of the */
1654 /* @FT_Open_Args structure. */
1657 /* FT_OPEN_MEMORY :: This is a memory-based stream. */
1659 /* FT_OPEN_STREAM :: Copy the stream from the `stream' field. */
1661 /* FT_OPEN_PATHNAME :: Create a new input stream from a C */
1664 /* FT_OPEN_DRIVER :: Use the `driver' field. */
1666 /* FT_OPEN_PARAMS :: Use the `num_params' & `params' field. */
1668 /* ft_open_memory :: Deprecated; use @FT_OPEN_MEMORY instead. */
1670 /* ft_open_stream :: Deprecated; use @FT_OPEN_STREAM instead. */
1672 /* ft_open_pathname :: Deprecated; use @FT_OPEN_PATHNAME instead. */
1674 /* ft_open_driver :: Deprecated; use @FT_OPEN_DRIVER instead. */
1676 /* ft_open_params :: Deprecated; use @FT_OPEN_PARAMS instead. */
1679 /* The `FT_OPEN_MEMORY', `FT_OPEN_STREAM', and `FT_OPEN_PATHNAME' */
1680 /* flags are mutually exclusive. */
1682 #define FT_OPEN_MEMORY 0x1
1683 #define FT_OPEN_STREAM 0x2
1684 #define FT_OPEN_PATHNAME 0x4
1685 #define FT_OPEN_DRIVER 0x8
1686 #define FT_OPEN_PARAMS 0x10
1688 #define ft_open_memory FT_OPEN_MEMORY /* deprecated */
1689 #define ft_open_stream FT_OPEN_STREAM /* deprecated */
1690 #define ft_open_pathname FT_OPEN_PATHNAME /* deprecated */
1691 #define ft_open_driver FT_OPEN_DRIVER /* deprecated */
1692 #define ft_open_params FT_OPEN_PARAMS /* deprecated */
1695 /*************************************************************************/
1701 /* A simple structure used to pass more or less generic parameters */
1702 /* to @FT_Open_Face. */
1705 /* tag :: A 4-byte identification tag. */
1707 /* data :: A pointer to the parameter data. */
1710 /* The id and function of parameters are driver-specific. */
1712 typedef struct FT_Parameter_
1720 /*************************************************************************/
1726 /* A structure used to indicate how to open a new font file/stream. */
1727 /* A pointer to such a structure can be used as a parameter for the */
1728 /* functions @FT_Open_Face and @FT_Attach_Stream. */
1731 /* flags :: A set of bit flags indicating how to use the */
1734 /* memory_base :: The first byte of the file in memory. */
1736 /* memory_size :: The size in bytes of the file in memory. */
1738 /* pathname :: A pointer to an 8-bit file pathname. */
1740 /* stream :: A handle to a source stream object. */
1742 /* driver :: This field is exclusively used by @FT_Open_Face; */
1743 /* it simply specifies the font driver to use to open */
1744 /* the face. If set to 0, FreeType will try to load */
1745 /* the face with each one of the drivers in its list. */
1747 /* num_params :: The number of extra parameters. */
1749 /* params :: Extra parameters passed to the font driver when */
1750 /* opening a new face. */
1753 /* The stream type is determined by the contents of `flags' which */
1754 /* are tested in the following order by @FT_Open_Face: */
1756 /* If the `FT_OPEN_MEMORY' bit is set, assume that this is a */
1757 /* memory file of `memory_size' bytes,located at `memory_address'. */
1759 /* Otherwise, if the `FT_OPEN_STREAM' bit is set, assume that a */
1760 /* custom input stream `stream' is used. */
1762 /* Otherwise, if the `FT_OPEN_PATHNAME' bit is set, assume that this */
1763 /* is a normal file and use `pathname' to open it. */
1765 /* If the `FT_OPEN_DRIVER' bit is set, @FT_Open_Face will only try to */
1766 /* open the file with the driver whose handler is in `driver'. */
1768 /* If the `FT_OPEN_PARAMS' bit is set, the parameters given by */
1769 /* `num_params' and `params' will be used. They are ignored */
1772 typedef struct FT_Open_Args_
1775 const FT_Byte* memory_base;
1776 FT_Long memory_size;
1777 FT_String* pathname;
1781 FT_Parameter* params;
1786 /*************************************************************************/
1792 /* Creates a new face object from a given resource and typeface index */
1793 /* using a pathname to the font file. */
1796 /* library :: A handle to the library resource. */
1799 /* pathname :: A path to the font file. */
1801 /* face_index :: The index of the face within the resource. The */
1802 /* first face has index 0. */
1805 /* aface :: A handle to a new face object. */
1808 /* FreeType error code. 0 means success. */
1811 /* Unlike FreeType 1.x, this function automatically creates a glyph */
1812 /* slot for the face object which can be accessed directly through */
1813 /* `face->glyph'. */
1815 /* @FT_New_Face can be used to determine and/or check the font format */
1816 /* of a given font resource. If the `face_index' field is negative, */
1817 /* the function will _not_ return any face handle in `aface'; the */
1818 /* return value is 0 if the font format is recognized, or non-zero */
1821 /* Each new face object created with this function also owns a */
1822 /* default @FT_Size object, accessible as `face->size'. */
1824 FT_EXPORT( FT_Error )
1825 FT_New_Face( FT_Library library,
1826 const char* filepathname,
1831 /*************************************************************************/
1834 /* FT_New_Memory_Face */
1837 /* Creates a new face object from a given resource and typeface index */
1838 /* using a font file already loaded into memory. */
1841 /* library :: A handle to the library resource. */
1844 /* file_base :: A pointer to the beginning of the font data. */
1846 /* file_size :: The size of the memory chunk used by the font data. */
1848 /* face_index :: The index of the face within the resource. The */
1849 /* first face has index 0. */
1852 /* aface :: A handle to a new face object. */
1855 /* FreeType error code. 0 means success. */
1858 /* The font data bytes are used _directly_ by the @FT_Face object. */
1859 /* This means that they are not copied, and that the client is */
1860 /* responsible for releasing/destroying them _after_ the */
1861 /* corresponding call to @FT_Done_Face . */
1863 /* Unlike FreeType 1.x, this function automatically creates a glyph */
1864 /* slot for the face object which can be accessed directly through */
1865 /* `face->glyph'. */
1867 /* @FT_New_Memory_Face can be used to determine and/or check the font */
1868 /* format of a given font resource. If the `face_index' field is */
1869 /* negative, the function will _not_ return any face handle in */
1870 /* `aface'; the return value is 0 if the font format is recognized, */
1871 /* or non-zero otherwise. */
1873 FT_EXPORT( FT_Error )
1874 FT_New_Memory_Face( FT_Library library,
1875 const FT_Byte* file_base,
1881 /*************************************************************************/
1887 /* Opens a face object from a given resource and typeface index using */
1888 /* an `FT_Open_Args' structure. If the face object doesn't exist, it */
1889 /* will be created. */
1892 /* library :: A handle to the library resource. */
1895 /* args :: A pointer to an `FT_Open_Args' structure which must */
1896 /* be filled by the caller. */
1898 /* face_index :: The index of the face within the resource. The */
1899 /* first face has index 0. */
1902 /* aface :: A handle to a new face object. */
1905 /* FreeType error code. 0 means success. */
1908 /* Unlike FreeType 1.x, this function automatically creates a glyph */
1909 /* slot for the face object which can be accessed directly through */
1910 /* `face->glyph'. */
1912 /* @FT_Open_Face can be used to determine and/or check the font */
1913 /* format of a given font resource. If the `face_index' field is */
1914 /* negative, the function will _not_ return any face handle in */
1915 /* `*aface'; the function's return value is 0 if the font format is */
1916 /* recognized, or non-zero otherwise. */
1918 FT_EXPORT( FT_Error )
1919 FT_Open_Face( FT_Library library,
1920 const FT_Open_Args* args,
1925 /*************************************************************************/
1928 /* FT_Attach_File */
1931 /* `Attaches' a given font file to an existing face. This is usually */
1932 /* to read additional information for a single face object. For */
1933 /* example, it is used to read the AFM files that come with Type 1 */
1934 /* fonts in order to add kerning data and other metrics. */
1937 /* face :: The target face object. */
1940 /* filepathname :: An 8-bit pathname naming the `metrics' file. */
1943 /* FreeType error code. 0 means success. */
1946 /* If your font file is in memory, or if you want to provide your */
1947 /* own input stream object, use @FT_Attach_Stream. */
1949 /* The meaning of the `attach' action (i.e., what really happens when */
1950 /* the new file is read) is not fixed by FreeType itself. It really */
1951 /* depends on the font format (and thus the font driver). */
1953 /* Client applications are expected to know what they are doing */
1954 /* when invoking this function. Most drivers simply do not implement */
1955 /* file attachments. */
1957 FT_EXPORT( FT_Error )
1958 FT_Attach_File( FT_Face face,
1959 const char* filepathname );
1962 /*************************************************************************/
1965 /* FT_Attach_Stream */
1968 /* This function is similar to @FT_Attach_File with the exception */
1969 /* that it reads the attachment from an arbitrary stream. */
1972 /* face :: The target face object. */
1975 /* parameters :: A pointer to an FT_Open_Args structure used to */
1976 /* describe the input stream to FreeType. */
1978 /* FreeType error code. 0 means success. */
1981 /* The meaning of the `attach' (i.e. what really happens when the */
1982 /* new file is read) is not fixed by FreeType itself. It really */
1983 /* depends on the font format (and thus the font driver). */
1985 /* Client applications are expected to know what they are doing */
1986 /* when invoking this function. Most drivers simply do not implement */
1987 /* file attachments. */
1989 FT_EXPORT( FT_Error )
1990 FT_Attach_Stream( FT_Face face,
1991 FT_Open_Args* parameters );
1994 /*************************************************************************/
2000 /* Discards a given face object, as well as all of its child slots */
2004 /* face :: A handle to a target face object. */
2007 /* FreeType error code. 0 means success. */
2009 FT_EXPORT( FT_Error )
2010 FT_Done_Face( FT_Face face );
2013 /*************************************************************************/
2016 /* FT_Set_Char_Size */
2019 /* Sets the character dimensions of a given face object. The */
2020 /* `char_width' and `char_height' values are used for the width and */
2021 /* height, respectively, expressed in 26.6 fractional points. */
2023 /* If the horizontal or vertical resolution values are zero, a */
2024 /* default value of 72dpi is used. Similarly, if one of the */
2025 /* character dimensions is zero, its value is set equal to the other. */
2028 /* face :: A handle to a target face object. */
2031 /* char_width :: The character width, in 26.6 fractional points. */
2033 /* char_height :: The character height, in 26.6 fractional */
2036 /* horz_resolution :: The horizontal resolution. */
2038 /* vert_resolution :: The vertical resolution. */
2041 /* FreeType error code. 0 means success. */
2044 /* For BDF and PCF formats, this function uses the `PIXEL_SIZE' */
2045 /* property of the bitmap font; the `char_width' parameter is */
2048 FT_EXPORT( FT_Error )
2049 FT_Set_Char_Size( FT_Face face,
2050 FT_F26Dot6 char_width,
2051 FT_F26Dot6 char_height,
2052 FT_UInt horz_resolution,
2053 FT_UInt vert_resolution );
2056 /*************************************************************************/
2059 /* FT_Set_Pixel_Sizes */
2062 /* Sets the character dimensions of a given face object. The width */
2063 /* and height are expressed in integer pixels. */
2065 /* If one of the character dimensions is zero, its value is set equal */
2069 /* face :: A handle to the target face object. */
2072 /* pixel_width :: The character width, in integer pixels. */
2074 /* pixel_height :: The character height, in integer pixels. */
2077 /* FreeType error code. 0 means success. */
2080 /* The values of `pixel_width' and `pixel_height' correspond to the */
2081 /* pixel values of the _typographic_ character size, which are NOT */
2082 /* necessarily the same as the dimensions of the glyph `bitmap */
2085 /* The `character size' is really the size of an abstract square */
2086 /* called the `EM', used to design the font. However, depending */
2087 /* on the font design, glyphs will be smaller or greater than the */
2090 /* This means that setting the pixel size to, say, 8x8 doesn't */
2091 /* guarantee in any way that you will get glyph bitmaps that all fit */
2092 /* within an 8x8 cell (sometimes even far from it). */
2094 /* For bitmap fonts, `pixel_height' usually is a reliable value for */
2095 /* the height of the bitmap cell. Drivers for bitmap font formats */
2096 /* which contain a single bitmap strike only (BDF, PCF, FNT) ignore */
2097 /* `pixel_width'. */
2099 /* For BDF and PCF formats, this function uses the sum of the */
2100 /* `FONT_ASCENT' and `FONT_DESCENT' properties of the bitmap font. */
2102 FT_EXPORT( FT_Error )
2103 FT_Set_Pixel_Sizes( FT_Face face,
2104 FT_UInt pixel_width,
2105 FT_UInt pixel_height );
2108 /*************************************************************************/
2114 /* A function used to load a single glyph within a given glyph slot, */
2115 /* for a given size. */
2118 /* face :: A handle to the target face object where the glyph */
2119 /* will be loaded. */
2122 /* glyph_index :: The index of the glyph in the font file. For */
2123 /* CID-keyed fonts (either in PS or in CFF format) */
2124 /* this argument specifies the CID value. */
2126 /* load_flags :: A flag indicating what to load for this glyph. The */
2127 /* @FT_LOAD_XXX constants can be used to control the */
2128 /* glyph loading process (e.g., whether the outline */
2129 /* should be scaled, whether to load bitmaps or not, */
2130 /* whether to hint the outline, etc). */
2133 /* FreeType error code. 0 means success. */
2136 /* If the glyph image is not a bitmap, and if the bit flag */
2137 /* FT_LOAD_IGNORE_TRANSFORM is unset, the glyph image will be */
2138 /* transformed with the information passed to a previous call to */
2139 /* @FT_Set_Transform. */
2141 /* Note that this also transforms the `face.glyph.advance' field, but */
2142 /* *not* the values in `face.glyph.metrics'. */
2144 FT_EXPORT( FT_Error )
2145 FT_Load_Glyph( FT_Face face,
2146 FT_UInt glyph_index,
2147 FT_Int32 load_flags );
2150 /*************************************************************************/
2156 /* A function used to load a single glyph within a given glyph slot, */
2157 /* for a given size, according to its character code. */
2160 /* face :: A handle to a target face object where the glyph */
2161 /* will be loaded. */
2164 /* char_code :: The glyph's character code, according to the */
2165 /* current charmap used in the face. */
2167 /* load_flags :: A flag indicating what to load for this glyph. The */
2168 /* @FT_LOAD_XXX constants can be used to control the */
2169 /* glyph loading process (e.g., whether the outline */
2170 /* should be scaled, whether to load bitmaps or not, */
2171 /* whether to hint the outline, etc). */
2174 /* FreeType error code. 0 means success. */
2177 /* If the face has no current charmap, or if the character code */
2178 /* is not defined in the charmap, this function will return an */
2181 /* If the glyph image is not a bitmap, and if the bit flag */
2182 /* FT_LOAD_IGNORE_TRANSFORM is unset, the glyph image will be */
2183 /* transformed with the information passed to a previous call to */
2184 /* @FT_Set_Transform. */
2186 /* Note that this also transforms the `face.glyph.advance' field, but */
2187 /* *not* the values in `face.glyph.metrics'. */
2189 FT_EXPORT( FT_Error )
2190 FT_Load_Char( FT_Face face,
2192 FT_Int32 load_flags );
2195 /***************************************************************************
2201 * A list of bit-field constants, used with @FT_Load_Glyph to indicate
2202 * what kind of operations to perform during glyph loading.
2205 * FT_LOAD_DEFAULT ::
2206 * Corresponding to 0, this value is used a default glyph load. In this
2207 * case, the following will happen:
2209 * 1. FreeType looks for a bitmap for the glyph corresponding to the
2210 * face's current size. If one is found, the function returns. The
2211 * bitmap data can be accessed from the glyph slot (see note below).
2213 * 2. If no embedded bitmap is searched or found, FreeType looks for a
2214 * scalable outline. If one is found, it is loaded from the font
2215 * file, scaled to device pixels, then "hinted" to the pixel grid in
2216 * order to optimize it. The outline data can be accessed from the
2217 * glyph slot (see note below).
2219 * Note that by default, the glyph loader doesn't render outlines into
2220 * bitmaps. The following flags are used to modify this default
2221 * behaviour to more specific and useful cases.
2223 * FT_LOAD_NO_SCALE ::
2224 * Don't scale the vector outline being loaded to 26.6 fractional
2225 * pixels, but kept in font units. Note that this also disables
2226 * hinting and the loading of embedded bitmaps. You should only use it
2227 * when you want to retrieve the original glyph outlines in font units.
2229 * FT_LOAD_NO_HINTING ::
2230 * Don't hint glyph outlines after their scaling to device pixels.
2231 * This generally generates "blurrier" glyphs in anti-aliased modes.
2233 * This flag is ignored if @FT_LOAD_NO_SCALE is set.
2236 * Render the glyph outline immediately into a bitmap before the glyph
2237 * loader returns. By default, the glyph is rendered for the
2238 * @FT_RENDER_MODE_NORMAL mode, which corresponds to 8-bit anti-aliased
2239 * bitmaps using 256 opacity levels. You can use either
2240 * @FT_LOAD_TARGET_MONO or @FT_LOAD_MONOCHROME to render 1-bit
2241 * monochrome bitmaps.
2243 * This flag is ignored if @FT_LOAD_NO_SCALE is set.
2245 * FT_LOAD_NO_BITMAP ::
2246 * Don't look for bitmaps when loading the glyph. Only scalable
2247 * outlines will be loaded when available, and scaled, hinted, or
2248 * rendered depending on other bit flags.
2250 * This does not prevent you from rendering outlines to bitmaps
2251 * with @FT_LOAD_RENDER, however.
2253 * FT_LOAD_VERTICAL_LAYOUT ::
2254 * Prepare the glyph image for vertical text layout. This basically
2255 * means that `face.glyph.advance' will correspond to the vertical
2256 * advance height (instead of the default horizontal advance width),
2257 * and that the glyph image will be translated to match the vertical
2258 * bearings positions.
2260 * FT_LOAD_FORCE_AUTOHINT ::
2261 * Force the use of the FreeType auto-hinter when a glyph outline is
2262 * loaded. You shouldn't need this in a typical application, since it
2263 * is mostly used to experiment with its algorithm.
2265 * FT_LOAD_CROP_BITMAP ::
2266 * Indicates that the glyph loader should try to crop the bitmap (i.e.,
2267 * remove all space around its black bits) when loading it. This is
2268 * only useful when loading embedded bitmaps in certain fonts, since
2269 * bitmaps rendered with @FT_LOAD_RENDER are always cropped by default.
2271 * FT_LOAD_PEDANTIC ::
2272 * Indicates that the glyph loader should perform pedantic
2273 * verifications during glyph loading, rejecting invalid fonts. This
2274 * is mostly used to detect broken glyphs in fonts. By default,
2275 * FreeType tries to handle broken fonts also.
2277 * FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ::
2278 * Indicates that the glyph loader should ignore the global advance
2279 * width defined in the font. For historical reasons (to support
2280 * buggy CJK fonts), FreeType uses the value of the `advanceWidthMax'
2281 * field in the `htmx' table for all glyphs if the font is monospaced.
2282 * Activating this flags makes FreeType use the metric values given in
2285 * FT_LOAD_NO_RECURSE ::
2286 * This flag is only used internally. It merely indicates that the
2287 * glyph loader should not load composite glyphs recursively. Instead,
2288 * it should set the `num_subglyph' and `subglyphs' values of the glyph
2289 * slot accordingly, and set "glyph->format" to
2290 * @FT_GLYPH_FORMAT_COMPOSITE.
2292 * The description of sub-glyphs is not available to client
2293 * applications for now.
2295 * FT_LOAD_IGNORE_TRANSFORM ::
2296 * Indicates that the glyph loader should not try to transform the
2297 * loaded glyph image. This doesn't prevent scaling, hinting, or
2300 * FT_LOAD_MONOCHROME ::
2301 * This flag is used with @FT_LOAD_RENDER to indicate that you want
2302 * to render a 1-bit monochrome glyph bitmap from a vectorial outline.
2304 * Note that this has no effect on the hinting algorithm used by the
2305 * glyph loader. You should better use @FT_LOAD_TARGET_MONO if you
2306 * want to render monochrome-optimized glyph images instead.
2308 * FT_LOAD_LINEAR_DESIGN ::
2309 * Return the linearly scaled metrics expressed in original font units
2310 * instead of the default 16.16 pixel values.
2312 * FT_LOAD_NO_AUTOHINT ::
2313 * Indicates that the auto-hinter should never be used to hint glyph
2314 * outlines. This doesn't prevent native format-specific hinters from
2315 * being used. This can be important for certain fonts where unhinted
2316 * output is better than auto-hinted one.
2318 * FT_LOAD_TARGET_NORMAL ::
2319 * Use hinting for @FT_RENDER_MODE_NORMAL.
2321 * FT_LOAD_TARGET_LIGHT ::
2322 * Use hinting for @FT_RENDER_MODE_LIGHT.
2324 * FT_LOAD_TARGET_MONO ::
2325 * Use hinting for @FT_RENDER_MODE_MONO.
2327 * FT_LOAD_TARGET_LCD ::
2328 * Use hinting for @FT_RENDER_MODE_LCD.
2330 * FT_LOAD_TARGET_LCD_V ::
2331 * Use hinting for @FT_RENDER_MODE_LCD_V.
2333 #define FT_LOAD_DEFAULT 0x0
2334 #define FT_LOAD_NO_SCALE 0x1
2335 #define FT_LOAD_NO_HINTING 0x2
2336 #define FT_LOAD_RENDER 0x4
2337 #define FT_LOAD_NO_BITMAP 0x8
2338 #define FT_LOAD_VERTICAL_LAYOUT 0x10
2339 #define FT_LOAD_FORCE_AUTOHINT 0x20
2340 #define FT_LOAD_CROP_BITMAP 0x40
2341 #define FT_LOAD_PEDANTIC 0x80
2342 #define FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH 0x200
2343 #define FT_LOAD_NO_RECURSE 0x400
2344 #define FT_LOAD_IGNORE_TRANSFORM 0x800
2345 #define FT_LOAD_MONOCHROME 0x1000
2346 #define FT_LOAD_LINEAR_DESIGN 0x2000
2348 /* temporary hack! */
2349 #define FT_LOAD_SBITS_ONLY 0x4000
2350 #define FT_LOAD_NO_AUTOHINT 0x8000U
2354 #define FT_LOAD_TARGET_( x ) ( (FT_Int32)( (x) & 15 ) << 16 )
2355 #define FT_LOAD_TARGET_MODE( x ) ( (FT_Render_Mode)( ( (x) >> 16 ) & 15 ) )
2357 #define FT_LOAD_TARGET_NORMAL FT_LOAD_TARGET_( FT_RENDER_MODE_NORMAL )
2358 #define FT_LOAD_TARGET_LIGHT FT_LOAD_TARGET_( FT_RENDER_MODE_LIGHT )
2359 #define FT_LOAD_TARGET_MONO FT_LOAD_TARGET_( FT_RENDER_MODE_MONO )
2360 #define FT_LOAD_TARGET_LCD FT_LOAD_TARGET_( FT_RENDER_MODE_LCD )
2361 #define FT_LOAD_TARGET_LCD_V FT_LOAD_TARGET_( FT_RENDER_MODE_LCD_V )
2366 /*************************************************************************/
2369 /* FT_Set_Transform */
2372 /* A function used to set the transformation that is applied to glyph */
2373 /* images when they are loaded into a glyph slot through */
2374 /* @FT_Load_Glyph. */
2377 /* face :: A handle to the source face object. */
2380 /* matrix :: A pointer to the transformation's 2x2 matrix. Use 0 for */
2381 /* the identity matrix. */
2382 /* delta :: A pointer to the translation vector. Use 0 for the null */
2386 /* The transformation is only applied to scalable image formats after */
2387 /* the glyph has been loaded. It means that hinting is unaltered by */
2388 /* the transformation and is performed on the character size given in */
2389 /* the last call to @FT_Set_Char_Size or @FT_Set_Pixel_Sizes. */
2392 FT_Set_Transform( FT_Face face,
2397 /*************************************************************************/
2400 /* FT_Render_Mode */
2403 /* An enumeration type that lists the render modes supported by */
2404 /* FreeType 2. Each mode corresponds to a specific type of scanline */
2405 /* conversion performed on the outline, as well as specific */
2406 /* hinting optimizations. */
2408 /* For bitmap fonts the `bitmap->pixel_mode' field in the */
2409 /* @FT_GlyphSlotRec structure gives the format of the returned */
2413 /* FT_RENDER_MODE_NORMAL :: */
2414 /* This is the default render mode; it corresponds to 8-bit */
2415 /* anti-aliased bitmaps, using 256 levels of opacity. */
2417 /* FT_RENDER_MODE_LIGHT :: */
2418 /* This is similar to @FT_RENDER_MODE_NORMAL -- you have to use */
2419 /* @FT_LOAD_TARGET_LIGHT in calls to @FT_Load_Glyph to get any */
2420 /* effect since the rendering process no longer influences the */
2421 /* positioning of glyph outlines. */
2423 /* The resulting glyph shapes are more similar to the original, */
2424 /* while being a bit more fuzzy (`better shapes' instead of `better */
2425 /* contrast', so to say. */
2427 /* FT_RENDER_MODE_MONO :: */
2428 /* This mode corresponds to 1-bit bitmaps. */
2430 /* FT_RENDER_MODE_LCD :: */
2431 /* This mode corresponds to horizontal RGB/BGR sub-pixel displays, */
2432 /* like LCD-screens. It produces 8-bit bitmaps that are 3 times */
2433 /* the width of the original glyph outline in pixels, and which use */
2434 /* the @FT_PIXEL_MODE_LCD mode. */
2436 /* FT_RENDER_MODE_LCD_V :: */
2437 /* This mode corresponds to vertical RGB/BGR sub-pixel displays */
2438 /* (like PDA screens, rotated LCD displays, etc.). It produces */
2439 /* 8-bit bitmaps that are 3 times the height of the original */
2440 /* glyph outline in pixels and use the @FT_PIXEL_MODE_LCD_V mode. */
2443 /* The LCD-optimized glyph bitmaps produced by FT_Render_Glyph are */
2444 /* _not filtered_ to reduce color-fringes. It is up to the caller to */
2445 /* perform this pass. */
2447 typedef enum FT_Render_Mode_
2449 FT_RENDER_MODE_NORMAL = 0,
2450 FT_RENDER_MODE_LIGHT,
2451 FT_RENDER_MODE_MONO,
2453 FT_RENDER_MODE_LCD_V,
2460 /*************************************************************************/
2463 /* ft_render_mode_xxx */
2466 /* These constats are deprecated. Use the corresponding */
2467 /* @FT_Render_Mode values instead. */
2470 /* ft_render_mode_normal :: see @FT_RENDER_MODE_NORMAL */
2471 /* ft_render_mode_mono :: see @FT_RENDER_MODE_MONO */
2473 #define ft_render_mode_normal FT_RENDER_MODE_NORMAL
2474 #define ft_render_mode_mono FT_RENDER_MODE_MONO
2477 /*************************************************************************/
2480 /* FT_Render_Glyph */
2483 /* Converts a given glyph image to a bitmap. It does so by */
2484 /* inspecting the glyph image format, find the relevant renderer, and */
2488 /* slot :: A handle to the glyph slot containing the image to */
2492 /* render_mode :: This is the render mode used to render the glyph */
2493 /* image into a bitmap. See FT_Render_Mode for a list */
2494 /* of possible values. */
2497 /* FreeType error code. 0 means success. */
2499 FT_EXPORT( FT_Error )
2500 FT_Render_Glyph( FT_GlyphSlot slot,
2501 FT_Render_Mode render_mode );
2504 /*************************************************************************/
2507 /* FT_Kerning_Mode */
2510 /* An enumeration used to specify which kerning values to return in */
2511 /* @FT_Get_Kerning. */
2514 /* FT_KERNING_DEFAULT :: Return scaled and grid-fitted kerning */
2515 /* distances (value is 0). */
2517 /* FT_KERNING_UNFITTED :: Return scaled but un-grid-fitted kerning */
2520 /* FT_KERNING_UNSCALED :: Return the kerning vector in original font */
2523 typedef enum FT_Kerning_Mode_
2525 FT_KERNING_DEFAULT = 0,
2526 FT_KERNING_UNFITTED,
2532 /*************************************************************************/
2535 /* ft_kerning_default */
2538 /* This constant is deprecated. Please use @FT_KERNING_DEFAULT */
2541 #define ft_kerning_default FT_KERNING_DEFAULT
2544 /*************************************************************************/
2547 /* ft_kerning_unfitted */
2550 /* This constant is deprecated. Please use @FT_KERNING_UNFITTED */
2553 #define ft_kerning_unfitted FT_KERNING_UNFITTED
2556 /*************************************************************************/
2559 /* ft_kerning_unscaled */
2562 /* This constant is deprecated. Please use @FT_KERNING_UNSCALED */
2565 #define ft_kerning_unscaled FT_KERNING_UNSCALED
2568 /*************************************************************************/
2571 /* FT_Get_Kerning */
2574 /* Returns the kerning vector between two glyphs of a same face. */
2577 /* face :: A handle to a source face object. */
2579 /* left_glyph :: The index of the left glyph in the kern pair. */
2581 /* right_glyph :: The index of the right glyph in the kern pair. */
2583 /* kern_mode :: See @FT_Kerning_Mode for more information. */
2584 /* Determines the scale/dimension of the returned */
2585 /* kerning vector. */
2588 /* akerning :: The kerning vector. This is either in font units */
2589 /* or in pixels (26.6 format) for scalable formats, */
2590 /* and in pixels for fixed-sizes formats. */
2593 /* FreeType error code. 0 means success. */
2596 /* Only horizontal layouts (left-to-right & right-to-left) are */
2597 /* supported by this method. Other layouts, or more sophisticated */
2598 /* kernings, are out of the scope of this API function -- they can be */
2599 /* implemented through format-specific interfaces. */
2601 FT_EXPORT( FT_Error )
2602 FT_Get_Kerning( FT_Face face,
2604 FT_UInt right_glyph,
2606 FT_Vector *akerning );
2609 /*************************************************************************/
2612 /* FT_Get_Glyph_Name */
2615 /* Retrieves the ASCII name of a given glyph in a face. This only */
2616 /* works for those faces where FT_HAS_GLYPH_NAME(face) returns true. */
2619 /* face :: A handle to a source face object. */
2621 /* glyph_index :: The glyph index. */
2623 /* buffer_max :: The maximal number of bytes available in the */
2627 /* buffer :: A pointer to a target buffer where the name will be */
2631 /* FreeType error code. 0 means success. */
2634 /* An error is returned if the face doesn't provide glyph names or if */
2635 /* the glyph index is invalid. In all cases of failure, the first */
2636 /* byte of `buffer' will be set to 0 to indicate an empty name. */
2638 /* The glyph name is truncated to fit within the buffer if it is too */
2639 /* long. The returned string is always zero-terminated. */
2641 /* This function is not compiled within the library if the config */
2642 /* macro FT_CONFIG_OPTION_NO_GLYPH_NAMES is defined in */
2643 /* `include/freetype/config/ftoptions.h' */
2645 FT_EXPORT( FT_Error )
2646 FT_Get_Glyph_Name( FT_Face face,
2647 FT_UInt glyph_index,
2649 FT_UInt buffer_max );
2652 /*************************************************************************/
2655 /* FT_Get_Postscript_Name */
2658 /* Retrieves the ASCII Postscript name of a given face, if available. */
2659 /* This only works with Postscript and TrueType fonts. */
2662 /* face :: A handle to the source face object. */
2665 /* A pointer to the face's Postscript name. NULL if unavailable. */
2668 /* The returned pointer is owned by the face and will be destroyed */
2671 FT_EXPORT( const char* )
2672 FT_Get_Postscript_Name( FT_Face face );
2675 /*************************************************************************/
2678 /* FT_Select_Charmap */
2681 /* Selects a given charmap by its encoding tag (as listed in */
2682 /* `freetype.h'). */
2685 /* face :: A handle to the source face object. */
2688 /* encoding :: A handle to the selected charmap. */
2691 /* FreeType error code. 0 means success. */
2694 /* This function will return an error if no charmap in the face */
2695 /* corresponds to the encoding queried here. */
2697 FT_EXPORT( FT_Error )
2698 FT_Select_Charmap( FT_Face face,
2699 FT_Encoding encoding );
2702 /*************************************************************************/
2705 /* FT_Set_Charmap */
2708 /* Selects a given charmap for character code to glyph index */
2712 /* face :: A handle to the source face object. */
2715 /* charmap :: A handle to the selected charmap. */
2718 /* FreeType error code. 0 means success. */
2721 /* This function will return an error if the charmap is not part of */
2722 /* the face (i.e., if it is not listed in the face->charmaps[] */
2725 FT_EXPORT( FT_Error )
2726 FT_Set_Charmap( FT_Face face,
2727 FT_CharMap charmap );
2730 /*************************************************************************/
2733 /* FT_Get_Charmap_Index */
2736 /* Retrieve index of a given charmap. */
2739 /* charmap :: A handle to a charmap. */
2742 /* The index into the array of character maps within the face to */
2743 /* which `charmap' belongs. */
2746 FT_Get_Charmap_Index( FT_CharMap charmap );
2749 /*************************************************************************/
2752 /* FT_Get_Char_Index */
2755 /* Returns the glyph index of a given character code. This function */
2756 /* uses a charmap object to do the translation. */
2759 /* face :: A handle to the source face object. */
2761 /* charcode :: The character code. */
2764 /* The glyph index. 0 means `undefined character code'. */
2767 /* FreeType computes its own glyph indices which are not necessarily */
2768 /* the same as used in the font in case the font is based on glyph */
2769 /* indices. Reason for this behaviour is to assure that index 0 is */
2770 /* never used, representing the missing glyph. */
2772 FT_EXPORT( FT_UInt )
2773 FT_Get_Char_Index( FT_Face face,
2774 FT_ULong charcode );
2777 /*************************************************************************/
2780 /* FT_Get_First_Char */
2783 /* This function is used to return the first character code in the */
2784 /* current charmap of a given face. It will also return the */
2785 /* corresponding glyph index. */
2788 /* face :: A handle to the source face object. */
2791 /* agindex :: Glyph index of first character code. 0 if charmap is */
2795 /* The charmap's first character code. */
2798 /* You should use this function with @FT_Get_Next_Char to be able to */
2799 /* parse all character codes available in a given charmap. The code */
2800 /* should look like this: */
2803 /* FT_ULong charcode; */
2804 /* FT_UInt gindex; */
2807 /* charcode = FT_Get_First_Char( face, &gindex ); */
2808 /* while ( gindex != 0 ) */
2810 /* ... do something with (charcode,gindex) pair ... */
2812 /* charcode = FT_Get_Next_Char( face, charcode, &gindex ); */
2816 /* Note that `*agindex' will be set to 0 if the charmap is empty. */
2817 /* The result itself can be 0 in two cases: if the charmap is empty */
2818 /* or when the value 0 is the first valid character code. */
2820 FT_EXPORT( FT_ULong )
2821 FT_Get_First_Char( FT_Face face,
2825 /*************************************************************************/
2828 /* FT_Get_Next_Char */
2831 /* This function is used to return the next character code in the */
2832 /* current charmap of a given face following the value 'char_code', */
2833 /* as well as the corresponding glyph index. */
2836 /* face :: A handle to the source face object. */
2837 /* char_code :: The starting character code. */
2840 /* agindex :: Glyph index of first character code. 0 if charmap */
2844 /* The charmap's next character code. */
2847 /* You should use this function with @FT_Get_First_Char to walk */
2848 /* through all character codes available in a given charmap. See */
2849 /* the note for this function for a simple code example. */
2851 /* Note that `*agindex' will be set to 0 when there are no more codes */
2852 /* in the charmap. */
2854 FT_EXPORT( FT_ULong )
2855 FT_Get_Next_Char( FT_Face face,
2860 /*************************************************************************/
2863 /* FT_Get_Name_Index */
2866 /* Returns the glyph index of a given glyph name. This function uses */
2867 /* driver specific objects to do the translation. */
2870 /* face :: A handle to the source face object. */
2872 /* glyph_name :: The glyph name. */
2875 /* The glyph index. 0 means `undefined character code'. */
2877 FT_EXPORT( FT_UInt )
2878 FT_Get_Name_Index( FT_Face face,
2879 FT_String* glyph_name );
2883 /*************************************************************************/
2892 /* Crunching fixed numbers and vectors. */
2895 /* This section contains various functions used to perform */
2896 /* computations on 16.16 fixed-float numbers or 2d vectors. */
2905 /* FT_Vector_Transform */
2906 /* FT_Matrix_Multiply */
2907 /* FT_Matrix_Invert */
2909 /*************************************************************************/
2912 /*************************************************************************/
2918 /* A very simple function used to perform the computation `(a*b)/c' */
2919 /* with maximal accuracy (it uses a 64-bit intermediate integer */
2920 /* whenever necessary). */
2922 /* This function isn't necessarily as fast as some processor specific */
2923 /* operations, but is at least completely portable. */
2926 /* a :: The first multiplier. */
2927 /* b :: The second multiplier. */
2928 /* c :: The divisor. */
2931 /* The result of `(a*b)/c'. This function never traps when trying to */
2932 /* divide by zero; it simply returns `MaxInt' or `MinInt' depending */
2933 /* on the signs of `a' and `b'. */
2935 FT_EXPORT( FT_Long )
2936 FT_MulDiv( FT_Long a,
2941 /*************************************************************************/
2947 /* A very simple function used to perform the computation */
2948 /* `(a*b)/0x10000' with maximal accuracy. Most of the time this is */
2949 /* used to multiply a given value by a 16.16 fixed float factor. */
2952 /* a :: The first multiplier. */
2953 /* b :: The second multiplier. Use a 16.16 factor here whenever */
2954 /* possible (see note below). */
2957 /* The result of `(a*b)/0x10000'. */
2960 /* This function has been optimized for the case where the absolute */
2961 /* value of `a' is less than 2048, and `b' is a 16.16 scaling factor. */
2962 /* As this happens mainly when scaling from notional units to */
2963 /* fractional pixels in FreeType, it resulted in noticeable speed */
2964 /* improvements between versions 2.x and 1.x. */
2966 /* As a conclusion, always try to place a 16.16 factor as the */
2967 /* _second_ argument of this function; this can make a great */
2970 FT_EXPORT( FT_Long )
2971 FT_MulFix( FT_Long a,
2975 /*************************************************************************/
2981 /* A very simple function used to perform the computation */
2982 /* `(a*0x10000)/b' with maximal accuracy. Most of the time, this is */
2983 /* used to divide a given value by a 16.16 fixed float factor. */
2986 /* a :: The first multiplier. */
2987 /* b :: The second multiplier. Use a 16.16 factor here whenever */
2988 /* possible (see note below). */
2991 /* The result of `(a*0x10000)/b'. */
2994 /* The optimization for FT_DivFix() is simple: If (a << 16) fits in */
2995 /* 32 bits, then the division is computed directly. Otherwise, we */
2996 /* use a specialized version of @FT_MulDiv. */
2998 FT_EXPORT( FT_Long )
2999 FT_DivFix( FT_Long a,
3003 /*************************************************************************/
3009 /* A very simple function used to round a 16.16 fixed number. */
3012 /* a :: The number to be rounded. */
3015 /* The result of `(a + 0x8000) & -0x10000'. */
3017 FT_EXPORT( FT_Fixed )
3018 FT_RoundFix( FT_Fixed a );
3021 /*************************************************************************/
3027 /* A very simple function used to compute the ceiling function of a */
3028 /* 16.16 fixed number. */
3031 /* a :: The number for which the ceiling function is to be computed. */
3034 /* The result of `(a + 0x10000 - 1) & -0x10000'. */
3036 FT_EXPORT( FT_Fixed )
3037 FT_CeilFix( FT_Fixed a );
3040 /*************************************************************************/
3046 /* A very simple function used to compute the floor function of a */
3047 /* 16.16 fixed number. */
3050 /* a :: The number for which the floor function is to be computed. */
3053 /* The result of `a & -0x10000'. */
3055 FT_EXPORT( FT_Fixed )
3056 FT_FloorFix( FT_Fixed a );
3059 /*************************************************************************/
3062 /* FT_Vector_Transform */
3065 /* Transforms a single vector through a 2x2 matrix. */
3068 /* vector :: The target vector to transform. */
3071 /* matrix :: A pointer to the source 2x2 matrix. */
3074 /* The result is undefined if either `vector' or `matrix' is invalid. */
3077 FT_Vector_Transform( FT_Vector* vec,
3078 const FT_Matrix* matrix );
3086 #endif /* __FREETYPE_H__ */