1 /***************************************************************************/
5 /* FreeType high-level API and common types (specification only). */
7 /* Copyright 1996-2001 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 0
41 #include FT_CONFIG_CONFIG_H
49 /*************************************************************************/
50 /*************************************************************************/
52 /* B A S I C T Y P E S */
54 /*************************************************************************/
55 /*************************************************************************/
58 /*************************************************************************/
67 /* The FreeType 2 base font interface. */
70 /* This section describes the public high-level API of FreeType 2. */
82 /* FT_FACE_FLAG_SCALABLE */
83 /* FT_FACE_FLAG_FIXED_SIZES */
84 /* FT_FACE_FLAG_FIXED_WIDTH */
85 /* FT_FACE_FLAG_HORIZONTAL */
86 /* FT_FACE_FLAG_VERTICAL */
87 /* FT_FACE_FLAG_SFNT */
88 /* FT_FACE_FLAG_KERNING */
89 /* FT_FACE_FLAG_MULTIPLE_MASTERS */
90 /* FT_FACE_FLAG_GLYPH_NAMES */
91 /* FT_FACE_FLAG_EXTERNAL_STREAM */
92 /* FT_FACE_FLAG_FAST_GLYPHS */
94 /* FT_STYLE_FLAG_BOLD */
95 /* FT_STYLE_FLAG_ITALIC */
100 /* FT_GlyphSlotRec */
101 /* FT_Glyph_Metrics */
106 /* FT_Init_FreeType */
107 /* FT_Done_FreeType */
111 /* FT_New_Memory_Face */
117 /* FT_Attach_Stream */
119 /* FT_Set_Char_Size */
120 /* FT_Set_Pixel_Sizes */
121 /* FT_Set_Transform */
123 /* FT_Get_Char_Index */
124 /* FT_Get_Name_Index */
127 /* FT_LOAD_DEFAULT */
129 /* FT_LOAD_MONOCHROME */
130 /* FT_LOAD_LINEAR_DESIGN */
131 /* FT_LOAD_NO_SCALE */
132 /* FT_LOAD_NO_HINTING */
133 /* FT_LOAD_NO_BITMAP */
134 /* FT_LOAD_CROP_BITMAP */
136 /* FT_LOAD_VERTICAL_LAYOUT */
137 /* FT_LOAD_IGNORE_TRANSFORM */
138 /* FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH */
139 /* FT_LOAD_FORCE_AUTOHINT */
140 /* FT_LOAD_NO_RECURSE */
141 /* FT_LOAD_PEDANTIC */
143 /* FT_Render_Glyph */
146 /* FT_Kerning_Mode */
147 /* FT_Get_Glyph_Name */
150 /* FT_Select_Charmap */
153 /*************************************************************************/
156 /*************************************************************************/
159 /* FT_Glyph_Metrics */
162 /* A structure used to model the metrics of a single glyph. Note */
163 /* that values are expressed in 26.6 fractional pixel format or in */
164 /* font units, depending on context. */
167 /* width :: The glyph's width. */
169 /* height :: The glyph's height. */
171 /* horiBearingX :: Horizontal left side bearing. */
173 /* horiBearingY :: Horizontal top side bearing. */
175 /* horiAdvance :: Horizontal advance width. */
177 /* vertBearingX :: Vertical left side bearing. */
179 /* vertBearingY :: Vertical top side bearing. */
181 /* vertAdvance :: Vertical advance height. */
183 typedef struct FT_Glyph_Metrics_
185 FT_Pos width; /* glyph width */
186 FT_Pos height; /* glyph height */
188 FT_Pos horiBearingX; /* left side bearing in horizontal layouts */
189 FT_Pos horiBearingY; /* top side bearing in horizontal layouts */
190 FT_Pos horiAdvance; /* advance width for horizontal layout */
192 FT_Pos vertBearingX; /* left side bearing in vertical layouts */
193 FT_Pos vertBearingY; /* top side bearing in vertical layouts */
194 FT_Pos vertAdvance; /* advance height for vertical layout */
199 /*************************************************************************/
205 /* An extremely simple structure used to model the size of a bitmap */
206 /* strike (i.e., a bitmap instance of the font for a given */
207 /* resolution) in a fixed-size font face. This is used for the */
208 /* `available_sizes' field of the FT_Face_Properties structure. */
211 /* height :: The character height in pixels. */
213 /* width :: The character width in pixels. */
215 typedef struct FT_Bitmap_Size_
223 /*************************************************************************/
224 /*************************************************************************/
226 /* O B J E C T C L A S S E S */
228 /*************************************************************************/
229 /*************************************************************************/
231 /*************************************************************************/
237 /* A handle to a FreeType library instance. Each `library' is */
238 /* completely independent from the others; it is the `root' of a set */
239 /* of objects like fonts, faces, sizes, etc. */
241 /* It also embeds a system object (see FT_System), as well as a */
242 /* scan-line converter object (see FT_Raster). */
245 /* Library objects are created through FT_Init_FreeType(). */
247 typedef struct FT_LibraryRec_ *FT_Library;
250 /*************************************************************************/
256 /* A handle to a given FreeType module object. Each module can be a */
257 /* font driver, a renderer, or anything else that provides services */
258 /* to the formers. */
260 typedef struct FT_ModuleRec_* FT_Module;
263 /*************************************************************************/
269 /* A handle to a given FreeType font driver object. Each font driver */
270 /* is able to create faces, sizes, glyph slots, and charmaps from the */
271 /* resources whose format it supports. */
273 /* A driver can support either bitmap, graymap, or scalable font */
276 typedef struct FT_DriverRec_* FT_Driver;
279 /*************************************************************************/
285 /* A handle to a given FreeType renderer. A renderer is in charge of */
286 /* converting a glyph image to a bitmap, when necessary. Each */
287 /* supports a given glyph image format, and one or more target */
288 /* surface depths. */
290 typedef struct FT_RendererRec_* FT_Renderer;
293 /*************************************************************************/
299 /* A handle to a given driver face object. A face object contains */
300 /* all the instance and glyph independent data of a font file */
303 /* A face object is created from a resource object through the */
304 /* new_face() method of a given driver. */
306 typedef struct FT_FaceRec_* FT_Face;
309 /*************************************************************************/
315 /* A handle to a given driver size object. Such an object models the */
316 /* _resolution_ AND _size_ dependent state of a given driver face */
319 /* A size object is always created from a given face object. It is */
320 /* discarded automatically by its parent face. */
322 typedef struct FT_SizeRec_* FT_Size;
325 /*************************************************************************/
331 /* A handle to a given `glyph slot'. A slot is a container where it */
332 /* is possible to load any of the glyphs contained within its parent */
335 /* A glyph slot is created from a given face object. It is discarded */
336 /* automatically by its parent face. */
338 typedef struct FT_GlyphSlotRec_* FT_GlyphSlot;
341 /*************************************************************************/
347 /* A handle to a given character map. A charmap is used to translate */
348 /* character codes in a given encoding into glyph indexes for its */
349 /* parent's face. Some font formats may provide several charmaps per */
352 /* A charmap is created from a given face object. It is discarded */
353 /* automatically by its parent face. */
355 typedef struct FT_CharMapRec_* FT_CharMap;
358 /*************************************************************************/
364 /* This macro converts four letter tags into an unsigned long. */
367 #define FT_ENC_TAG( value, _x1, _x2, _x3, _x4 ) \
368 value = ( ( (unsigned long)_x1 << 24 ) | \
369 ( (unsigned long)_x2 << 16 ) | \
370 ( (unsigned long)_x3 << 8 ) | \
372 #endif /* FT_ENC_TAG */
375 /*************************************************************************/
381 /* An enumeration used to specify encodings supported by charmaps. */
382 /* Used in the FT_Select_Charmap() API function. */
385 /* Because of 32-bit charcodes defined in Unicode (i.e., surrogates), */
386 /* all character codes must be expressed as FT_Longs. */
388 /* Other encodings might be defined in the future. */
390 typedef enum FT_Encoding_
392 FT_ENC_TAG( ft_encoding_none, 0, 0, 0, 0 ),
394 FT_ENC_TAG( ft_encoding_symbol, 's', 'y', 'm', 'b' ),
395 FT_ENC_TAG( ft_encoding_unicode, 'u', 'n', 'i', 'c' ),
396 FT_ENC_TAG( ft_encoding_latin_2, 'l', 'a', 't', '2' ),
397 FT_ENC_TAG( ft_encoding_sjis, 's', 'j', 'i', 's' ),
398 FT_ENC_TAG( ft_encoding_gb2312, 'g', 'b', ' ', ' ' ),
399 FT_ENC_TAG( ft_encoding_big5, 'b', 'i', 'g', '5' ),
400 FT_ENC_TAG( ft_encoding_wansung, 'w', 'a', 'n', 's' ),
401 FT_ENC_TAG( ft_encoding_johab, 'j', 'o', 'h', 'a' ),
403 FT_ENC_TAG( ft_encoding_adobe_standard, 'A', 'D', 'O', 'B' ),
404 FT_ENC_TAG( ft_encoding_adobe_expert, 'A', 'D', 'B', 'E' ),
405 FT_ENC_TAG( ft_encoding_adobe_custom, 'A', 'D', 'B', 'C' ),
407 FT_ENC_TAG( ft_encoding_apple_roman, 'a', 'r', 'm', 'n' )
412 /*************************************************************************/
418 /* The base charmap class. */
421 /* face :: A handle to the parent face object. */
423 /* encoding :: A tag which identifies the charmap. Use this with */
424 /* FT_Select_Charmap(). */
426 /* platform_id :: An ID number describing the platform for the */
427 /* following encoding ID. This comes directly from */
428 /* the TrueType specification and should be emulated */
429 /* for other formats. */
431 /* encoding_id :: A platform specific encoding number. This also */
432 /* comes from the TrueType specification and should be */
433 /* emulated similarly. */
436 /* We STRONGLY recommmend emulating a Unicode charmap for drivers */
437 /* that do not support TrueType or OpenType. */
439 typedef struct FT_CharMapRec_
442 FT_Encoding encoding;
443 FT_UShort platform_id;
444 FT_UShort encoding_id;
449 /*************************************************************************/
450 /*************************************************************************/
452 /* B A S E O B J E C T C L A S S E S */
454 /*************************************************************************/
455 /*************************************************************************/
458 /*************************************************************************/
461 /* FT_Face_Internal */
464 /* An opaque handle to an FT_Face_InternalRec structure, used to */
465 /* model private data of a given FT_Face object. */
467 /* This field might change between releases of FreeType 2 and are */
468 /* not generally available to client applications. */
470 typedef struct FT_Face_InternalRec_* FT_Face_Internal;
473 /*************************************************************************/
475 /* FreeType base face class */
481 /* FreeType root face class structure. A face object models the */
482 /* resolution and point-size independent data found in a font file. */
485 /* num_faces :: In the case where the face is located in a */
486 /* collection (i.e., a resource which embeds */
487 /* several faces), this is the total number of */
488 /* faces found in the resource. 1 by default. */
490 /* face_index :: The index of the face in its resource. */
491 /* Usually, this is 0 for all normal font */
492 /* formats. It can be more in the case of */
493 /* collections (which embed several fonts in a */
494 /* single resource/file). */
496 /* face_flags :: A set of bit flags that give important */
497 /* information about the face; see the */
498 /* FT_FACE_FLAG_XXX macros for details. */
500 /* style_flags :: A set of bit flags indicating the style of */
501 /* the face (i.e., italic, bold, underline, */
504 /* num_glyphs :: The total number of glyphs in the face. */
506 /* family_name :: The face's family name. This is an ASCII */
507 /* string, usually in English, which describes */
508 /* the typeface's family (like `Times New */
509 /* Roman', `Bodoni', `Garamond', etc). This */
510 /* is a least common denominator used to list */
511 /* fonts. Some formats (TrueType & OpenType) */
512 /* provide localized and Unicode versions of */
513 /* this string. Applications should use the */
514 /* format specific interface to access them. */
516 /* style_name :: The face's style name. This is an ASCII */
517 /* string, usually in English, which describes */
518 /* the typeface's style (like `Italic', */
519 /* `Bold', `Condensed', etc). Not all font */
520 /* formats provide a style name, so this field */
521 /* is optional, and can be set to NULL. As */
522 /* for `family_name', some formats provide */
523 /* localized/Unicode versions of this string. */
524 /* Applications should use the format specific */
525 /* interface to access them. */
527 /* num_fixed_sizes :: The number of fixed sizes available in this */
528 /* face. This should be set to 0 for scalable */
529 /* fonts, unless its resource includes a */
530 /* complete set of glyphs (called a `strike') */
531 /* for the specified size. */
533 /* available_sizes :: An array of sizes specifying the available */
534 /* bitmap/graymap sizes that are contained in */
535 /* in the font resource. Should be set to */
536 /* NULL if the field `num_fixed_sizes' is set */
539 /* num_charmaps :: The total number of character maps in the */
542 /* charmaps :: A table of pointers to the face's charmaps. */
543 /* Used to scan the list of available charmaps */
544 /* -- this table might change after a call to */
545 /* FT_Attach_File/Stream (e.g. when used to */
546 /* hook an additional encoding/CMap to the */
549 /* generic :: A field reserved for client uses. See the */
550 /* FT_Generic type description. */
552 /* bbox :: The font bounding box. Coordinates are */
553 /* expressed in font units (see units_per_EM). */
554 /* The box is large enough to contain any */
555 /* glyph from the font. Thus, bbox.yMax can */
556 /* be seen as the `maximal ascender', */
557 /* bbox.yMin as the `minimal descender', and */
558 /* the maximal glyph width is given by */
559 /* `bbox.xMax-bbox.xMin' (not to be confused */
560 /* with the maximal _advance_width_). Only */
561 /* relevant for scalable formats. */
563 /* units_per_EM :: The number of font units per EM square for */
564 /* this face. This is typically 2048 for */
565 /* TrueType fonts, 1000 for Type1 fonts, and */
566 /* should be set to the (unrealistic) value 1 */
567 /* for fixed-sizes fonts. Only relevant for */
568 /* scalable formats. */
570 /* ascender :: The face's ascender is the vertical */
571 /* distance from the baseline to the topmost */
572 /* point of any glyph in the face. This */
573 /* field's value is positive, expressed in */
574 /* font units. Some font designs use a value */
575 /* different from `bbox.yMax'. Only relevant */
576 /* for scalable formats. */
578 /* descender :: The face's descender is the vertical */
579 /* distance from the baseline to the */
580 /* bottommost point of any glyph in the face. */
581 /* This field's value is positive, expressed */
582 /* in font units. Some font designs use a */
583 /* value different from `-bbox.yMin'. Only */
584 /* relevant for scalable formats. */
586 /* height :: The face's height is the vertical distance */
587 /* from one baseline to the next when writing */
588 /* several lines of text. Its value is always */
589 /* positive, expressed in font units. The */
590 /* value can be computed as */
591 /* `ascender+descender+line_gap' where the */
592 /* value of `line_gap' is also called */
593 /* `external leading'. Only relevant for */
594 /* scalable formats. */
596 /* max_advance_width :: The maximal advance width, in font units, */
597 /* for all glyphs in this face. This can be */
598 /* used to make word wrapping computations */
599 /* faster. Only relevant for scalable */
602 /* max_advance_height :: The maximal advance height, in font units, */
603 /* for all glyphs in this face. This is only */
604 /* relevant for vertical layouts, and should */
605 /* be set to the `height' for fonts that do */
606 /* not provide vertical metrics. Only */
607 /* relevant for scalable formats. */
609 /* underline_position :: The position, in font units, of the */
610 /* underline line for this face. It's the */
611 /* center of the underlining stem. Only */
612 /* relevant for scalable formats. */
614 /* underline_thickness :: The thickness, in font units, of the */
615 /* underline for this face. Only relevant for */
616 /* scalable formats. */
618 /* driver :: A handle to the face's parent driver */
621 /* memory :: A handle to the face's parent memory */
622 /* object. Used for the allocation of */
623 /* subsequent objects. */
625 /* stream :: A handle to the face's stream. */
627 /* glyph :: The face's associated glyph slot(s). This */
628 /* object is created automatically with a new */
629 /* face object. However, certain kinds of */
630 /* applications (mainly tools like converters) */
631 /* can need more than one slot to ease their */
634 /* sizes_list :: The list of child sizes for this face. */
636 /* internal :: A pointer to internal fields of the face */
637 /* object. These fields can change freely */
638 /* between releases of FreeType and are not */
639 /* publicly available. */
641 typedef struct FT_FaceRec_
651 FT_String* family_name;
652 FT_String* style_name;
654 FT_Int num_fixed_sizes;
655 FT_Bitmap_Size* available_sizes;
658 FT_CharMap* charmaps;
662 /*# the following are only relevant to scalable outlines */
665 FT_UShort units_per_EM;
670 FT_Short max_advance_width;
671 FT_Short max_advance_height;
673 FT_Short underline_position;
674 FT_Short underline_thickness;
686 FT_ListRec sizes_list;
691 FT_Face_Internal internal;
698 /*************************************************************************/
701 /* FT_FACE_FLAG_SCALABLE */
704 /* A bit-field constant, used to indicate that a given face provides */
705 /* vectorial outlines (i.e., TrueType or Type1). This doesn't */
706 /* prevent embedding of bitmap strikes though, i.e., a given face can */
707 /* have both this bit set, and a `num_fixed_sizes' property > 0. */
709 #define FT_FACE_FLAG_SCALABLE 1
712 /*************************************************************************/
715 /* FT_FACE_FLAG_FIXED_SIZES */
718 /* A bit-field constant, used to indicate that a given face contains */
719 /* `fixed sizes', i.e., bitmap strikes for some given pixel sizes. */
720 /* See the `num_fixed_sizes' and `available_sizes' face properties */
721 /* for more information. */
723 #define FT_FACE_FLAG_FIXED_SIZES 2
726 /*************************************************************************/
729 /* FT_FACE_FLAG_FIXED_WIDTH */
732 /* A bit-field constant, used to indicate that a given face contains */
733 /* fixed-width characters (like Courier, Lucida, MonoType, etc.). */
735 #define FT_FACE_FLAG_FIXED_WIDTH 4
738 /*************************************************************************/
741 /* FT_FACE_FLAG_SFNT */
744 /* A bit-field constant, used to indicate that a given face uses the */
745 /* `sfnt' storage fomat. For now, this means TrueType or OpenType. */
747 #define FT_FACE_FLAG_SFNT 8
750 /*************************************************************************/
753 /* FT_FACE_FLAG_HORIZONTAL */
756 /* A bit-field constant, used to indicate that a given face contains */
757 /* horizontal glyph metrics. This should be set for all common */
758 /* formats, but who knows. */
760 #define FT_FACE_FLAG_HORIZONTAL 0x10
763 /*************************************************************************/
766 /* FT_FACE_FLAG_VERTICAL */
769 /* A bit-field constant, used to indicate that a given face contains */
770 /* vertical glyph metrics. If not set, the glyph loader will */
771 /* synthetize vertical metrics itself to help display vertical text */
774 #define FT_FACE_FLAG_VERTICAL 0x20
777 /*************************************************************************/
780 /* FT_FACE_FLAG_KERNING */
783 /* A bit-field constant, used to indicate that a given face contains */
784 /* kerning information. When set, this information can be retrieved */
785 /* through the function FT_Get_Kerning(). Note that when unset, this */
786 /* function will always return the kerning vector (0,0). */
788 #define FT_FACE_FLAG_KERNING 0x40
791 /*************************************************************************/
794 /* FT_FACE_FLAG_FAST_GLYPHS */
797 /* A bit-field constant, used to indicate that the glyphs in a given */
798 /* font can be retrieved very quickly, and that a glyph cache is thus */
799 /* not necessary for any of its child size objects. */
801 /* This flag should really be set for fixed-size formats like FNT, */
802 /* where each glyph bitmap is available directly in binary form */
803 /* without any kind of compression. */
805 #define FT_FACE_FLAG_FAST_GLYPHS 0x80
808 /*************************************************************************/
811 /* FT_FACE_FLAG_MULTIPLE_MASTERS */
814 /* A bit-field constant, used to indicate that the font contains */
815 /* multiple masters and is capable of interpolating between them. */
817 #define FT_FACE_FLAG_MULTIPLE_MASTERS 0x100
820 /*************************************************************************/
823 /* FT_FACE_FLAG_GLYPH_NAMES */
826 /* A bit-field constant, used to indicate that the font contains */
827 /* glyph names that can be retrieved through FT_Get_Glyph_Name(). */
829 #define FT_FACE_FLAG_GLYPH_NAMES 0x200
832 /*************************************************************************/
835 /* FT_FACE_FLAG_EXTERNAL_STREAM */
838 /* This bit field is used internally by FreeType to indicate that */
839 /* a face's stream was provided by the client application and should */
840 /* not be destroyed by FT_Done_Face(). */
842 #define FT_FACE_FLAG_EXTERNAL_STREAM 0x4000
848 /*************************************************************************/
850 /* @macro: FT_HAS_HORIZONTAL (face) */
853 /* A macro that returns true whenever a face object contains */
854 /* horizontal metrics (this is true for all font formats though). */
857 /* @FT_HAS_VERTICAL can be used to check for vertical metrics. */
859 #define FT_HAS_HORIZONTAL( face ) \
860 ( face->face_flags & FT_FACE_FLAG_HORIZONTAL )
863 /*************************************************************************/
865 /* @macro: FT_HAS_VERTICAL (face) */
868 /* A macro that returns true whenever a face object contains vertical */
871 #define FT_HAS_VERTICAL( face ) \
872 ( face->face_flags & FT_FACE_FLAG_VERTICAL )
875 /*************************************************************************/
877 /* @macro: FT_HAS_KERNING (face) */
880 /* A macro that returns true whenever a face object contains kerning */
881 /* data that can be accessed with @FT_Get_Kerning. */
883 #define FT_HAS_KERNING( face ) \
884 ( face->face_flags & FT_FACE_FLAG_KERNING )
887 /*************************************************************************/
889 /* @macro: FT_IS_SCALABLE (face) */
892 /* A macro that returns true whenever a face object contains a */
893 /* scalable font face (true for TrueType, Type 1, CID, and */
894 /* OpenType/CFF font formats. */
896 #define FT_IS_SCALABLE( face ) \
897 ( face->face_flags & FT_FACE_FLAG_SCALABLE )
900 /*************************************************************************/
902 /* @macro: FT_IS_SFNT (face) */
905 /* A macro that returns true whenever a face object contains a font */
906 /* whose format is based on the SFNT storage scheme. This usually */
907 /* means: TrueType fonts, OpenType fonts, as well as SFNT-based */
908 /* embedded bitmap fonts. */
910 /* If this macro is true, all functions defined in @FT_SFNT_NAMES_H */
911 /* and @FT_TRUETYPE_TABLES_H are available. */
913 #define FT_IS_SFNT( face ) \
914 ( face->face_flags & FT_FACE_FLAG_SFNT )
917 /*************************************************************************/
919 /* @macro: FT_IS_FIXED_WIDTH (face) */
922 /* A macro that returns true whenever a face object contains a font */
923 /* face that contains fixed-width (or "monospace", "fixed-pitch", */
926 #define FT_IS_FIXED_WIDTH( face ) \
927 ( face->face_flags & FT_FACE_FLAG_FIXED_WIDTH )
930 /*************************************************************************/
932 /* @macro: FT_IS_FIXED_SIZES (face) */
935 /* A macro that returns true whenever a face object contains some */
936 /* embedded bitmaps. See the `fixed_sizes' field of the @FT_FaceRec */
939 #define FT_HAS_FIXED_SIZES( face ) \
940 ( face->face_flags & FT_FACE_FLAG_FIXED_SIZES )
946 /*************************************************************************/
948 /* @macro: FT_HAS_FAST_GLYPHS (face) */
953 #define FT_HAS_FAST_GLYPHS( face ) \
954 ( face->face_flags & FT_FACE_FLAG_FAST_GLYPHS )
957 /*************************************************************************/
959 /* @macro: FT_HAS_GLYPH_NAMES (face) */
962 /* A macro that returns true whenever a face object contains some */
963 /* glyph names that can be accessed through @FT_Get_Glyph_Names. */
965 #define FT_HAS_GLYPH_NAMES( face ) \
966 ( face->face_flags & FT_FACE_FLAG_GLYPH_NAMES )
969 /*************************************************************************/
971 /* @macro: FT_HAS_MULTIPLE_MASTERS (face) */
974 /* A macro that returns true whenever a face object contains some */
975 /* multiple masters. The functions provided by */
976 /* @FT_MULTIPLE_MASTERS_H are then available to choose the exact */
977 /* design you want. */
979 #define FT_HAS_MULTIPLE_MASTERS( face ) \
980 ( face->face_flags & FT_FACE_FLAG_MULTIPLE_MASTERS )
983 /*************************************************************************/
986 /* FT_STYLE_FLAG_ITALIC */
989 /* A bit-field constant, used to indicate that a given face is */
992 #define FT_STYLE_FLAG_ITALIC 1
995 /*************************************************************************/
998 /* FT_STYLE_FLAG_BOLD */
1001 /* A bit-field constant, used to indicate that a given face is */
1004 #define FT_STYLE_FLAG_BOLD 2
1007 /*************************************************************************/
1010 /* FT_Size_Internal */
1013 /* An opaque handle to an FT_Size_InternalRec structure, used to */
1014 /* model private data of a given FT_Size object. */
1016 typedef struct FT_Size_InternalRec_* FT_Size_Internal;
1019 /*************************************************************************/
1021 /* FreeType base size metrics */
1024 /* FT_Size_Metrics */
1027 /* The size metrics structure returned scaled important distances for */
1028 /* a given size object. */
1031 /* x_ppem :: The character width, expressed in integer pixels. */
1032 /* This is the width of the EM square expressed in */
1033 /* pixels, hence the term `ppem' (pixels per EM). */
1035 /* y_ppem :: The character height, expressed in integer pixels. */
1036 /* This is the height of the EM square expressed in */
1037 /* pixels, hence the term `ppem' (pixels per EM). */
1039 /* x_scale :: A simple 16.16 fixed point format coefficient used */
1040 /* to scale horizontal distances expressed in font */
1041 /* units to fractional (26.6) pixel coordinates. */
1043 /* y_scale :: A simple 16.16 fixed point format coefficient used */
1044 /* to scale vertical distances expressed in font */
1045 /* units to fractional (26.6) pixel coordinates. */
1047 /* ascender :: The ascender, expressed in 26.6 fixed point */
1048 /* pixels. Always positive. */
1050 /* descender :: The descender, expressed in 26.6 fixed point */
1051 /* pixels. Always positive. */
1053 /* height :: The text height, expressed in 26.6 fixed point */
1054 /* pixels. Always positive. */
1056 /* max_advance :: Maximum horizontal advance, expressed in 26.6 */
1057 /* fixed point pixels. Always positive. */
1060 /* The values of `ascender', `descender', and `height' are only the */
1061 /* scaled versions of `face->ascender', `face->descender', and */
1062 /* `face->height'. */
1064 /* Unfortunately, due to glyph hinting, these values might not be */
1065 /* exact for certain fonts, they thus must be treated as unreliable */
1066 /* with an error margin of at least one pixel! */
1068 /* Indeed, the only way to get the exact pixel ascender and descender */
1069 /* is to render _all_ glyphs. As this would be a definite */
1070 /* performance hit, it is up to client applications to perform such */
1073 typedef struct FT_Size_Metrics_
1075 FT_UShort x_ppem; /* horizontal pixels per EM */
1076 FT_UShort y_ppem; /* vertical pixels per EM */
1078 FT_Fixed x_scale; /* two scales used to convert font units */
1079 FT_Fixed y_scale; /* to 26.6 frac. pixel coordinates.. */
1081 FT_Pos ascender; /* ascender in 26.6 frac. pixels */
1082 FT_Pos descender; /* descender in 26.6 frac. pixels */
1083 FT_Pos height; /* text height in 26.6 frac. pixels */
1084 FT_Pos max_advance; /* max horizontal advance, in 26.6 pixels */
1089 /*************************************************************************/
1091 /* FreeType base size class */
1097 /* FreeType root size class structure. A size object models the */
1098 /* resolution and pointsize dependent data of a given face. */
1101 /* face :: Handle to the parent face object. */
1103 /* generic :: A typeless pointer, which is unused by the FreeType */
1104 /* library or any of its drivers. It can be used by */
1105 /* client applications to link their own data to each size */
1108 /* metrics :: Metrics for this size object. This field is read-only. */
1110 typedef struct FT_SizeRec_
1112 FT_Face face; /* parent face object */
1113 FT_Generic generic; /* generic pointer for client uses */
1114 FT_Size_Metrics metrics; /* size metrics */
1115 FT_Size_Internal internal;
1120 /*************************************************************************/
1126 /* The subglyph structure is an internal object used to describe */
1127 /* subglyphs (for example, in the case of composites). */
1130 /* The subglyph implementation is not part of the high-level API, */
1131 /* hence the forward structure declaration. */
1133 typedef struct FT_SubGlyph_ FT_SubGlyph;
1136 /*************************************************************************/
1139 /* FT_Slot_Internal */
1142 /* An opaque handle to an FT_Slot_InternalRec structure, used to */
1143 /* model private data of a given FT_GlyphSlot object. */
1145 typedef struct FT_Slot_InternalRec_* FT_Slot_Internal;
1148 /*************************************************************************/
1150 /* FreeType Glyph Slot base class */
1153 /* FT_GlyphSlotRec */
1156 /* FreeType root glyph slot class structure. A glyph slot is a */
1157 /* container where individual glyphs can be loaded, be they */
1158 /* vectorial or bitmap/graymaps. */
1161 /* library :: A handle to the FreeType library instance */
1162 /* this slot belongs to. */
1164 /* face :: A handle to the parent face object. */
1166 /* next :: In some cases (like some font tools), several */
1167 /* glyph slots per face object can be a good */
1168 /* thing. As this is rare, the glyph slots are */
1169 /* listed through a direct, single-linked list */
1170 /* using its `next' field. */
1172 /* generic :: A typeless pointer which is unused by the */
1173 /* FreeType library or any of its drivers. It */
1174 /* can be used by client applications to link */
1175 /* their own data to each glyph slot object. */
1177 /* metrics :: The metrics of the last loaded glyph in the */
1178 /* slot. The returned values depend on the last */
1179 /* load flags (see the FT_Load_Glyph() API */
1180 /* function) and can be expressed either in 26.6 */
1181 /* fractional pixels or font units. */
1183 /* Note that even when the glyph image is */
1184 /* transformed, the metrics are not. */
1186 /* linearHoriAdvance :: For scalable formats only, this field holds */
1187 /* the linearly scaled horizontal advance width */
1188 /* for the glyph (i.e. the scaled and unhinted */
1189 /* value of the hori advance). This can be */
1190 /* important to perform correct WYSIWYG layout. */
1192 /* Note that this value is expressed by default */
1193 /* in 16.16 pixels. However, when the glyph is */
1194 /* loaded with the FT_LOAD_LINEAR_DESIGN flag, */
1195 /* this field contains simply the value of the */
1196 /* advance in original font units. */
1198 /* linearVertAdvance :: For scalable formats only, this field holds */
1199 /* the linearly scaled vertical advance height */
1200 /* for the glyph. See linearHoriAdvance for */
1203 /* advance :: This is the transformed advance width for the */
1206 /* format :: This field indicates the format of the image */
1207 /* contained in the glyph slot. Typically */
1208 /* ft_glyph_format_bitmap, */
1209 /* ft_glyph_format_outline, and */
1210 /* ft_glyph_format_composite, but others are */
1213 /* bitmap :: This field is used as a bitmap descriptor */
1214 /* when the slot format is */
1215 /* ft_glyph_format_bitmap. Note that the */
1216 /* address and content of the bitmap buffer can */
1217 /* change between calls of FT_Load_Glyph() and a */
1218 /* few other functions. */
1220 /* bitmap_left :: This is the bitmap's left bearing expressed */
1221 /* in integer pixels. Of course, this is only */
1222 /* valid if the format is */
1223 /* ft_glyph_format_bitmap. */
1225 /* bitmap_top :: This is the bitmap's top bearing expressed in */
1226 /* integer pixels. Remember that this is the */
1227 /* distance from the baseline to the top-most */
1228 /* glyph scanline, upwards y-coordinates being */
1231 /* outline :: The outline descriptor for the current glyph */
1232 /* image if its format is */
1233 /* ft_glyph_bitmap_outline. */
1235 /* num_subglyphs :: The number of subglyphs in a composite glyph. */
1236 /* This format is only valid for the composite */
1237 /* glyph format, that should normally only be */
1238 /* loaded with the FT_LOAD_NO_RECURSE flag. */
1240 /* subglyphs :: An array of subglyph descriptors for */
1241 /* composite glyphs. There are `num_subglyphs' */
1242 /* elements in there. */
1244 /* control_data :: Certain font drivers can also return the */
1245 /* control data for a given glyph image (e.g. */
1246 /* TrueType bytecode, Type 1 charstrings, etc.). */
1247 /* This field is a pointer to such data. */
1249 /* control_len :: This is the length in bytes of the control */
1252 /* other :: Really wicked formats can use this pointer to */
1253 /* present their own glyph image to client apps. */
1254 /* Note that the app will need to know about the */
1258 /* If @FT_Load_Glyph() is called with default flags (see */
1259 /* @FT_LOAD_DEFAULT ) the glyph image is loaded in the glyph slot in */
1260 /* its native format (e.g. a vectorial outline for TrueType and */
1261 /* Type 1 formats). */
1263 /* This image can later be converted into a bitmap by calling */
1264 /* FT_Render_Glyph(). This function finds the current renderer for */
1265 /* the native image's format then invokes it. */
1267 /* The renderer is in charge of transforming the native image through */
1268 /* the slot's face transformation fields, then convert it into a */
1269 /* bitmap that is returned in `slot->bitmap'. */
1271 /* Note that `slot->bitmap_left' and `slot->bitmap_top' are also used */
1272 /* to specify the position of the bitmap relative to the current pen */
1273 /* position (e.g. coordinates [0,0] on the baseline). Of course, */
1274 /* `slot->format' is also changed to `ft_glyph_format_bitmap' . */
1276 typedef struct FT_GlyphSlotRec_
1284 FT_Glyph_Metrics metrics;
1285 FT_Fixed linearHoriAdvance;
1286 FT_Fixed linearVertAdvance;
1289 FT_Glyph_Format format;
1297 FT_UInt num_subglyphs;
1298 FT_SubGlyph* subglyphs;
1305 FT_Slot_Internal internal;
1310 /*************************************************************************/
1311 /*************************************************************************/
1313 /* F U N C T I O N S */
1315 /*************************************************************************/
1316 /*************************************************************************/
1319 /*************************************************************************/
1322 /* FT_Init_FreeType */
1325 /* Initializes a new FreeType library object. The set of drivers */
1326 /* that are registered by this function is determined at build time. */
1329 /* alibrary :: A handle to a new library object. */
1332 /* FreeType error code. 0 means success. */
1334 FT_EXPORT( FT_Error )
1335 FT_Init_FreeType( FT_Library *alibrary );
1338 /*************************************************************************/
1341 /* FT_Done_FreeType */
1344 /* Destroys a given FreeType library object and all of its childs, */
1345 /* including resources, drivers, faces, sizes, etc. */
1348 /* library :: A handle to the target library object. */
1351 /* FreeType error code. 0 means success. */
1353 FT_EXPORT( FT_Error )
1354 FT_Done_FreeType( FT_Library library );
1357 /*************************************************************************/
1363 /* An enumeration used to list the bit flags used within the */
1364 /* `flags' field of the @FT_Open_Args structure. */
1367 /* ft_open_memory :: This is a memory-based stream. */
1369 /* ft_open_stream :: Copy the stream from the `stream' field. */
1371 /* ft_open_pathname :: Create a new input stream from a C pathname. */
1373 /* ft_open_driver :: Use the `driver' field. */
1375 /* ft_open_params :: Use the `num_params' & `params' field. */
1378 /* The `ft_open_memory', `ft_open_stream', and `ft_open_pathname' */
1379 /* flags are mutually exclusive. */
1385 ft_open_pathname = 4,
1392 /*************************************************************************/
1398 /* A simple structure used to pass more or less generic parameters */
1399 /* to FT_Open_Face(). */
1402 /* tag :: A 4-byte identification tag. */
1404 /* data :: A pointer to the parameter data. */
1407 /* The id and function of parameters are driver-specific. */
1409 typedef struct FT_Parameter_
1417 /*************************************************************************/
1423 /* A structure used to indicate how to open a new font file/stream. */
1424 /* A pointer to such a structure can be used as a parameter for the */
1425 /* functions @FT_Open_Face() & @FT_Attach_Stream(). */
1428 /* flags :: A set of bit flags indicating how to use the */
1431 /* memory_base :: The first byte of the file in memory. */
1433 /* memory_size :: The size in bytes of the file in memory. */
1435 /* pathname :: A pointer to an 8-bit file pathname. */
1437 /* stream :: A handle to a source stream object. */
1439 /* driver :: This field is exclusively used by FT_Open_Face(); */
1440 /* it simply specifies the font driver to use to open */
1441 /* the face. If set to 0, FreeType will try to load */
1442 /* the face with each one of the drivers in its list. */
1444 /* num_params :: The number of extra parameters. */
1446 /* params :: Extra parameters passed to the font driver when */
1447 /* opening a new face. */
1450 /* The stream type is determined by the contents of `flags' which */
1451 /* are tested in the following order by @FT_Open_Face: */
1453 /* If the `ft_open_memory' bit is set, assume that this is a */
1454 /* memory file of `memory_size' bytes,located at `memory_address'. */
1456 /* Otherwise, if the `ft_open_stream' bit is set, assume that a */
1457 /* custom input stream `stream' is used. */
1459 /* Otherwise, if the `ft_open_pathname' bit is set, assume that this */
1460 /* is a normal file and use `pathname' to open it. */
1462 /* If the `ft_open_driver' bit is set, @FT_Open_Face() will only */
1463 /* try to open the file with the driver whose handler is in `driver'. */
1465 /* If the `ft_open_params' bit is set, the parameters given by */
1466 /* `num_params' and `params' will be used. They are ignored */
1469 typedef struct FT_Open_Args_
1471 FT_Open_Flags flags;
1472 const FT_Byte* memory_base;
1473 FT_Long memory_size;
1474 FT_String* pathname;
1478 FT_Parameter* params;
1483 /*************************************************************************/
1489 /* Creates a new face object from a given resource and typeface index */
1490 /* using a pathname to the font file. */
1493 /* library :: A handle to the library resource. */
1496 /* pathname :: A path to the font file. */
1498 /* face_index :: The index of the face within the resource. The */
1499 /* first face has index 0. */
1501 /* aface :: A handle to a new face object. */
1504 /* FreeType error code. 0 means success. */
1507 /* Unlike FreeType 1.x, this function automatically creates a glyph */
1508 /* slot for the face object which can be accessed directly through */
1509 /* `face->glyph'. */
1511 /* FT_New_Face() can be used to determine and/or check the font */
1512 /* format of a given font resource. If the `face_index' field is */
1513 /* negative, the function will _not_ return any face handle in */
1514 /* `aface'. Its return value should be 0 if the font format is */
1515 /* recognized, or non-zero otherwise. */
1517 FT_EXPORT( FT_Error )
1518 FT_New_Face( FT_Library library,
1519 const char* filepathname,
1524 /*************************************************************************/
1527 /* FT_New_Memory_Face */
1530 /* Creates a new face object from a given resource and typeface index */
1531 /* using a font file already loaded into memory. */
1534 /* library :: A handle to the library resource. */
1537 /* file_base :: A pointer to the beginning of the font data. */
1539 /* file_size :: The size of the memory chunk used by the font data. */
1541 /* face_index :: The index of the face within the resource. The */
1542 /* first face has index 0. */
1544 /* aface :: A handle to a new face object. */
1547 /* FreeType error code. 0 means success. */
1550 /* The font data bytes are used _directly_ by the @FT_Face object. */
1551 /* This means that they are not copied, and that the client is */
1552 /* responsible for releasing/destroying them _after_ the */
1553 /* corresponding call to @FT_Done_Face . */
1555 /* Unlike FreeType 1.x, this function automatically creates a glyph */
1556 /* slot for the face object which can be accessed directly through */
1557 /* `face->glyph'. */
1559 /* FT_New_Memory_Face() can be used to determine and/or check the */
1560 /* font format of a given font resource. If the `face_index' field */
1561 /* is negative, the function will _not_ return any face handle in */
1562 /* `aface'. Its return value should be 0 if the font format is */
1563 /* recognized, or non-zero otherwise. */
1565 FT_EXPORT( FT_Error )
1566 FT_New_Memory_Face( FT_Library library,
1567 const FT_Byte* file_base,
1573 /*************************************************************************/
1579 /* Opens a face object from a given resource and typeface index using */
1580 /* an `FT_Open_Args' structure. If the face object doesn't exist, it */
1581 /* will be created. */
1584 /* library :: A handle to the library resource. */
1587 /* args :: A pointer to an `FT_Open_Args' structure which must */
1588 /* be filled by the caller. */
1590 /* face_index :: The index of the face within the resource. The */
1591 /* first face has index 0. */
1593 /* aface :: A handle to a new face object. */
1596 /* FreeType error code. 0 means success. */
1599 /* Unlike FreeType 1.x, this function automatically creates a glyph */
1600 /* slot for the face object which can be accessed directly through */
1601 /* `face->glyph'. */
1603 /* FT_Open_Face() can be used to determine and/or check the font */
1604 /* format of a given font resource. If the `face_index' field is */
1605 /* negative, the function will _not_ return any face handle in */
1606 /* `*face'. Its return value should be 0 if the font format is */
1607 /* recognized, or non-zero otherwise. */
1609 FT_EXPORT( FT_Error )
1610 FT_Open_Face( FT_Library library,
1616 /*************************************************************************/
1619 /* FT_Attach_File */
1622 /* `Attaches' a given font file to an existing face. This is usually */
1623 /* to read additional information for a single face object. For */
1624 /* example, it is used to read the AFM files that come with Type 1 */
1625 /* fonts in order to add kerning data and other metrics. */
1628 /* face :: The target face object. */
1631 /* filepathname :: An 8-bit pathname naming the `metrics' file. */
1634 /* FreeType error code. 0 means success. */
1637 /* If your font file is in memory, or if you want to provide your */
1638 /* own input stream object, use FT_Attach_Stream(). */
1640 /* The meaning of the `attach' action (i.e., what really happens when */
1641 /* the new file is read) is not fixed by FreeType itself. It really */
1642 /* depends on the font format (and thus the font driver). */
1644 /* Client applications are expected to know what they are doing */
1645 /* when invoking this function. Most drivers simply do not implement */
1646 /* file attachments. */
1648 FT_EXPORT( FT_Error )
1649 FT_Attach_File( FT_Face face,
1650 const char* filepathname );
1653 /*************************************************************************/
1656 /* FT_Attach_Stream */
1659 /* This function is similar to FT_Attach_File() with the exception */
1660 /* that it reads the attachment from an arbitrary stream. */
1663 /* face :: The target face object. */
1666 /* parameters :: A pointer to an FT_Open_Args structure used to */
1667 /* describe the input stream to FreeType. */
1669 /* FreeType error code. 0 means success. */
1672 /* The meaning of the `attach' (i.e. what really happens when the */
1673 /* new file is read) is not fixed by FreeType itself. It really */
1674 /* depends on the font format (and thus the font driver). */
1676 /* Client applications are expected to know what they are doing */
1677 /* when invoking this function. Most drivers simply do not implement */
1678 /* file attachments. */
1680 FT_EXPORT( FT_Error )
1681 FT_Attach_Stream( FT_Face face,
1682 FT_Open_Args* parameters );
1685 /*************************************************************************/
1691 /* Discards a given face object, as well as all of its child slots */
1695 /* face :: A handle to a target face object. */
1698 /* FreeType error code. 0 means success. */
1700 FT_EXPORT( FT_Error )
1701 FT_Done_Face( FT_Face face );
1704 /*************************************************************************/
1707 /* FT_Set_Char_Size */
1710 /* Sets the character dimensions of a given face object. The */
1711 /* `char_width' and `char_height' values are used for the width and */
1712 /* height, respectively, expressed in 26.6 fractional points. */
1714 /* If the horizontal or vertical resolution values are zero, a */
1715 /* default value of 72dpi is used. Similarly, if one of the */
1716 /* character dimensions is zero, its value is set equal to the other. */
1719 /* size :: A handle to a target size object. */
1722 /* char_width :: The character width, in 26.6 fractional points. */
1724 /* char_height :: The character height, in 26.6 fractional */
1727 /* horz_resolution :: The horizontal resolution. */
1729 /* vert_resolution :: The vertical resolution. */
1732 /* FreeType error code. 0 means success. */
1735 /* When dealing with fixed-size faces (i.e., non-scalable formats), */
1736 /* use the function FT_Set_Pixel_Sizes(). */
1738 FT_EXPORT( FT_Error )
1739 FT_Set_Char_Size( FT_Face face,
1740 FT_F26Dot6 char_width,
1741 FT_F26Dot6 char_height,
1742 FT_UInt horz_resolution,
1743 FT_UInt vert_resolution );
1746 /*************************************************************************/
1749 /* FT_Set_Pixel_Sizes */
1752 /* Sets the character dimensions of a given face object. The width */
1753 /* and height are expressed in integer pixels. */
1755 /* If one of the character dimensions is zero, its value is set equal */
1759 /* face :: A handle to the target face object. */
1762 /* pixel_width :: The character width, in integer pixels. */
1764 /* pixel_height :: The character height, in integer pixels. */
1767 /* FreeType error code. 0 means success. */
1771 /* The values of `pixel_width' and `pixel_height' correspond to the */
1772 /* pixel values of the _typographic_ character size, which are NOT */
1773 /* necessarily the same as the dimensions of the glyph `bitmap */
1776 /* The `character size' is really the size of an abstract square */
1777 /* called the `EM', used to design the font. However, depending */
1778 /* on the font design, glyphs will be smaller or greater than the */
1781 /* This means that setting the pixel size to, say, 8x8 doesn't */
1782 /* guarantee in any way that you will get glyph bitmaps that all fit */
1783 /* within an 8x8 cell (sometimes even far from it). */
1785 FT_EXPORT( FT_Error )
1786 FT_Set_Pixel_Sizes( FT_Face face,
1787 FT_UInt pixel_width,
1788 FT_UInt pixel_height );
1791 /*************************************************************************/
1797 /* A function used to load a single glyph within a given glyph slot, */
1798 /* for a given size. */
1801 /* face :: A handle to the target face object where the glyph */
1802 /* will be loaded. */
1805 /* glyph_index :: The index of the glyph in the font file. */
1807 /* load_flags :: A flag indicating what to load for this glyph. The */
1808 /* FT_LOAD_XXX constants can be used to control the */
1809 /* glyph loading process (e.g., whether the outline */
1810 /* should be scaled, whether to load bitmaps or not, */
1811 /* whether to hint the outline, etc). */
1814 /* FreeType error code. 0 means success. */
1817 /* If the glyph image is not a bitmap, and if the bit flag */
1818 /* FT_LOAD_IGNORE_TRANSFORM is unset, the glyph image will be */
1819 /* transformed with the information passed to a previous call to */
1820 /* FT_Set_Transform(). */
1822 /* Note that this also transforms the `face.glyph.advance' field, but */
1823 /* *not* the values in `face.glyph.metrics'. */
1825 FT_EXPORT( FT_Error )
1826 FT_Load_Glyph( FT_Face face,
1827 FT_UInt glyph_index,
1828 FT_Int load_flags );
1831 /*************************************************************************/
1837 /* A function used to load a single glyph within a given glyph slot, */
1838 /* for a given size, according to its character code. */
1841 /* face :: A handle to a target face object where the glyph */
1842 /* will be loaded. */
1845 /* char_code :: The glyph's character code, according to the */
1846 /* current charmap used in the face. */
1848 /* load_flags :: A flag indicating what to load for this glyph. The */
1849 /* FT_LOAD_XXX constants can be used to control the */
1850 /* glyph loading process (e.g., whether the outline */
1851 /* should be scaled, whether to load bitmaps or not, */
1852 /* whether to hint the outline, etc). */
1855 /* FreeType error code. 0 means success. */
1858 /* If the face has no current charmap, or if the character code */
1859 /* is not defined in the charmap, this function will return an */
1862 /* If the glyph image is not a bitmap, and if the bit flag */
1863 /* FT_LOAD_IGNORE_TRANSFORM is unset, the glyph image will be */
1864 /* transformed with the information passed to a previous call to */
1865 /* FT_Set_Transform(). */
1867 /* Note that this also transforms the `face.glyph.advance' field, but */
1868 /* *not* the values in `face.glyph.metrics'. */
1870 FT_EXPORT( FT_Error )
1871 FT_Load_Char( FT_Face face,
1873 FT_Int load_flags );
1876 /*************************************************************************/
1879 /* FT_LOAD_NO_SCALE */
1882 /* A bit field constant, used with FT_Load_Glyph() to indicate that */
1883 /* the vector outline being loaded should not be scaled to 26.6 */
1884 /* fractional pixels, but kept in notional units. */
1886 #define FT_LOAD_NO_SCALE 1
1889 /*************************************************************************/
1892 /* FT_LOAD_NO_HINTING */
1895 /* A bit-field constant, used with FT_Load_Glyph() to indicate that */
1896 /* the vector outline being loaded should not be fitted to the pixel */
1897 /* grid but simply scaled to 26.6 fractional pixels. */
1899 /* This flag is ignored if FT_LOAD_NO_SCALE is set. */
1901 #define FT_LOAD_NO_HINTING 2
1904 /*************************************************************************/
1907 /* FT_LOAD_RENDER */
1910 /* A bit-field constant, used with FT_Load_Glyph() to indicate that */
1911 /* the function should load the glyph and immediately convert it into */
1912 /* a bitmap, if necessary, by calling FT_Render_Glyph(). */
1914 /* Note that by default, FT_Load_Glyph() loads the glyph image in its */
1915 /* native format. */
1917 #define FT_LOAD_RENDER 4
1920 /*************************************************************************/
1923 /* FT_LOAD_NO_BITMAP */
1926 /* A bit-field constant, used with FT_Load_Glyph() to indicate that */
1927 /* the function should not load the bitmap or pixmap of a given */
1928 /* glyph. This is useful when you do not want to load the embedded */
1929 /* bitmaps of scalable formats, as the native glyph image will be */
1930 /* loaded, and can then be rendered through FT_Render_Glyph(). */
1932 #define FT_LOAD_NO_BITMAP 8
1935 /*************************************************************************/
1938 /* FT_LOAD_VERTICAL_LAYOUT */
1941 /* A bit-field constant, used with FT_Load_Glyph() to indicate that */
1942 /* the glyph image should be prepared for vertical layout. This */
1943 /* basically means that `face.glyph.advance' will correspond to the */
1944 /* vertical advance height (instead of the default horizontal */
1945 /* advance width), and that the glyph image will translated to match */
1946 /* the vertical bearings positions. */
1948 #define FT_LOAD_VERTICAL_LAYOUT 16
1951 /*************************************************************************/
1954 /* FT_LOAD_FORCE_AUTOHINT */
1957 /* A bit-field constant, used with FT_Load_Glyph() to indicate that */
1958 /* the function should try to auto-hint the glyphs, even if a driver */
1959 /* specific hinter is available. */
1961 #define FT_LOAD_FORCE_AUTOHINT 32
1964 /*************************************************************************/
1967 /* FT_LOAD_CROP_BITMAP */
1970 /* A bit-field constant, used with FT_Load_Glyph() to indicate that */
1971 /* the font driver should try to crop the bitmap (i.e. remove all */
1972 /* space around its black bits) when loading it. For now, this */
1973 /* really only works with embedded bitmaps in TrueType fonts. */
1975 #define FT_LOAD_CROP_BITMAP 64
1978 /*************************************************************************/
1981 /* FT_LOAD_PEDANTIC */
1984 /* A bit-field constant, used with FT_Load_Glyph() to indicate that */
1985 /* the glyph loader should perform a pedantic bytecode */
1986 /* interpretation. Many popular fonts come with broken glyph */
1987 /* programs. When this flag is set, loading them will return an */
1988 /* error. Otherwise, errors are ignored by the loader, sometimes */
1989 /* resulting in ugly glyphs. */
1991 #define FT_LOAD_PEDANTIC 128
1994 /*************************************************************************/
1997 /* FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH */
2000 /* A bit-field constant, used with FT_Load_Glyph() to indicate that */
2001 /* the glyph loader should ignore the global advance width defined */
2002 /* in the font. As far as we know, this is only used by the */
2003 /* X-TrueType font server, in order to deal correctly with the */
2004 /* incorrect metrics contained in DynaLab's TrueType CJK fonts. */
2006 #define FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH 512
2009 /*************************************************************************/
2012 /* FT_LOAD_NO_RECURSE */
2015 /* A bit-field constant, used with FT_Load_Glyph() to indicate that */
2016 /* the glyph loader should not load composite glyph recursively. */
2017 /* Rather, when a composite glyph is encountered, it should set */
2018 /* the values of `num_subglyphs' and `subglyphs', as well as set */
2019 /* `face->glyph.format' to ft_glyph_format_composite. */
2021 /* This is for use by the auto-hinter and possibly other tools. */
2022 /* For nearly all applications, this flags should be left unset */
2023 /* when invoking FT_Load_Glyph(). */
2025 /* Note that the flag forces the load of unscaled glyphs. */
2027 #define FT_LOAD_NO_RECURSE 1024
2030 /*************************************************************************/
2033 /* FT_LOAD_IGNORE_TRANSFORM */
2036 /* A bit-field constant, used with FT_Load_Glyph() to indicate that */
2037 /* the glyph loader should not try to transform the loaded glyph */
2040 #define FT_LOAD_IGNORE_TRANSFORM 2048
2043 /*************************************************************************/
2046 /* FT_LOAD_MONOCHROME */
2049 /* Only used with FT_LOAD_RENDER set, it indicates that the returned */
2050 /* glyph image should be 1-bit monochrome. This really tells the */
2051 /* glyph loader to use `ft_render_mode_mono' when calling */
2052 /* FT_Render_Glyph(). */
2054 #define FT_LOAD_MONOCHROME 4096
2057 /*************************************************************************/
2060 /* FT_LOAD_LINEAR_DESIGN */
2063 /* A bit-field constant, used with FT_Load_Glyph() to indicate that */
2064 /* the function should return the linearly scaled metrics expressed */
2065 /* in original font units, instead of the default 16.16 pixel values. */
2067 #define FT_LOAD_LINEAR_DESIGN 8192
2070 /*************************************************************************/
2073 /* FT_LOAD_DEFAULT */
2076 /* A bit-field constant, used with FT_Load_Glyph() to indicate that */
2077 /* the function should try to load the glyph normally, i.e., */
2078 /* embedded bitmaps are favored over outlines, vectors are always */
2079 /* scaled and grid-fitted. */
2081 #define FT_LOAD_DEFAULT 0
2084 /*************************************************************************/
2087 /* FT_Set_Transform */
2090 /* A function used to set the transformation that is applied to glyph */
2091 /* images just before they are converted to bitmaps in a glyph slot */
2092 /* when FT_Render_Glyph() is called. */
2095 /* face :: A handle to the source face object. */
2098 /* matrix :: A pointer to the transformation's 2x2 matrix. Use 0 for */
2099 /* the identity matrix. */
2100 /* delta :: A pointer to the translation vector. Use 0 for the null */
2104 /* The transformation is only applied to scalable image formats after */
2105 /* the glyph has been loaded. It means that hinting is unaltered by */
2106 /* the transformation and is performed on the character size given in */
2107 /* the last call to FT_Set_Char_Sizes() or FT_Set_Pixel_Sizes(). */
2110 FT_Set_Transform( FT_Face face,
2115 /*************************************************************************/
2118 /* FT_Render_Mode */
2121 /* An enumeration type that lists the render modes supported by the */
2122 /* FreeType 2 renderer(s). A renderer is in charge of converting a */
2123 /* glyph image into a bitmap. */
2126 /* ft_render_mode_normal :: This is the default render mode; it */
2127 /* corresponds to 8-bit anti-aliased */
2128 /* bitmaps, using 256 levels of gray. */
2130 /* ft_render_mode_mono :: This render mode is used to produce 1-bit */
2131 /* monochrome bitmaps. */
2134 /* There is no render mode to produce 8-bit `monochrome' bitmaps -- */
2135 /* you have to make the conversion yourself if you need such things */
2136 /* (besides, FreeType is not a graphics library). */
2138 /* More modes might appear later for specific display modes (e.g. TV, */
2139 /* LCDs, etc.). They will be supported through the simple addition */
2140 /* of a renderer module, with no changes to the rest of the engine. */
2142 typedef enum FT_Render_Mode_
2144 ft_render_mode_normal = 0,
2145 ft_render_mode_mono = 1
2150 /*************************************************************************/
2153 /* FT_Render_Glyph */
2156 /* Converts a given glyph image to a bitmap. It does so by */
2157 /* inspecting the glyph image format, find the relevant renderer, and */
2161 /* slot :: A handle to the glyph slot containing the image to */
2165 /* render_mode :: This is the render mode used to render the glyph */
2166 /* image into a bitmap. See FT_Render_Mode for a list */
2167 /* of possible values. */
2170 /* FreeType error code. 0 means success. */
2172 FT_EXPORT( FT_Error )
2173 FT_Render_Glyph( FT_GlyphSlot slot,
2174 FT_UInt render_mode );
2177 /*************************************************************************/
2180 /* FT_Kerning_Mode */
2183 /* An enumeration used to specify which kerning values to return in */
2184 /* FT_Get_Kerning(). */
2187 /* ft_kerning_default :: Return scaled and grid-fitted kerning */
2188 /* distances (value is 0). */
2190 /* ft_kerning_unfitted :: Return scaled but un-grid-fitted kerning */
2193 /* ft_kerning_unscaled :: Return the kerning vector in original font */
2196 typedef enum FT_Kerning_Mode_
2198 ft_kerning_default = 0,
2199 ft_kerning_unfitted,
2205 /*************************************************************************/
2208 /* FT_Get_Kerning */
2211 /* Returns the kerning vector between two glyphs of a same face. */
2214 /* face :: A handle to a source face object. */
2216 /* left_glyph :: The index of the left glyph in the kern pair. */
2218 /* right_glyph :: The index of the right glyph in the kern pair. */
2220 /* kern_mode :: See FT_Kerning_Mode() for more information. */
2221 /* Determines the scale/dimension of the returned */
2222 /* kerning vector. */
2225 /* akerning :: The kerning vector. This is in font units for */
2226 /* scalable formats, and in pixels for fixed-sizes */
2230 /* FreeType error code. 0 means success. */
2233 /* Only horizontal layouts (left-to-right & right-to-left) are */
2234 /* supported by this method. Other layouts, or more sophisticated */
2235 /* kernings, are out of the scope of this API function -- they can be */
2236 /* implemented through format-specific interfaces. */
2238 FT_EXPORT( FT_Error )
2239 FT_Get_Kerning( FT_Face face,
2241 FT_UInt right_glyph,
2243 FT_Vector *akerning );
2246 /*************************************************************************/
2249 /* FT_Get_Glyph_Name */
2252 /* Retrieves the ASCII name of a given glyph in a face. This only */
2253 /* works for those faces where FT_HAS_GLYPH_NAME(face) returns true. */
2256 /* face :: A handle to a source face object. */
2258 /* glyph_index :: The glyph index. */
2260 /* buffer_max :: The maximal number of bytes available in the */
2264 /* buffer :: A pointer to a target buffer where the name will be */
2268 /* FreeType error code. 0 means success. */
2271 /* An error is returned if the face doesn't provide glyph names or if */
2272 /* the glyph index is invalid. In all cases of failure, the first */
2273 /* byte of `buffer' will be set to 0 to indicate an empty name. */
2275 /* The glyph name is truncated to fit within the buffer if it is too */
2276 /* long. The returned string is always zero-terminated. */
2278 /* This function is not compiled within the library if the config */
2279 /* macro FT_CONFIG_OPTION_NO_GLYPH_NAMES is defined in */
2280 /* `include/freetype/config/ftoptions.h' */
2282 FT_EXPORT( FT_Error )
2283 FT_Get_Glyph_Name( FT_Face face,
2284 FT_UInt glyph_index,
2286 FT_UInt buffer_max );
2289 /*************************************************************************/
2292 /* FT_Get_Postscript_Name */
2295 /* Retrieves the ASCII Postscript name of a given face, when */
2296 /* available. This should only work with Postscript and TrueType */
2300 /* face :: handle to source face object. */
2303 /* pointer to face's Postscript name. NULL when un-available */
2306 /* The returned pointer is owned by the face and will be destroyed */
2309 FT_EXPORT( const char* )
2310 FT_Get_Postscript_Name( FT_Face face );
2313 /*************************************************************************/
2316 /* FT_Select_Charmap */
2319 /* Selects a given charmap by its encoding tag (as listed in */
2320 /* `freetype.h'). */
2323 /* face :: A handle to the source face object. */
2326 /* encoding :: A handle to the selected charmap. */
2329 /* FreeType error code. 0 means success. */
2332 /* This function will return an error if no charmap in the face */
2333 /* corresponds to the encoding queried here. */
2335 FT_EXPORT( FT_Error )
2336 FT_Select_Charmap( FT_Face face,
2337 FT_Encoding encoding );
2340 /*************************************************************************/
2343 /* FT_Set_Charmap */
2346 /* Selects a given charmap for character code to glyph index */
2350 /* face :: A handle to the source face object. */
2353 /* charmap :: A handle to the selected charmap. */
2356 /* FreeType error code. 0 means success. */
2359 /* This function will return an error if the charmap is not part of */
2360 /* the face (i.e., if it is not listed in the face->charmaps[] */
2363 FT_EXPORT( FT_Error )
2364 FT_Set_Charmap( FT_Face face,
2365 FT_CharMap charmap );
2368 /*************************************************************************/
2371 /* FT_Get_Char_Index */
2374 /* Returns the glyph index of a given character code. This function */
2375 /* uses a charmap object to do the translation. */
2378 /* face :: A handle to the source face object. */
2380 /* charcode :: The character code. */
2383 /* The glyph index. 0 means `undefined character code'. */
2385 FT_EXPORT( FT_UInt )
2386 FT_Get_Char_Index( FT_Face face,
2387 FT_ULong charcode );
2390 /*************************************************************************/
2393 /* FT_Get_Name_Index */
2396 /* Returns the glyph index of a given glyph name. This function uses */
2397 /* driver specific objects to do the translation. */
2400 /* face :: A handle to the source face object. */
2402 /* glyph_name :: The glyph name. */
2405 /* The glyph index. 0 means `undefined character code'. */
2407 FT_EXPORT( FT_UInt )
2408 FT_Get_Name_Index( FT_Face face,
2409 FT_String* glyph_name );
2413 /*************************************************************************/
2422 /* Crunching fixed numbers and vectors */
2425 /* This section contains various functions used to perform */
2426 /* computations on 16.16 fixed-float numbers or 2d vectors. */
2435 /* FT_Vector_Transform */
2436 /* FT_Matrix_Multiply */
2437 /* FT_Matrix_Invert */
2439 /*************************************************************************/
2442 /*************************************************************************/
2448 /* A very simple function used to perform the computation `(a*b)/c' */
2449 /* with maximal accuracy (it uses a 64-bit intermediate integer */
2450 /* whenever necessary). */
2452 /* This function isn't necessarily as fast as some processor specific */
2453 /* operations, but is at least completely portable. */
2456 /* a :: The first multiplier. */
2457 /* b :: The second multiplier. */
2458 /* c :: The divisor. */
2461 /* The result of `(a*b)/c'. This function never traps when trying to */
2462 /* divide by zero; it simply returns `MaxInt' or `MinInt' depending */
2463 /* on the signs of `a' and `b'. */
2465 FT_EXPORT( FT_Long )
2466 FT_MulDiv( FT_Long a,
2471 /*************************************************************************/
2477 /* A very simple function used to perform the computation */
2478 /* `(a*b)/0x10000' with maximal accuracy. Most of the time this is */
2479 /* used to multiply a given value by a 16.16 fixed float factor. */
2482 /* a :: The first multiplier. */
2483 /* b :: The second multiplier. Use a 16.16 factor here whenever */
2484 /* possible (see note below). */
2487 /* The result of `(a*b)/0x10000'. */
2490 /* This function has been optimized for the case where the absolute */
2491 /* value of `a' is less than 2048, and `b' is a 16.16 scaling factor. */
2492 /* As this happens mainly when scaling from notional units to */
2493 /* fractional pixels in FreeType, it resulted in noticeable speed */
2494 /* improvements between versions 2.x and 1.x. */
2496 /* As a conclusion, always try to place a 16.16 factor as the */
2497 /* _second_ argument of this function; this can make a great */
2500 FT_EXPORT( FT_Long )
2501 FT_MulFix( FT_Long a,
2505 /*************************************************************************/
2511 /* A very simple function used to perform the computation */
2512 /* `(a*0x10000)/b' with maximal accuracy. Most of the time, this is */
2513 /* used to divide a given value by a 16.16 fixed float factor. */
2516 /* a :: The first multiplier. */
2517 /* b :: The second multiplier. Use a 16.16 factor here whenever */
2518 /* possible (see note below). */
2521 /* The result of `(a*0x10000)/b'. */
2524 /* The optimization for FT_DivFix() is simple: If (a << 16) fits in */
2525 /* 32 bits, then the division is computed directly. Otherwise, we */
2526 /* use a specialized version of the old FT_MulDiv64(). */
2528 FT_EXPORT( FT_Long )
2529 FT_DivFix( FT_Long a,
2533 /*************************************************************************/
2539 /* A very simple function used to round a 16.16 fixed number. */
2542 /* a :: The number to be rounded. */
2545 /* The result of `(a + 0x8000) & -0x10000'. */
2547 FT_EXPORT( FT_Fixed )
2548 FT_RoundFix( FT_Fixed a );
2551 /*************************************************************************/
2557 /* A very simple function used to compute the ceiling function of a */
2558 /* 16.16 fixed number. */
2561 /* a :: The number for which the ceiling function is to be computed. */
2564 /* The result of `(a + 0x10000 - 1) & -0x10000'. */
2566 FT_EXPORT( FT_Fixed )
2567 FT_CeilFix( FT_Fixed a );
2570 /*************************************************************************/
2576 /* A very simple function used to compute the floor function of a */
2577 /* 16.16 fixed number. */
2580 /* a :: The number for which the floor function is to be computed. */
2583 /* The result of `a & -0x10000'. */
2585 FT_EXPORT( FT_Fixed )
2586 FT_FloorFix( FT_Fixed a );
2589 /*************************************************************************/
2592 /* FT_Vector_Transform */
2595 /* Transforms a single vector through a 2x2 matrix. */
2598 /* vector :: The target vector to transform. */
2601 /* matrix :: A pointer to the source 2x2 matrix. */
2604 /* The result is undefined if either `vector' or `matrix' is invalid. */
2607 FT_Vector_Transform( FT_Vector* vec,
2608 FT_Matrix* matrix );
2616 #endif /* __FREETYPE_H__ */