1 /***************************************************************************/
5 /* FreeType high-level API and common types (specification only). */
7 /* Copyright 1996-2001, 2002 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__
23 /*************************************************************************/
25 /* The `raster' component duplicates some of the declarations in */
26 /* freetype.h for stand-alone use if _FREETYPE_ isn't defined. */
30 /*************************************************************************/
32 /* The FREETYPE_MAJOR and FREETYPE_MINOR macros are used to version the */
33 /* new FreeType design, which is able to host several kinds of font */
34 /* drivers. It starts at 2.0. */
36 #define FREETYPE_MAJOR 2
37 #define FREETYPE_MINOR 1
38 #define FREETYPE_PATCH 0
42 #include FT_CONFIG_CONFIG_H
50 /*************************************************************************/
51 /*************************************************************************/
53 /* B A S I C T Y P E S */
55 /*************************************************************************/
56 /*************************************************************************/
59 /*************************************************************************/
68 /* The FreeType 2 base font interface. */
71 /* This section describes the public high-level API of FreeType 2. */
83 /* FT_FACE_FLAG_SCALABLE */
84 /* FT_FACE_FLAG_FIXED_SIZES */
85 /* FT_FACE_FLAG_FIXED_WIDTH */
86 /* FT_FACE_FLAG_HORIZONTAL */
87 /* FT_FACE_FLAG_VERTICAL */
88 /* FT_FACE_FLAG_SFNT */
89 /* FT_FACE_FLAG_KERNING */
90 /* FT_FACE_FLAG_MULTIPLE_MASTERS */
91 /* FT_FACE_FLAG_GLYPH_NAMES */
92 /* FT_FACE_FLAG_EXTERNAL_STREAM */
93 /* FT_FACE_FLAG_FAST_GLYPHS */
95 /* FT_STYLE_FLAG_BOLD */
96 /* FT_STYLE_FLAG_ITALIC */
101 /* FT_GlyphSlotRec */
102 /* FT_Glyph_Metrics */
107 /* FT_Init_FreeType */
108 /* FT_Done_FreeType */
109 /* FT_Library_Version */
113 /* FT_New_Memory_Face */
119 /* FT_Attach_Stream */
121 /* FT_Set_Char_Size */
122 /* FT_Set_Pixel_Sizes */
123 /* FT_Set_Transform */
125 /* FT_Get_Char_Index */
126 /* FT_Get_Name_Index */
129 /* FT_LOAD_DEFAULT */
131 /* FT_LOAD_MONOCHROME */
132 /* FT_LOAD_LINEAR_DESIGN */
133 /* FT_LOAD_NO_SCALE */
134 /* FT_LOAD_NO_HINTING */
135 /* FT_LOAD_NO_BITMAP */
136 /* FT_LOAD_CROP_BITMAP */
138 /* FT_LOAD_VERTICAL_LAYOUT */
139 /* FT_LOAD_IGNORE_TRANSFORM */
140 /* FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH */
141 /* FT_LOAD_FORCE_AUTOHINT */
142 /* FT_LOAD_NO_RECURSE */
143 /* FT_LOAD_PEDANTIC */
145 /* FT_Render_Glyph */
148 /* FT_Kerning_Mode */
149 /* FT_Get_Glyph_Name */
150 /* FT_Get_Postscript_Name */
153 /* FT_Select_Charmap */
156 /*************************************************************************/
159 /*************************************************************************/
162 /* FT_Glyph_Metrics */
165 /* A structure used to model the metrics of a single glyph. Note */
166 /* that values are expressed in 26.6 fractional pixel format or in */
167 /* font units, depending on context. */
170 /* width :: The glyph's width. */
172 /* height :: The glyph's height. */
174 /* horiBearingX :: Horizontal left side bearing. */
176 /* horiBearingY :: Horizontal top side bearing. */
178 /* horiAdvance :: Horizontal advance width. */
180 /* vertBearingX :: Vertical left side bearing. */
182 /* vertBearingY :: Vertical top side bearing. */
184 /* vertAdvance :: Vertical advance height. */
186 typedef struct FT_Glyph_Metrics_
188 FT_Pos width
; /* glyph width */
189 FT_Pos height
; /* glyph height */
191 FT_Pos horiBearingX
; /* left side bearing in horizontal layouts */
192 FT_Pos horiBearingY
; /* top side bearing in horizontal layouts */
193 FT_Pos horiAdvance
; /* advance width for horizontal layout */
195 FT_Pos vertBearingX
; /* left side bearing in vertical layouts */
196 FT_Pos vertBearingY
; /* top side bearing in vertical layouts */
197 FT_Pos vertAdvance
; /* advance height for vertical layout */
202 /*************************************************************************/
208 /* An extremely simple structure used to model the size of a bitmap */
209 /* strike (i.e., a bitmap instance of the font for a given */
210 /* resolution) in a fixed-size font face. This is used for the */
211 /* `available_sizes' field of the FT_Face_Properties structure. */
214 /* height :: The character height in pixels. */
216 /* width :: The character width in pixels. */
218 typedef struct FT_Bitmap_Size_
226 /*************************************************************************/
227 /*************************************************************************/
229 /* O B J E C T C L A S S E S */
231 /*************************************************************************/
232 /*************************************************************************/
234 /*************************************************************************/
240 /* A handle to a FreeType library instance. Each `library' is */
241 /* completely independent from the others; it is the `root' of a set */
242 /* of objects like fonts, faces, sizes, etc. */
244 /* It also embeds a memory manager (see @FT_Memory), as well as a */
245 /* scan-line converter object (see @FT_Raster). */
248 /* Library objects are normally created by @FT_Init_FreeType, and */
249 /* destroyed with @FT_Done_FreeType */
251 typedef struct FT_LibraryRec_
*FT_Library
;
254 /*************************************************************************/
260 /* A handle to a given FreeType module object. Each module can be a */
261 /* font driver, a renderer, or anything else that provides services */
262 /* to the formers. */
264 typedef struct FT_ModuleRec_
* FT_Module
;
267 /*************************************************************************/
273 /* A handle to a given FreeType font driver object. Each font driver */
274 /* is a special module capable of creating faces from font files. */
276 typedef struct FT_DriverRec_
* FT_Driver
;
279 /*************************************************************************/
285 /* A handle to a given FreeType renderer. A renderer is a special */
286 /* module in charge of converting a glyph image to a bitmap, when */
287 /* necessary. Each renderer supports a given glyph image format, and */
288 /* one or more target surface depths. */
290 typedef struct FT_RendererRec_
* FT_Renderer
;
293 /*************************************************************************/
299 /* A handle to a given typographic face object. A face object models */
300 /* a given typeface, in a given style. */
303 /* Each face object also owns a single @FT_GlyphSlot object, as well */
304 /* as one or more @FT_Size objects. */
306 /* use @FT_New_Face or @FT_Open_Face to create a new face object from */
307 /* a given filepathname or a custom input stream. */
309 /* use @FT_Done_Face to destroy it (along with its slot and sizes) */
312 /* the @FT_FaceRec details the publicly accessible fields of a given */
315 typedef struct FT_FaceRec_
* FT_Face
;
318 /*************************************************************************/
324 /* A handle to a given size object. Such an object models the */
325 /* data that depends on the current _resolution_ and _character_ */
326 /* _size_ in a given @FT_Face. */
329 /* Each face object owns one or more sizes. There is however a */
330 /* single _active_ size for the face at any time that will be */
331 /* used by functions like @FT_Load_Glyph, @FT_Get_Kerning, etc... */
333 /* you can use the @FT_Activate_Size API to change the current */
334 /* active size of any given face */
337 /* the @FT_SizeRec structure details the publicly accessible fields */
338 /* of a given face object. */
340 typedef struct FT_SizeRec_
* FT_Size
;
343 /*************************************************************************/
349 /* A handle to a given `glyph slot'. A slot is a container where it */
350 /* is possible to load any one of the glyphs contained in its parent */
353 /* In other words, each time you call @FT_Load_Glyph or */
354 /* @FT_Load_Char, the slot's content is erased by the new glyph data, */
355 /* i.e. the glyph's metrics, its image (bitmap or outline), and */
356 /* other control information */
359 /* @FT_GlyphSlotRec details the publicly accessible glyph fields */
361 typedef struct FT_GlyphSlotRec_
* FT_GlyphSlot
;
364 /*************************************************************************/
370 /* A handle to a given character map. A charmap is used to translate */
371 /* character codes in a given encoding into glyph indexes for its */
372 /* parent's face. Some font formats may provide several charmaps per */
375 /* Each face object owns zero or more charmaps, but only one of */
376 /* them can be "active" and used by @FT_Get_Char_Index or */
379 /* The list of available charmaps in a face is available through the */
380 /* "face->num_charmaps" and "face->charmaps" fields of @FT_FaceRec */
382 /* the currently active charmap is available as "face->charmap". */
383 /* You should call @FT_Set_Charmap to change it */
386 /* when a new face is created (either through @FT_New_Face or */
387 /* @FT_Open_Face), the library looks for a Unicode charmap within */
388 /* the list and automatically activates it */
390 typedef struct FT_CharMapRec_
* FT_CharMap
;
393 /*************************************************************************/
399 /* This macro converts four letter tags into an unsigned long. */
400 /* It is used to define "encoding" identifiers (see @FT_Encoding) */
404 #define FT_ENC_TAG( value, _x1, _x2, _x3, _x4 ) \
405 value = ( ( (unsigned long)_x1 << 24 ) | \
406 ( (unsigned long)_x2 << 16 ) | \
407 ( (unsigned long)_x3 << 8 ) | \
409 #endif /* FT_ENC_TAG */
412 /*************************************************************************/
418 /* An enumeration used to specify encodings supported by charmaps. */
419 /* Used in the FT_Select_Charmap() API function. */
422 /* Because of 32-bit charcodes defined in Unicode (i.e., surrogates), */
423 /* all character codes must be expressed as FT_Longs. */
425 /* Other encodings might be defined in the future. */
427 typedef enum FT_Encoding_
429 FT_ENC_TAG( ft_encoding_none
, 0, 0, 0, 0 ),
431 FT_ENC_TAG( ft_encoding_symbol
, 's', 'y', 'm', 'b' ),
432 FT_ENC_TAG( ft_encoding_unicode
, 'u', 'n', 'i', 'c' ),
433 FT_ENC_TAG( ft_encoding_latin_1
, 'l', 'a', 't', '1' ),
434 FT_ENC_TAG( ft_encoding_latin_2
, 'l', 'a', 't', '2' ),
435 FT_ENC_TAG( ft_encoding_sjis
, 's', 'j', 'i', 's' ),
436 FT_ENC_TAG( ft_encoding_gb2312
, 'g', 'b', ' ', ' ' ),
437 FT_ENC_TAG( ft_encoding_big5
, 'b', 'i', 'g', '5' ),
438 FT_ENC_TAG( ft_encoding_wansung
, 'w', 'a', 'n', 's' ),
439 FT_ENC_TAG( ft_encoding_johab
, 'j', 'o', 'h', 'a' ),
441 FT_ENC_TAG( ft_encoding_adobe_standard
, 'A', 'D', 'O', 'B' ),
442 FT_ENC_TAG( ft_encoding_adobe_expert
, 'A', 'D', 'B', 'E' ),
443 FT_ENC_TAG( ft_encoding_adobe_custom
, 'A', 'D', 'B', 'C' ),
445 FT_ENC_TAG( ft_encoding_apple_roman
, 'a', 'r', 'm', 'n' )
450 /*************************************************************************/
456 /* The base charmap structure. */
459 /* face :: A handle to the parent face object. */
461 /* encoding :: A @FT_Encoding tag identifying the charmap. Use */
462 /* this with @FT_Select_Charmap(). */
464 /* platform_id :: An ID number describing the platform for the */
465 /* following encoding ID. This comes directly from */
466 /* the TrueType specification and should be emulated */
467 /* for other formats. */
469 /* encoding_id :: A platform specific encoding number. This also */
470 /* comes from the TrueType specification and should be */
471 /* emulated similarly. */
473 typedef struct FT_CharMapRec_
476 FT_Encoding encoding
;
477 FT_UShort platform_id
;
478 FT_UShort encoding_id
;
483 /*************************************************************************/
484 /*************************************************************************/
486 /* B A S E O B J E C T C L A S S E S */
488 /*************************************************************************/
489 /*************************************************************************/
492 /*************************************************************************/
495 /* FT_Face_Internal */
498 /* An opaque handle to an FT_Face_InternalRec structure, used to */
499 /* model private data of a given @FT_Face object. */
501 /* This structure might change between releases of FreeType 2 and are */
502 /* not generally available to client applications. */
504 typedef struct FT_Face_InternalRec_
* FT_Face_Internal
;
507 /*************************************************************************/
509 /* FreeType base face object */
515 /* FreeType root face class structure. A face object models the */
516 /* resolution and point-size independent data found in a font file. */
519 /* num_faces :: In the case where the face is located in a */
520 /* collection (i.e., a file which embed */
521 /* several faces), this is the total number of */
522 /* faces found in the resource. 1 by default. */
524 /* face_index :: The index of the face in its font file. */
525 /* Usually, this is 0 for all normal font */
526 /* formats. It can be more in the case of */
527 /* collections (which embed several fonts in a */
528 /* single resource/file). */
530 /* face_flags :: A set of bit flags that give important */
531 /* information about the face; see the */
532 /* FT_FACE_FLAG_XXX constants for details. */
534 /* style_flags :: A set of bit flags indicating the style of */
535 /* the face (i.e., italic, bold, underline, */
538 /* num_glyphs :: The total number of glyphs in the face. */
540 /* family_name :: The face's family name. This is an ASCII */
541 /* string, usually in English, which describes */
542 /* the typeface's family (like `Times New */
543 /* Roman', `Bodoni', `Garamond', etc). This */
544 /* is a least common denominator used to list */
545 /* fonts. Some formats (TrueType & OpenType) */
546 /* provide localized and Unicode versions of */
547 /* this string. Applications should use the */
548 /* format specific interface to access them. */
550 /* style_name :: The face's style name. This is an ASCII */
551 /* string, usually in English, which describes */
552 /* the typeface's style (like `Italic', */
553 /* `Bold', `Condensed', etc). Not all font */
554 /* formats provide a style name, so this field */
555 /* is optional, and can be set to NULL. As */
556 /* for `family_name', some formats provide */
557 /* localized/Unicode versions of this string. */
558 /* Applications should use the format specific */
559 /* interface to access them. */
561 /* num_fixed_sizes :: The number of fixed sizes available in this */
562 /* face. This should be set to 0 for scalable */
563 /* fonts, unless its face includes a complete */
564 /* set of glyphs (called a `strike') for the */
565 /* specified sizes. */
567 /* available_sizes :: An array of sizes specifying the available */
568 /* bitmap/graymap sizes that are contained in */
569 /* in the font face. Should be set to NULL if */
570 /* the field `num_fixed_sizes' is set to 0. */
572 /* num_charmaps :: The total number of character maps in the */
575 /* charmaps :: A table of pointers to the face's charmaps. */
576 /* Used to scan the list of available charmaps */
577 /* -- this table might change after a call to */
578 /* @FT_Attach_File or @FT_Attach_Stream (e.g. */
579 /* when used to hook an additional encoding or */
580 /* CMap to the face object). */
582 /* generic :: A field reserved for client uses. See the */
583 /* @FT_Generic type description. */
585 /* bbox :: The font bounding box. Coordinates are */
586 /* expressed in font units (see units_per_EM). */
587 /* The box is large enough to contain any */
588 /* glyph from the font. Thus, bbox.yMax can */
589 /* be seen as the `maximal ascender', */
590 /* bbox.yMin as the `minimal descender', and */
591 /* the maximal glyph width is given by */
592 /* `bbox.xMax-bbox.xMin' (not to be confused */
593 /* with the maximal _advance_width_). Only */
594 /* relevant for scalable formats. */
596 /* units_per_EM :: The number of font units per EM square for */
597 /* this face. This is typically 2048 for */
598 /* TrueType fonts, 1000 for Type1 fonts, and */
599 /* should be set to the (unrealistic) value 1 */
600 /* for fixed-sizes fonts. Only relevant for */
601 /* scalable formats. */
603 /* ascender :: The face's ascender is the vertical */
604 /* distance from the baseline to the topmost */
605 /* point of any glyph in the face. This */
606 /* field's value is positive, expressed in */
607 /* font units. Some font designs use a value */
608 /* different from `bbox.yMax'. Only relevant */
609 /* for scalable formats. */
611 /* descender :: The face's descender is the vertical */
612 /* distance from the baseline to the */
613 /* bottommost point of any glyph in the face. */
614 /* This field's value is positive, expressed */
615 /* in font units. Some font designs use a */
616 /* value different from `-bbox.yMin'. Only */
617 /* relevant for scalable formats. */
619 /* height :: The face's height is the vertical distance */
620 /* from one baseline to the next when writing */
621 /* several lines of text. Its value is always */
622 /* positive, expressed in font units. The */
623 /* value can be computed as */
624 /* `ascender+descender+line_gap' where the */
625 /* value of `line_gap' is also called */
626 /* `external leading'. Only relevant for */
627 /* scalable formats. */
629 /* max_advance_width :: The maximal advance width, in font units, */
630 /* for all glyphs in this face. This can be */
631 /* used to make word wrapping computations */
632 /* faster. Only relevant for scalable */
635 /* max_advance_height :: The maximal advance height, in font units, */
636 /* for all glyphs in this face. This is only */
637 /* relevant for vertical layouts, and should */
638 /* be set to the `height' for fonts that do */
639 /* not provide vertical metrics. Only */
640 /* relevant for scalable formats. */
642 /* underline_position :: The position, in font units, of the */
643 /* underline line for this face. It's the */
644 /* center of the underlining stem. Only */
645 /* relevant for scalable formats. */
647 /* underline_thickness :: The thickness, in font units, of the */
648 /* underline for this face. Only relevant for */
649 /* scalable formats. */
651 /* glyph :: The face's associated glyph slot(s). This */
652 /* object is created automatically with a new */
653 /* face object. However, certain kinds of */
654 /* applications (mainly tools like converters) */
655 /* can need more than one slot to ease their */
658 /* size :: the current active size for this face */
660 /* charmap :: the current active charmap for this face */
662 typedef struct FT_FaceRec_
672 FT_String
* family_name
;
673 FT_String
* style_name
;
675 FT_Int num_fixed_sizes
;
676 FT_Bitmap_Size
* available_sizes
;
679 FT_CharMap
* charmaps
;
683 /*# the following are only relevant to scalable outlines */
686 FT_UShort units_per_EM
;
691 FT_Short max_advance_width
;
692 FT_Short max_advance_height
;
694 FT_Short underline_position
;
695 FT_Short underline_thickness
;
707 FT_ListRec sizes_list
;
712 FT_Face_Internal internal
;
719 /*************************************************************************/
722 /* FT_FACE_FLAG_SCALABLE */
725 /* A bit-field constant, used to indicate that a given face provides */
726 /* vectorial outlines (i.e., TrueType or Type1). This doesn't */
727 /* prevent embedding of bitmap strikes though, i.e., a given face can */
728 /* have both this bit set, and a `num_fixed_sizes' property > 0. */
730 #define FT_FACE_FLAG_SCALABLE 1
733 /*************************************************************************/
736 /* FT_FACE_FLAG_FIXED_SIZES */
739 /* A bit-field constant, used to indicate that a given face contains */
740 /* `fixed sizes', i.e., bitmap strikes for some given pixel sizes. */
741 /* See the `num_fixed_sizes' and `available_sizes' face properties */
742 /* for more information. */
744 #define FT_FACE_FLAG_FIXED_SIZES 2
747 /*************************************************************************/
750 /* FT_FACE_FLAG_FIXED_WIDTH */
753 /* A bit-field constant, used to indicate that a given face contains */
754 /* fixed-width characters (like Courier, Lucida, MonoType, etc.). */
756 #define FT_FACE_FLAG_FIXED_WIDTH 4
759 /*************************************************************************/
762 /* FT_FACE_FLAG_SFNT */
765 /* A bit-field constant, used to indicate that a given face uses the */
766 /* `sfnt' storage fomat. For now, this means TrueType or OpenType. */
768 #define FT_FACE_FLAG_SFNT 8
771 /*************************************************************************/
774 /* FT_FACE_FLAG_HORIZONTAL */
777 /* A bit-field constant, used to indicate that a given face contains */
778 /* horizontal glyph metrics. This should be set for all common */
779 /* formats, but who knows. */
781 #define FT_FACE_FLAG_HORIZONTAL 0x10
784 /*************************************************************************/
787 /* FT_FACE_FLAG_VERTICAL */
790 /* A bit-field constant, used to indicate that a given face contains */
791 /* vertical glyph metrics. If not set, the glyph loader will */
792 /* synthetize vertical metrics itself to help display vertical text */
795 #define FT_FACE_FLAG_VERTICAL 0x20
798 /*************************************************************************/
801 /* FT_FACE_FLAG_KERNING */
804 /* A bit-field constant, used to indicate that a given face contains */
805 /* kerning information. When set, this information can be retrieved */
806 /* through the function @FT_Get_Kerning(). Note that when unset, */
807 /* this function will always return the kerning vector (0,0). */
809 #define FT_FACE_FLAG_KERNING 0x40
812 /*************************************************************************/
815 /* FT_FACE_FLAG_FAST_GLYPHS */
818 /* A bit-field constant, used to indicate that the glyphs in a given */
819 /* font can be retrieved very quickly, and that a glyph cache is thus */
820 /* not necessary for any of its child size objects. */
822 /* This flag should really be set for fixed-size formats like FNT, */
823 /* where each glyph bitmap is available directly in binary form */
824 /* without any kind of compression. */
827 /* This bit flag is deprecated, because even if the bitmaps are */
828 /* available directly in the font file, the glyph sub-system is */
829 /* very likely to be faster anyway... */
831 #define FT_FACE_FLAG_FAST_GLYPHS 0x80
834 /*************************************************************************/
837 /* FT_FACE_FLAG_MULTIPLE_MASTERS */
840 /* A bit-field constant, used to indicate that the font contains */
841 /* multiple masters and is capable of interpolating between them. */
842 /* See the multiple-masters specific API for more details */
844 #define FT_FACE_FLAG_MULTIPLE_MASTERS 0x100
847 /*************************************************************************/
850 /* FT_FACE_FLAG_GLYPH_NAMES */
853 /* A bit-field constant, used to indicate that the font contains */
854 /* glyph names that can be retrieved through @FT_Get_Glyph_Name(). */
856 #define FT_FACE_FLAG_GLYPH_NAMES 0x200
859 /*************************************************************************/
862 /* FT_FACE_FLAG_EXTERNAL_STREAM */
865 /* This bit field is used internally by FreeType to indicate that */
866 /* a face's stream was provided by the client application and should */
867 /* not be destroyed by @FT_Done_Face(). */
869 #define FT_FACE_FLAG_EXTERNAL_STREAM 0x4000
875 /*************************************************************************/
877 /* @macro: FT_HAS_HORIZONTAL (face) */
880 /* A macro that returns true whenever a face object contains */
881 /* horizontal metrics (this is true for all font formats though). */
884 /* @FT_HAS_VERTICAL can be used to check for vertical metrics. */
886 #define FT_HAS_HORIZONTAL( face ) \
887 ( face->face_flags & FT_FACE_FLAG_HORIZONTAL )
890 /*************************************************************************/
892 /* @macro: FT_HAS_VERTICAL (face) */
895 /* A macro that returns true whenever a face object contains vertical */
898 #define FT_HAS_VERTICAL( face ) \
899 ( face->face_flags & FT_FACE_FLAG_VERTICAL )
902 /*************************************************************************/
904 /* @macro: FT_HAS_KERNING (face) */
907 /* A macro that returns true whenever a face object contains kerning */
908 /* data that can be accessed with @FT_Get_Kerning. */
910 #define FT_HAS_KERNING( face ) \
911 ( face->face_flags & FT_FACE_FLAG_KERNING )
914 /*************************************************************************/
916 /* @macro: FT_IS_SCALABLE (face) */
919 /* A macro that returns true whenever a face object contains a */
920 /* scalable font face (true for TrueType, Type 1, CID, and */
921 /* OpenType/CFF font formats. */
923 #define FT_IS_SCALABLE( face ) \
924 ( face->face_flags & FT_FACE_FLAG_SCALABLE )
927 /*************************************************************************/
929 /* @macro: FT_IS_SFNT (face) */
932 /* A macro that returns true whenever a face object contains a font */
933 /* whose format is based on the SFNT storage scheme. This usually */
934 /* means: TrueType fonts, OpenType fonts, as well as SFNT-based */
935 /* embedded bitmap fonts. */
937 /* If this macro is true, all functions defined in @FT_SFNT_NAMES_H */
938 /* and @FT_TRUETYPE_TABLES_H are available. */
940 #define FT_IS_SFNT( face ) \
941 ( face->face_flags & FT_FACE_FLAG_SFNT )
944 /*************************************************************************/
946 /* @macro: FT_IS_FIXED_WIDTH (face) */
949 /* A macro that returns true whenever a face object contains a font */
950 /* face that contains fixed-width (or "monospace", "fixed-pitch", */
953 #define FT_IS_FIXED_WIDTH( face ) \
954 ( face->face_flags & FT_FACE_FLAG_FIXED_WIDTH )
957 /*************************************************************************/
959 /* @macro: FT_IS_FIXED_SIZES (face) */
962 /* A macro that returns true whenever a face object contains some */
963 /* embedded bitmaps. See the `fixed_sizes' field of the @FT_FaceRec */
966 #define FT_HAS_FIXED_SIZES( face ) \
967 ( face->face_flags & FT_FACE_FLAG_FIXED_SIZES )
973 /*************************************************************************/
975 /* @macro: FT_HAS_FAST_GLYPHS (face) */
978 /* Deprecated, indicates that the face contains so-called "fast" */
981 #define FT_HAS_FAST_GLYPHS( face ) \
982 ( face->face_flags & FT_FACE_FLAG_FAST_GLYPHS )
985 /*************************************************************************/
987 /* @macro: FT_HAS_GLYPH_NAMES (face) */
990 /* A macro that returns true whenever a face object contains some */
991 /* glyph names that can be accessed through @FT_Get_Glyph_Names. */
993 #define FT_HAS_GLYPH_NAMES( face ) \
994 ( face->face_flags & FT_FACE_FLAG_GLYPH_NAMES )
997 /*************************************************************************/
999 /* @macro: FT_HAS_MULTIPLE_MASTERS (face) */
1002 /* A macro that returns true whenever a face object contains some */
1003 /* multiple masters. The functions provided by */
1004 /* @FT_MULTIPLE_MASTERS_H are then available to choose the exact */
1005 /* design you want. */
1007 #define FT_HAS_MULTIPLE_MASTERS( face ) \
1008 ( face->face_flags & FT_FACE_FLAG_MULTIPLE_MASTERS )
1011 /*************************************************************************/
1014 /* FT_STYLE_FLAG_ITALIC */
1017 /* A bit-field constant, used to indicate that a given face is */
1020 #define FT_STYLE_FLAG_ITALIC 1
1023 /*************************************************************************/
1026 /* FT_STYLE_FLAG_BOLD */
1029 /* A bit-field constant, used to indicate that a given face is */
1032 #define FT_STYLE_FLAG_BOLD 2
1035 /*************************************************************************/
1038 /* FT_Size_Internal */
1041 /* An opaque handle to an FT_Size_InternalRec structure, used to */
1042 /* model private data of a given FT_Size object. */
1044 typedef struct FT_Size_InternalRec_
* FT_Size_Internal
;
1047 /*************************************************************************/
1049 /* FreeType base size metrics */
1052 /* FT_Size_Metrics */
1055 /* The size metrics structure returned scaled important distances for */
1056 /* a given size object. */
1059 /* x_ppem :: The character width, expressed in integer pixels. */
1060 /* This is the width of the EM square expressed in */
1061 /* pixels, hence the term `ppem' (pixels per EM). */
1063 /* y_ppem :: The character height, expressed in integer pixels. */
1064 /* This is the height of the EM square expressed in */
1065 /* pixels, hence the term `ppem' (pixels per EM). */
1067 /* x_scale :: A simple 16.16 fixed point format coefficient used */
1068 /* to scale horizontal distances expressed in font */
1069 /* units to fractional (26.6) pixel coordinates. */
1071 /* y_scale :: A simple 16.16 fixed point format coefficient used */
1072 /* to scale vertical distances expressed in font */
1073 /* units to fractional (26.6) pixel coordinates. */
1075 /* ascender :: The ascender, expressed in 26.6 fixed point */
1076 /* pixels. Always positive. */
1078 /* descender :: The descender, expressed in 26.6 fixed point */
1079 /* pixels. Always positive. */
1081 /* height :: The text height, expressed in 26.6 fixed point */
1082 /* pixels. Always positive. */
1084 /* max_advance :: Maximum horizontal advance, expressed in 26.6 */
1085 /* fixed point pixels. Always positive. */
1088 /* The values of `ascender', `descender', and `height' are only the */
1089 /* scaled versions of `face->ascender', `face->descender', and */
1090 /* `face->height'. */
1092 /* Unfortunately, due to glyph hinting, these values might not be */
1093 /* exact for certain fonts, they thus must be treated as unreliable */
1094 /* with an error margin of at least one pixel! */
1096 /* Indeed, the only way to get the exact pixel ascender and descender */
1097 /* is to render _all_ glyphs. As this would be a definite */
1098 /* performance hit, it is up to client applications to perform such */
1101 typedef struct FT_Size_Metrics_
1103 FT_UShort x_ppem
; /* horizontal pixels per EM */
1104 FT_UShort y_ppem
; /* vertical pixels per EM */
1106 FT_Fixed x_scale
; /* two scales used to convert font units */
1107 FT_Fixed y_scale
; /* to 26.6 frac. pixel coordinates.. */
1109 FT_Pos ascender
; /* ascender in 26.6 frac. pixels */
1110 FT_Pos descender
; /* descender in 26.6 frac. pixels */
1111 FT_Pos height
; /* text height in 26.6 frac. pixels */
1112 FT_Pos max_advance
; /* max horizontal advance, in 26.6 pixels */
1117 /*************************************************************************/
1119 /* FreeType base size class */
1125 /* FreeType root size class structure. A size object models the */
1126 /* resolution and pointsize dependent data of a given face. */
1129 /* face :: Handle to the parent face object. */
1131 /* generic :: A typeless pointer, which is unused by the FreeType */
1132 /* library or any of its drivers. It can be used by */
1133 /* client applications to link their own data to each size */
1136 /* metrics :: Metrics for this size object. This field is read-only. */
1138 typedef struct FT_SizeRec_
1140 FT_Face face
; /* parent face object */
1141 FT_Generic generic
; /* generic pointer for client uses */
1142 FT_Size_Metrics metrics
; /* size metrics */
1143 FT_Size_Internal internal
;
1148 /*************************************************************************/
1154 /* The subglyph structure is an internal object used to describe */
1155 /* subglyphs (for example, in the case of composites). */
1158 /* The subglyph implementation is not part of the high-level API, */
1159 /* hence the forward structure declaration. */
1161 typedef struct FT_SubGlyphRec_
* FT_SubGlyph
;
1164 /*************************************************************************/
1167 /* FT_Slot_Internal */
1170 /* An opaque handle to an FT_Slot_InternalRec structure, used to */
1171 /* model private data of a given FT_GlyphSlot object. */
1173 typedef struct FT_Slot_InternalRec_
* FT_Slot_Internal
;
1176 /*************************************************************************/
1178 /* FreeType Glyph Slot base class */
1181 /* FT_GlyphSlotRec */
1184 /* FreeType root glyph slot class structure. A glyph slot is a */
1185 /* container where individual glyphs can be loaded, be they */
1186 /* vectorial or bitmap/graymaps. */
1189 /* library :: A handle to the FreeType library instance */
1190 /* this slot belongs to. */
1192 /* face :: A handle to the parent face object. */
1194 /* next :: In some cases (like some font tools), several */
1195 /* glyph slots per face object can be a good */
1196 /* thing. As this is rare, the glyph slots are */
1197 /* listed through a direct, single-linked list */
1198 /* using its `next' field. */
1200 /* generic :: A typeless pointer which is unused by the */
1201 /* FreeType library or any of its drivers. It */
1202 /* can be used by client applications to link */
1203 /* their own data to each glyph slot object. */
1205 /* metrics :: The metrics of the last loaded glyph in the */
1206 /* slot. The returned values depend on the last */
1207 /* load flags (see the FT_Load_Glyph() API */
1208 /* function) and can be expressed either in 26.6 */
1209 /* fractional pixels or font units. */
1211 /* Note that even when the glyph image is */
1212 /* transformed, the metrics are not. */
1214 /* linearHoriAdvance :: For scalable formats only, this field holds */
1215 /* the linearly scaled horizontal advance width */
1216 /* for the glyph (i.e. the scaled and unhinted */
1217 /* value of the hori advance). This can be */
1218 /* important to perform correct WYSIWYG layout. */
1220 /* Note that this value is expressed by default */
1221 /* in 16.16 pixels. However, when the glyph is */
1222 /* loaded with the FT_LOAD_LINEAR_DESIGN flag, */
1223 /* this field contains simply the value of the */
1224 /* advance in original font units. */
1226 /* linearVertAdvance :: For scalable formats only, this field holds */
1227 /* the linearly scaled vertical advance height */
1228 /* for the glyph. See linearHoriAdvance for */
1231 /* advance :: This is the transformed advance width for the */
1234 /* format :: This field indicates the format of the image */
1235 /* contained in the glyph slot. Typically */
1236 /* ft_glyph_format_bitmap, */
1237 /* ft_glyph_format_outline, and */
1238 /* ft_glyph_format_composite, but others are */
1241 /* bitmap :: This field is used as a bitmap descriptor */
1242 /* when the slot format is */
1243 /* ft_glyph_format_bitmap. Note that the */
1244 /* address and content of the bitmap buffer can */
1245 /* change between calls of @FT_Load_Glyph() and */
1246 /* a few other functions. */
1248 /* bitmap_left :: This is the bitmap's left bearing expressed */
1249 /* in integer pixels. Of course, this is only */
1250 /* valid if the format is */
1251 /* ft_glyph_format_bitmap. */
1253 /* bitmap_top :: This is the bitmap's top bearing expressed in */
1254 /* integer pixels. Remember that this is the */
1255 /* distance from the baseline to the top-most */
1256 /* glyph scanline, upwards y-coordinates being */
1259 /* outline :: The outline descriptor for the current glyph */
1260 /* image if its format is */
1261 /* ft_glyph_bitmap_outline. */
1263 /* num_subglyphs :: The number of subglyphs in a composite glyph. */
1264 /* This format is only valid for the composite */
1265 /* glyph format, that should normally only be */
1266 /* loaded with the FT_LOAD_NO_RECURSE flag. */
1268 /* subglyphs :: An array of subglyph descriptors for */
1269 /* composite glyphs. There are `num_subglyphs' */
1270 /* elements in there. */
1272 /* control_data :: Certain font drivers can also return the */
1273 /* control data for a given glyph image (e.g. */
1274 /* TrueType bytecode, Type 1 charstrings, etc.). */
1275 /* This field is a pointer to such data. */
1277 /* control_len :: This is the length in bytes of the control */
1280 /* other :: Really wicked formats can use this pointer to */
1281 /* present their own glyph image to client apps. */
1282 /* Note that the app will need to know about the */
1286 /* If @FT_Load_Glyph() is called with default flags (see */
1287 /* @FT_LOAD_DEFAULT ) the glyph image is loaded in the glyph slot in */
1288 /* its native format (e.g. a vectorial outline for TrueType and */
1289 /* Type 1 formats). */
1291 /* This image can later be converted into a bitmap by calling */
1292 /* FT_Render_Glyph(). This function finds the current renderer for */
1293 /* the native image's format then invokes it. */
1295 /* The renderer is in charge of transforming the native image through */
1296 /* the slot's face transformation fields, then convert it into a */
1297 /* bitmap that is returned in `slot->bitmap'. */
1299 /* Note that `slot->bitmap_left' and `slot->bitmap_top' are also used */
1300 /* to specify the position of the bitmap relative to the current pen */
1301 /* position (e.g. coordinates [0,0] on the baseline). Of course, */
1302 /* `slot->format' is also changed to `ft_glyph_format_bitmap' . */
1304 typedef struct FT_GlyphSlotRec_
1312 FT_Glyph_Metrics metrics
;
1313 FT_Fixed linearHoriAdvance
;
1314 FT_Fixed linearVertAdvance
;
1317 FT_Glyph_Format format
;
1325 FT_UInt num_subglyphs
;
1326 FT_SubGlyph subglyphs
;
1333 FT_Slot_Internal internal
;
1338 /*************************************************************************/
1339 /*************************************************************************/
1341 /* F U N C T I O N S */
1343 /*************************************************************************/
1344 /*************************************************************************/
1347 /*************************************************************************/
1350 /* FT_Init_FreeType */
1353 /* Initializes a new FreeType library object. The set of modules */
1354 /* that are registered by this function is determined at build time. */
1357 /* alibrary :: A handle to a new library object. */
1360 /* FreeType error code. 0 means success. */
1362 FT_EXPORT( FT_Error
)
1363 FT_Init_FreeType( FT_Library
*alibrary
);
1366 /*************************************************************************/
1369 /* FT_Library_Version */
1372 /* Return the version of the FreeType library being used. This is */
1373 /* useful when dynamically linking to the library, since one cannot */
1374 /* use the macros FT_FREETYPE_MAJOR, FT_FREETYPE_MINOR, and */
1375 /* FT_FREETYPE_PATCH. */
1378 /* library :: A source library handle. */
1381 /* amajor :: The major version number. */
1383 /* aminor :: The minor version number. */
1385 /* apatch :: The patch version number. */
1388 /* The reason why this function takes a 'library' argument is because */
1389 /* certain programs implement library initialization in a custom way */
1390 /* that doesn't use `FT_Init_FreeType'. */
1392 /* In such cases, the library version might not be available before */
1393 /* the library object has been created. */
1396 FT_Library_Version( FT_Library library
,
1402 /*************************************************************************/
1405 /* FT_Done_FreeType */
1408 /* Destroys a given FreeType library object and all of its childs, */
1409 /* including resources, drivers, faces, sizes, etc. */
1412 /* library :: A handle to the target library object. */
1415 /* FreeType error code. 0 means success. */
1417 FT_EXPORT( FT_Error
)
1418 FT_Done_FreeType( FT_Library library
);
1421 /*************************************************************************/
1427 /* An enumeration used to list the bit flags used within the */
1428 /* `flags' field of the @FT_Open_Args structure. */
1431 /* ft_open_memory :: This is a memory-based stream. */
1433 /* ft_open_stream :: Copy the stream from the `stream' field. */
1435 /* ft_open_pathname :: Create a new input stream from a C pathname. */
1437 /* ft_open_driver :: Use the `driver' field. */
1439 /* ft_open_params :: Use the `num_params' & `params' field. */
1442 /* The `ft_open_memory', `ft_open_stream', and `ft_open_pathname' */
1443 /* flags are mutually exclusive. */
1449 ft_open_pathname
= 4,
1456 /*************************************************************************/
1462 /* A simple structure used to pass more or less generic parameters */
1463 /* to FT_Open_Face(). */
1466 /* tag :: A 4-byte identification tag. */
1468 /* data :: A pointer to the parameter data. */
1471 /* The id and function of parameters are driver-specific. */
1473 typedef struct FT_Parameter_
1481 /*************************************************************************/
1487 /* A structure used to indicate how to open a new font file/stream. */
1488 /* A pointer to such a structure can be used as a parameter for the */
1489 /* functions @FT_Open_Face() & @FT_Attach_Stream(). */
1492 /* flags :: A set of bit flags indicating how to use the */
1495 /* memory_base :: The first byte of the file in memory. */
1497 /* memory_size :: The size in bytes of the file in memory. */
1499 /* pathname :: A pointer to an 8-bit file pathname. */
1501 /* stream :: A handle to a source stream object. */
1503 /* driver :: This field is exclusively used by FT_Open_Face(); */
1504 /* it simply specifies the font driver to use to open */
1505 /* the face. If set to 0, FreeType will try to load */
1506 /* the face with each one of the drivers in its list. */
1508 /* num_params :: The number of extra parameters. */
1510 /* params :: Extra parameters passed to the font driver when */
1511 /* opening a new face. */
1514 /* The stream type is determined by the contents of `flags' which */
1515 /* are tested in the following order by @FT_Open_Face: */
1517 /* If the `ft_open_memory' bit is set, assume that this is a */
1518 /* memory file of `memory_size' bytes,located at `memory_address'. */
1520 /* Otherwise, if the `ft_open_stream' bit is set, assume that a */
1521 /* custom input stream `stream' is used. */
1523 /* Otherwise, if the `ft_open_pathname' bit is set, assume that this */
1524 /* is a normal file and use `pathname' to open it. */
1526 /* If the `ft_open_driver' bit is set, @FT_Open_Face() will only */
1527 /* try to open the file with the driver whose handler is in `driver'. */
1529 /* If the `ft_open_params' bit is set, the parameters given by */
1530 /* `num_params' and `params' will be used. They are ignored */
1533 typedef struct FT_Open_Args_
1535 FT_Open_Flags flags
;
1536 const FT_Byte
* memory_base
;
1537 FT_Long memory_size
;
1538 FT_String
* pathname
;
1542 FT_Parameter
* params
;
1547 /*************************************************************************/
1553 /* Creates a new face object from a given resource and typeface index */
1554 /* using a pathname to the font file. */
1557 /* library :: A handle to the library resource. */
1560 /* pathname :: A path to the font file. */
1562 /* face_index :: The index of the face within the resource. The */
1563 /* first face has index 0. */
1565 /* aface :: A handle to a new face object. */
1568 /* FreeType error code. 0 means success. */
1571 /* Unlike FreeType 1.x, this function automatically creates a glyph */
1572 /* slot for the face object which can be accessed directly through */
1573 /* `face->glyph'. */
1575 /* FT_New_Face() can be used to determine and/or check the font */
1576 /* format of a given font resource. If the `face_index' field is */
1577 /* negative, the function will _not_ return any face handle in */
1578 /* `aface'. Its return value should be 0 if the font format is */
1579 /* recognized, or non-zero otherwise. */
1581 /* Each new face object created with this function also owns a */
1582 /* default @FT_Size object, accessible as `face->size' */
1584 FT_EXPORT( FT_Error
)
1585 FT_New_Face( FT_Library library
,
1586 const char* filepathname
,
1591 /*************************************************************************/
1594 /* FT_New_Memory_Face */
1597 /* Creates a new face object from a given resource and typeface index */
1598 /* using a font file already loaded into memory. */
1601 /* library :: A handle to the library resource. */
1604 /* file_base :: A pointer to the beginning of the font data. */
1606 /* file_size :: The size of the memory chunk used by the font data. */
1608 /* face_index :: The index of the face within the resource. The */
1609 /* first face has index 0. */
1611 /* aface :: A handle to a new face object. */
1614 /* FreeType error code. 0 means success. */
1617 /* The font data bytes are used _directly_ by the @FT_Face object. */
1618 /* This means that they are not copied, and that the client is */
1619 /* responsible for releasing/destroying them _after_ the */
1620 /* corresponding call to @FT_Done_Face . */
1622 /* Unlike FreeType 1.x, this function automatically creates a glyph */
1623 /* slot for the face object which can be accessed directly through */
1624 /* `face->glyph'. */
1626 /* FT_New_Memory_Face() can be used to determine and/or check the */
1627 /* font format of a given font resource. If the `face_index' field */
1628 /* is negative, the function will _not_ return any face handle in */
1629 /* `aface'. Its return value should be 0 if the font format is */
1630 /* recognized, or non-zero otherwise. */
1632 FT_EXPORT( FT_Error
)
1633 FT_New_Memory_Face( FT_Library library
,
1634 const FT_Byte
* file_base
,
1640 /*************************************************************************/
1646 /* Opens a face object from a given resource and typeface index using */
1647 /* an `FT_Open_Args' structure. If the face object doesn't exist, it */
1648 /* will be created. */
1651 /* library :: A handle to the library resource. */
1654 /* args :: A pointer to an `FT_Open_Args' structure which must */
1655 /* be filled by the caller. */
1657 /* face_index :: The index of the face within the resource. The */
1658 /* first face has index 0. */
1660 /* aface :: A handle to a new face object. */
1663 /* FreeType error code. 0 means success. */
1666 /* Unlike FreeType 1.x, this function automatically creates a glyph */
1667 /* slot for the face object which can be accessed directly through */
1668 /* `face->glyph'. */
1670 /* FT_Open_Face() can be used to determine and/or check the font */
1671 /* format of a given font resource. If the `face_index' field is */
1672 /* negative, the function will _not_ return any face handle in */
1673 /* `*face'. Its return value should be 0 if the font format is */
1674 /* recognized, or non-zero otherwise. */
1676 FT_EXPORT( FT_Error
)
1677 FT_Open_Face( FT_Library library
,
1683 /*************************************************************************/
1686 /* FT_Attach_File */
1689 /* `Attaches' a given font file to an existing face. This is usually */
1690 /* to read additional information for a single face object. For */
1691 /* example, it is used to read the AFM files that come with Type 1 */
1692 /* fonts in order to add kerning data and other metrics. */
1695 /* face :: The target face object. */
1698 /* filepathname :: An 8-bit pathname naming the `metrics' file. */
1701 /* FreeType error code. 0 means success. */
1704 /* If your font file is in memory, or if you want to provide your */
1705 /* own input stream object, use FT_Attach_Stream(). */
1707 /* The meaning of the `attach' action (i.e., what really happens when */
1708 /* the new file is read) is not fixed by FreeType itself. It really */
1709 /* depends on the font format (and thus the font driver). */
1711 /* Client applications are expected to know what they are doing */
1712 /* when invoking this function. Most drivers simply do not implement */
1713 /* file attachments. */
1715 FT_EXPORT( FT_Error
)
1716 FT_Attach_File( FT_Face face
,
1717 const char* filepathname
);
1720 /*************************************************************************/
1723 /* FT_Attach_Stream */
1726 /* This function is similar to FT_Attach_File() with the exception */
1727 /* that it reads the attachment from an arbitrary stream. */
1730 /* face :: The target face object. */
1733 /* parameters :: A pointer to an FT_Open_Args structure used to */
1734 /* describe the input stream to FreeType. */
1736 /* FreeType error code. 0 means success. */
1739 /* The meaning of the `attach' (i.e. what really happens when the */
1740 /* new file is read) is not fixed by FreeType itself. It really */
1741 /* depends on the font format (and thus the font driver). */
1743 /* Client applications are expected to know what they are doing */
1744 /* when invoking this function. Most drivers simply do not implement */
1745 /* file attachments. */
1747 FT_EXPORT( FT_Error
)
1748 FT_Attach_Stream( FT_Face face
,
1749 FT_Open_Args
* parameters
);
1752 /*************************************************************************/
1758 /* Discards a given face object, as well as all of its child slots */
1762 /* face :: A handle to a target face object. */
1765 /* FreeType error code. 0 means success. */
1767 FT_EXPORT( FT_Error
)
1768 FT_Done_Face( FT_Face face
);
1771 /*************************************************************************/
1774 /* FT_Set_Char_Size */
1777 /* Sets the character dimensions of a given face object. The */
1778 /* `char_width' and `char_height' values are used for the width and */
1779 /* height, respectively, expressed in 26.6 fractional points. */
1781 /* If the horizontal or vertical resolution values are zero, a */
1782 /* default value of 72dpi is used. Similarly, if one of the */
1783 /* character dimensions is zero, its value is set equal to the other. */
1786 /* size :: A handle to a target size object. */
1789 /* char_width :: The character width, in 26.6 fractional points. */
1791 /* char_height :: The character height, in 26.6 fractional */
1794 /* horz_resolution :: The horizontal resolution. */
1796 /* vert_resolution :: The vertical resolution. */
1799 /* FreeType error code. 0 means success. */
1802 /* When dealing with fixed-size faces (i.e., non-scalable formats), */
1803 /* use the function FT_Set_Pixel_Sizes(). */
1805 FT_EXPORT( FT_Error
)
1806 FT_Set_Char_Size( FT_Face face
,
1807 FT_F26Dot6 char_width
,
1808 FT_F26Dot6 char_height
,
1809 FT_UInt horz_resolution
,
1810 FT_UInt vert_resolution
);
1813 /*************************************************************************/
1816 /* FT_Set_Pixel_Sizes */
1819 /* Sets the character dimensions of a given face object. The width */
1820 /* and height are expressed in integer pixels. */
1822 /* If one of the character dimensions is zero, its value is set equal */
1826 /* face :: A handle to the target face object. */
1829 /* pixel_width :: The character width, in integer pixels. */
1831 /* pixel_height :: The character height, in integer pixels. */
1834 /* FreeType error code. 0 means success. */
1838 /* The values of `pixel_width' and `pixel_height' correspond to the */
1839 /* pixel values of the _typographic_ character size, which are NOT */
1840 /* necessarily the same as the dimensions of the glyph `bitmap */
1843 /* The `character size' is really the size of an abstract square */
1844 /* called the `EM', used to design the font. However, depending */
1845 /* on the font design, glyphs will be smaller or greater than the */
1848 /* This means that setting the pixel size to, say, 8x8 doesn't */
1849 /* guarantee in any way that you will get glyph bitmaps that all fit */
1850 /* within an 8x8 cell (sometimes even far from it). */
1852 FT_EXPORT( FT_Error
)
1853 FT_Set_Pixel_Sizes( FT_Face face
,
1854 FT_UInt pixel_width
,
1855 FT_UInt pixel_height
);
1858 /*************************************************************************/
1864 /* A function used to load a single glyph within a given glyph slot, */
1865 /* for a given size. */
1868 /* face :: A handle to the target face object where the glyph */
1869 /* will be loaded. */
1872 /* glyph_index :: The index of the glyph in the font file. */
1874 /* load_flags :: A flag indicating what to load for this glyph. The */
1875 /* FT_LOAD_XXX constants can be used to control the */
1876 /* glyph loading process (e.g., whether the outline */
1877 /* should be scaled, whether to load bitmaps or not, */
1878 /* whether to hint the outline, etc). */
1881 /* FreeType error code. 0 means success. */
1884 /* If the glyph image is not a bitmap, and if the bit flag */
1885 /* FT_LOAD_IGNORE_TRANSFORM is unset, the glyph image will be */
1886 /* transformed with the information passed to a previous call to */
1887 /* FT_Set_Transform(). */
1889 /* Note that this also transforms the `face.glyph.advance' field, but */
1890 /* *not* the values in `face.glyph.metrics'. */
1892 FT_EXPORT( FT_Error
)
1893 FT_Load_Glyph( FT_Face face
,
1894 FT_UInt glyph_index
,
1895 FT_Int load_flags
);
1898 /*************************************************************************/
1904 /* A function used to load a single glyph within a given glyph slot, */
1905 /* for a given size, according to its character code. */
1908 /* face :: A handle to a target face object where the glyph */
1909 /* will be loaded. */
1912 /* char_code :: The glyph's character code, according to the */
1913 /* current charmap used in the face. */
1915 /* load_flags :: A flag indicating what to load for this glyph. The */
1916 /* FT_LOAD_XXX constants can be used to control the */
1917 /* glyph loading process (e.g., whether the outline */
1918 /* should be scaled, whether to load bitmaps or not, */
1919 /* whether to hint the outline, etc). */
1922 /* FreeType error code. 0 means success. */
1925 /* If the face has no current charmap, or if the character code */
1926 /* is not defined in the charmap, this function will return an */
1929 /* If the glyph image is not a bitmap, and if the bit flag */
1930 /* FT_LOAD_IGNORE_TRANSFORM is unset, the glyph image will be */
1931 /* transformed with the information passed to a previous call to */
1932 /* FT_Set_Transform(). */
1934 /* Note that this also transforms the `face.glyph.advance' field, but */
1935 /* *not* the values in `face.glyph.metrics'. */
1937 FT_EXPORT( FT_Error
)
1938 FT_Load_Char( FT_Face face
,
1940 FT_Int load_flags
);
1943 /*************************************************************************/
1946 /* FT_LOAD_NO_SCALE */
1949 /* A bit field constant, used with FT_Load_Glyph() to indicate that */
1950 /* the vector outline being loaded should not be scaled to 26.6 */
1951 /* fractional pixels, but kept in notional units. */
1953 #define FT_LOAD_NO_SCALE 1
1956 /*************************************************************************/
1959 /* FT_LOAD_NO_HINTING */
1962 /* A bit-field constant, used with FT_Load_Glyph() to indicate that */
1963 /* the vector outline being loaded should not be fitted to the pixel */
1964 /* grid but simply scaled to 26.6 fractional pixels. */
1966 /* This flag is ignored if FT_LOAD_NO_SCALE is set. */
1968 #define FT_LOAD_NO_HINTING 2
1971 /*************************************************************************/
1974 /* FT_LOAD_RENDER */
1977 /* A bit-field constant, used with FT_Load_Glyph() to indicate that */
1978 /* the function should load the glyph and immediately convert it into */
1979 /* a bitmap, if necessary, by calling FT_Render_Glyph(). */
1981 /* Note that by default, FT_Load_Glyph() loads the glyph image in its */
1982 /* native format. */
1984 #define FT_LOAD_RENDER 4
1987 /*************************************************************************/
1990 /* FT_LOAD_NO_BITMAP */
1993 /* A bit-field constant, used with FT_Load_Glyph() to indicate that */
1994 /* the function should not load the bitmap or pixmap of a given */
1995 /* glyph. This is useful when you do not want to load the embedded */
1996 /* bitmaps of scalable formats, as the native glyph image will be */
1997 /* loaded, and can then be rendered through FT_Render_Glyph(). */
1999 #define FT_LOAD_NO_BITMAP 8
2002 /*************************************************************************/
2005 /* FT_LOAD_VERTICAL_LAYOUT */
2008 /* A bit-field constant, used with FT_Load_Glyph() to indicate that */
2009 /* the glyph image should be prepared for vertical layout. This */
2010 /* basically means that `face.glyph.advance' will correspond to the */
2011 /* vertical advance height (instead of the default horizontal */
2012 /* advance width), and that the glyph image will translated to match */
2013 /* the vertical bearings positions. */
2015 #define FT_LOAD_VERTICAL_LAYOUT 16
2018 /*************************************************************************/
2021 /* FT_LOAD_FORCE_AUTOHINT */
2024 /* A bit-field constant, used with FT_Load_Glyph() to indicate that */
2025 /* the function should try to auto-hint the glyphs, even if a driver */
2026 /* specific hinter is available. */
2028 #define FT_LOAD_FORCE_AUTOHINT 32
2031 /*************************************************************************/
2034 /* FT_LOAD_CROP_BITMAP */
2037 /* A bit-field constant, used with FT_Load_Glyph() to indicate that */
2038 /* the font driver should try to crop the bitmap (i.e. remove all */
2039 /* space around its black bits) when loading it. For now, this */
2040 /* really only works with embedded bitmaps in TrueType fonts. */
2042 #define FT_LOAD_CROP_BITMAP 64
2045 /*************************************************************************/
2048 /* FT_LOAD_PEDANTIC */
2051 /* A bit-field constant, used with FT_Load_Glyph() to indicate that */
2052 /* the glyph loader should perform a pedantic bytecode */
2053 /* interpretation. Many popular fonts come with broken glyph */
2054 /* programs. When this flag is set, loading them will return an */
2055 /* error. Otherwise, errors are ignored by the loader, sometimes */
2056 /* resulting in ugly glyphs. */
2058 #define FT_LOAD_PEDANTIC 128
2061 /*************************************************************************/
2064 /* FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH */
2067 /* A bit-field constant, used with FT_Load_Glyph() to indicate that */
2068 /* the glyph loader should ignore the global advance width defined */
2069 /* in the font. As far as we know, this is only used by the */
2070 /* X-TrueType font server, in order to deal correctly with the */
2071 /* incorrect metrics contained in DynaLab's TrueType CJK fonts. */
2073 #define FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH 512
2076 /*************************************************************************/
2079 /* FT_LOAD_NO_RECURSE */
2082 /* A bit-field constant, used with FT_Load_Glyph() to indicate that */
2083 /* the glyph loader should not load composite glyph recursively. */
2084 /* Rather, when a composite glyph is encountered, it should set */
2085 /* the values of `num_subglyphs' and `subglyphs', as well as set */
2086 /* `face->glyph.format' to ft_glyph_format_composite. */
2088 /* This is for use by the auto-hinter and possibly other tools. */
2089 /* For nearly all applications, this flags should be left unset */
2090 /* when invoking FT_Load_Glyph(). */
2092 /* Note that the flag forces the load of unscaled glyphs. */
2094 #define FT_LOAD_NO_RECURSE 1024
2097 /*************************************************************************/
2100 /* FT_LOAD_IGNORE_TRANSFORM */
2103 /* A bit-field constant, used with FT_Load_Glyph() to indicate that */
2104 /* the glyph loader should not try to transform the loaded glyph */
2107 #define FT_LOAD_IGNORE_TRANSFORM 2048
2110 /*************************************************************************/
2113 /* FT_LOAD_MONOCHROME */
2116 /* Only used with FT_LOAD_RENDER set, it indicates that the returned */
2117 /* glyph image should be 1-bit monochrome. This really tells the */
2118 /* glyph loader to use `ft_render_mode_mono' when calling */
2119 /* FT_Render_Glyph(). */
2121 #define FT_LOAD_MONOCHROME 4096
2124 /*************************************************************************/
2127 /* FT_LOAD_LINEAR_DESIGN */
2130 /* A bit-field constant, used with FT_Load_Glyph() to indicate that */
2131 /* the function should return the linearly scaled metrics expressed */
2132 /* in original font units, instead of the default 16.16 pixel values. */
2134 #define FT_LOAD_LINEAR_DESIGN 8192
2136 /* temporary hack! */
2137 #define FT_LOAD_SBITS_ONLY 16384
2140 /*************************************************************************/
2143 /* FT_LOAD_DEFAULT */
2146 /* A bit-field constant, used with FT_Load_Glyph() to indicate that */
2147 /* the function should try to load the glyph normally, i.e., */
2148 /* embedded bitmaps are favored over outlines, vectors are always */
2149 /* scaled and grid-fitted. */
2151 #define FT_LOAD_DEFAULT 0
2154 /*************************************************************************/
2157 /* FT_Set_Transform */
2160 /* A function used to set the transformation that is applied to glyph */
2161 /* images just before they are converted to bitmaps in a glyph slot */
2162 /* when FT_Render_Glyph() is called. */
2165 /* face :: A handle to the source face object. */
2168 /* matrix :: A pointer to the transformation's 2x2 matrix. Use 0 for */
2169 /* the identity matrix. */
2170 /* delta :: A pointer to the translation vector. Use 0 for the null */
2174 /* The transformation is only applied to scalable image formats after */
2175 /* the glyph has been loaded. It means that hinting is unaltered by */
2176 /* the transformation and is performed on the character size given in */
2177 /* the last call to FT_Set_Char_Sizes() or FT_Set_Pixel_Sizes(). */
2180 FT_Set_Transform( FT_Face face
,
2185 /*************************************************************************/
2188 /* FT_Render_Mode */
2191 /* An enumeration type that lists the render modes supported by the */
2192 /* FreeType 2 renderer(s). A renderer is in charge of converting a */
2193 /* glyph image into a bitmap. */
2196 /* ft_render_mode_normal :: This is the default render mode; it */
2197 /* corresponds to 8-bit anti-aliased */
2198 /* bitmaps, using 256 levels of gray. */
2200 /* ft_render_mode_mono :: This render mode is used to produce 1-bit */
2201 /* monochrome bitmaps. */
2204 /* There is no render mode to produce 8-bit `monochrome' bitmaps -- */
2205 /* you have to make the conversion yourself if you need such things */
2206 /* (besides, FreeType is not a graphics library). */
2208 /* More modes might appear later for specific display modes (e.g. TV, */
2209 /* LCDs, etc.). They will be supported through the simple addition */
2210 /* of a renderer module, with no changes to the rest of the engine. */
2212 typedef enum FT_Render_Mode_
2214 ft_render_mode_normal
= 0,
2215 ft_render_mode_mono
= 1
2220 /*************************************************************************/
2223 /* FT_Render_Glyph */
2226 /* Converts a given glyph image to a bitmap. It does so by */
2227 /* inspecting the glyph image format, find the relevant renderer, and */
2231 /* slot :: A handle to the glyph slot containing the image to */
2235 /* render_mode :: This is the render mode used to render the glyph */
2236 /* image into a bitmap. See FT_Render_Mode for a list */
2237 /* of possible values. */
2240 /* FreeType error code. 0 means success. */
2242 FT_EXPORT( FT_Error
)
2243 FT_Render_Glyph( FT_GlyphSlot slot
,
2244 FT_UInt render_mode
);
2247 /*************************************************************************/
2250 /* FT_Kerning_Mode */
2253 /* An enumeration used to specify which kerning values to return in */
2254 /* FT_Get_Kerning(). */
2257 /* ft_kerning_default :: Return scaled and grid-fitted kerning */
2258 /* distances (value is 0). */
2260 /* ft_kerning_unfitted :: Return scaled but un-grid-fitted kerning */
2263 /* ft_kerning_unscaled :: Return the kerning vector in original font */
2266 typedef enum FT_Kerning_Mode_
2268 ft_kerning_default
= 0,
2269 ft_kerning_unfitted
,
2275 /*************************************************************************/
2278 /* FT_Get_Kerning */
2281 /* Returns the kerning vector between two glyphs of a same face. */
2284 /* face :: A handle to a source face object. */
2286 /* left_glyph :: The index of the left glyph in the kern pair. */
2288 /* right_glyph :: The index of the right glyph in the kern pair. */
2290 /* kern_mode :: See FT_Kerning_Mode() for more information. */
2291 /* Determines the scale/dimension of the returned */
2292 /* kerning vector. */
2295 /* akerning :: The kerning vector. This is in font units for */
2296 /* scalable formats, and in pixels for fixed-sizes */
2300 /* FreeType error code. 0 means success. */
2303 /* Only horizontal layouts (left-to-right & right-to-left) are */
2304 /* supported by this method. Other layouts, or more sophisticated */
2305 /* kernings, are out of the scope of this API function -- they can be */
2306 /* implemented through format-specific interfaces. */
2308 FT_EXPORT( FT_Error
)
2309 FT_Get_Kerning( FT_Face face
,
2311 FT_UInt right_glyph
,
2313 FT_Vector
*akerning
);
2316 /*************************************************************************/
2319 /* FT_Get_Glyph_Name */
2322 /* Retrieves the ASCII name of a given glyph in a face. This only */
2323 /* works for those faces where FT_HAS_GLYPH_NAME(face) returns true. */
2326 /* face :: A handle to a source face object. */
2328 /* glyph_index :: The glyph index. */
2330 /* buffer_max :: The maximal number of bytes available in the */
2334 /* buffer :: A pointer to a target buffer where the name will be */
2338 /* FreeType error code. 0 means success. */
2341 /* An error is returned if the face doesn't provide glyph names or if */
2342 /* the glyph index is invalid. In all cases of failure, the first */
2343 /* byte of `buffer' will be set to 0 to indicate an empty name. */
2345 /* The glyph name is truncated to fit within the buffer if it is too */
2346 /* long. The returned string is always zero-terminated. */
2348 /* This function is not compiled within the library if the config */
2349 /* macro FT_CONFIG_OPTION_NO_GLYPH_NAMES is defined in */
2350 /* `include/freetype/config/ftoptions.h' */
2352 FT_EXPORT( FT_Error
)
2353 FT_Get_Glyph_Name( FT_Face face
,
2354 FT_UInt glyph_index
,
2356 FT_UInt buffer_max
);
2359 /*************************************************************************/
2362 /* FT_Get_Postscript_Name */
2365 /* Retrieves the ASCII Postscript name of a given face, if available. */
2366 /* This should only work with Postscript and TrueType fonts. */
2369 /* face :: A handle to the source face object. */
2372 /* A pointer to the face's Postscript name. NULL if un-available. */
2375 /* The returned pointer is owned by the face and will be destroyed */
2378 FT_EXPORT( const char* )
2379 FT_Get_Postscript_Name( FT_Face face
);
2382 /*************************************************************************/
2385 /* FT_Select_Charmap */
2388 /* Selects a given charmap by its encoding tag (as listed in */
2389 /* `freetype.h'). */
2392 /* face :: A handle to the source face object. */
2395 /* encoding :: A handle to the selected charmap. */
2398 /* FreeType error code. 0 means success. */
2401 /* This function will return an error if no charmap in the face */
2402 /* corresponds to the encoding queried here. */
2404 FT_EXPORT( FT_Error
)
2405 FT_Select_Charmap( FT_Face face
,
2406 FT_Encoding encoding
);
2409 /*************************************************************************/
2412 /* FT_Set_Charmap */
2415 /* Selects a given charmap for character code to glyph index */
2419 /* face :: A handle to the source face object. */
2422 /* charmap :: A handle to the selected charmap. */
2425 /* FreeType error code. 0 means success. */
2428 /* This function will return an error if the charmap is not part of */
2429 /* the face (i.e., if it is not listed in the face->charmaps[] */
2432 FT_EXPORT( FT_Error
)
2433 FT_Set_Charmap( FT_Face face
,
2434 FT_CharMap charmap
);
2437 /*************************************************************************/
2440 /* FT_Get_Char_Index */
2443 /* Returns the glyph index of a given character code. This function */
2444 /* uses a charmap object to do the translation. */
2447 /* face :: A handle to the source face object. */
2449 /* charcode :: The character code. */
2452 /* The glyph index. 0 means `undefined character code'. */
2455 /* FreeType computes its own glyph indices which are not necessarily */
2456 /* the same as used in the font in case the font is based on glyph */
2457 /* indices. Reason for this behaviour is to assure that index 0 is */
2458 /* never used, representing the missing glyph. */
2460 FT_EXPORT( FT_UInt
)
2461 FT_Get_Char_Index( FT_Face face
,
2462 FT_ULong charcode
);
2465 /*************************************************************************/
2468 /* FT_Get_First_Char */
2471 /* This function is used to return the first character code in the */
2472 /* current charmap of a given face. It will also return the */
2473 /* corresponding glyph index. */
2476 /* face :: A handle to the source face object. */
2479 /* agindex :: Glyph index of first character code. 0 if charmap is */
2483 /* The charmap's first character code. */
2486 /* You should use this function with @FT_Get_Next_Char to be able to */
2487 /* parse all character codes available in a given charmap. The code */
2488 /* should look like this: */
2491 /* FT_ULong charcode; */
2492 /* FT_UInt gindex; */
2495 /* charcode = FT_Get_First_Char( face, &gindex ); */
2496 /* while ( gindex != 0 ) */
2498 /* ... do something with (charcode,gindex) pair ... */
2500 /* charcode = FT_Get_Next_Char( face, charcode, &gindex ); */
2504 /* Note that `*agindex' will be set to 0 if the charmap is empty. */
2505 /* The result itself can be 0 in two cases: if the charmap is empty */
2506 /* or when the value 0 is the first valid character code. */
2508 FT_EXPORT( FT_ULong
)
2509 FT_Get_First_Char( FT_Face face
,
2513 /*************************************************************************/
2516 /* FT_Get_Next_Char */
2519 /* This function is used to return the next character code in the */
2520 /* current charmap of a given face following the value 'char_code', */
2521 /* as well as the corresponding glyph index. */
2524 /* face :: A handle to the source face object. */
2525 /* char_code :: The starting character code. */
2528 /* agindex :: Glyph index of first character code. 0 if charmap */
2532 /* The charmap's next character code. */
2535 /* You should use this function with @FT_Get_First_Char to walk */
2536 /* through all character codes available in a given charmap. See */
2537 /* the note for this function for a simple code example. */
2539 /* Note that `*agindex' will be set to 0 when there are no more codes */
2540 /* in the charmap. */
2542 FT_EXPORT( FT_ULong
)
2543 FT_Get_Next_Char( FT_Face face
,
2548 /*************************************************************************/
2551 /* FT_Get_Name_Index */
2554 /* Returns the glyph index of a given glyph name. This function uses */
2555 /* driver specific objects to do the translation. */
2558 /* face :: A handle to the source face object. */
2560 /* glyph_name :: The glyph name. */
2563 /* The glyph index. 0 means `undefined character code'. */
2565 FT_EXPORT( FT_UInt
)
2566 FT_Get_Name_Index( FT_Face face
,
2567 FT_String
* glyph_name
);
2571 /*************************************************************************/
2580 /* Crunching fixed numbers and vectors */
2583 /* This section contains various functions used to perform */
2584 /* computations on 16.16 fixed-float numbers or 2d vectors. */
2593 /* FT_Vector_Transform */
2594 /* FT_Matrix_Multiply */
2595 /* FT_Matrix_Invert */
2597 /*************************************************************************/
2600 /*************************************************************************/
2606 /* A very simple function used to perform the computation `(a*b)/c' */
2607 /* with maximal accuracy (it uses a 64-bit intermediate integer */
2608 /* whenever necessary). */
2610 /* This function isn't necessarily as fast as some processor specific */
2611 /* operations, but is at least completely portable. */
2614 /* a :: The first multiplier. */
2615 /* b :: The second multiplier. */
2616 /* c :: The divisor. */
2619 /* The result of `(a*b)/c'. This function never traps when trying to */
2620 /* divide by zero; it simply returns `MaxInt' or `MinInt' depending */
2621 /* on the signs of `a' and `b'. */
2623 FT_EXPORT( FT_Long
)
2624 FT_MulDiv( FT_Long a
,
2629 /*************************************************************************/
2635 /* A very simple function used to perform the computation */
2636 /* `(a*b)/0x10000' with maximal accuracy. Most of the time this is */
2637 /* used to multiply a given value by a 16.16 fixed float factor. */
2640 /* a :: The first multiplier. */
2641 /* b :: The second multiplier. Use a 16.16 factor here whenever */
2642 /* possible (see note below). */
2645 /* The result of `(a*b)/0x10000'. */
2648 /* This function has been optimized for the case where the absolute */
2649 /* value of `a' is less than 2048, and `b' is a 16.16 scaling factor. */
2650 /* As this happens mainly when scaling from notional units to */
2651 /* fractional pixels in FreeType, it resulted in noticeable speed */
2652 /* improvements between versions 2.x and 1.x. */
2654 /* As a conclusion, always try to place a 16.16 factor as the */
2655 /* _second_ argument of this function; this can make a great */
2658 FT_EXPORT( FT_Long
)
2659 FT_MulFix( FT_Long a
,
2663 /*************************************************************************/
2669 /* A very simple function used to perform the computation */
2670 /* `(a*0x10000)/b' with maximal accuracy. Most of the time, this is */
2671 /* used to divide a given value by a 16.16 fixed float factor. */
2674 /* a :: The first multiplier. */
2675 /* b :: The second multiplier. Use a 16.16 factor here whenever */
2676 /* possible (see note below). */
2679 /* The result of `(a*0x10000)/b'. */
2682 /* The optimization for FT_DivFix() is simple: If (a << 16) fits in */
2683 /* 32 bits, then the division is computed directly. Otherwise, we */
2684 /* use a specialized version of the old FT_MulDiv64(). */
2686 FT_EXPORT( FT_Long
)
2687 FT_DivFix( FT_Long a
,
2691 /*************************************************************************/
2697 /* A very simple function used to round a 16.16 fixed number. */
2700 /* a :: The number to be rounded. */
2703 /* The result of `(a + 0x8000) & -0x10000'. */
2705 FT_EXPORT( FT_Fixed
)
2706 FT_RoundFix( FT_Fixed a
);
2709 /*************************************************************************/
2715 /* A very simple function used to compute the ceiling function of a */
2716 /* 16.16 fixed number. */
2719 /* a :: The number for which the ceiling function is to be computed. */
2722 /* The result of `(a + 0x10000 - 1) & -0x10000'. */
2724 FT_EXPORT( FT_Fixed
)
2725 FT_CeilFix( FT_Fixed a
);
2728 /*************************************************************************/
2734 /* A very simple function used to compute the floor function of a */
2735 /* 16.16 fixed number. */
2738 /* a :: The number for which the floor function is to be computed. */
2741 /* The result of `a & -0x10000'. */
2743 FT_EXPORT( FT_Fixed
)
2744 FT_FloorFix( FT_Fixed a
);
2747 /*************************************************************************/
2750 /* FT_Vector_Transform */
2753 /* Transforms a single vector through a 2x2 matrix. */
2756 /* vector :: The target vector to transform. */
2759 /* matrix :: A pointer to the source 2x2 matrix. */
2762 /* The result is undefined if either `vector' or `matrix' is invalid. */
2765 FT_Vector_Transform( FT_Vector
* vec
,
2766 FT_Matrix
* matrix
);
2773 #endif /* __FREETYPE_H__ */