1 /***************************************************************************/
5 /* FreeType high-level API and common types (specification only). */
7 /* Copyright 1996-2000 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 /***************************************************************************/
23 /*************************************************************************/
25 /* The `raster' component duplicates some of the declarations in */
26 /* freetype.h for stand-alone use if _FREETYPE_ isn't defined. */
31 /*************************************************************************/
33 /* The FREETYPE_MAJOR and FREETYPE_MINOR macros are used to version the */
34 /* new FreeType design, which is able to host several kinds of font */
35 /* drivers. It starts at 2.0. */
37 #define FREETYPE_MAJOR 2
38 #define FREETYPE_MINOR 0
41 #include <freetype/config/ftconfig.h> /* read configuration information */
42 #include <freetype/fterrors.h>
43 #include <freetype/fttypes.h>
51 /*************************************************************************/
52 /*************************************************************************/
54 /* B A S I C T Y P E S */
56 /*************************************************************************/
57 /*************************************************************************/
60 /*************************************************************************/
63 /* FT_Glyph_Metrics */
66 /* A structure used to model the metrics of a single glyph. Note */
67 /* that values are expressed in 26.6 fractional pixel format or in */
68 /* font units, depending on context. */
71 /* width :: The glyph's width. */
73 /* height :: The glyph's height. */
75 /* horiBearingX :: Horizontal left side bearing. */
77 /* horiBearingY :: Horizontal top side bearing. */
79 /* horiAdvance :: Horizontal advance width. */
81 /* vertBearingX :: Vertical left side bearing. */
83 /* vertBearingY :: Vertical top side bearing. */
85 /* vertAdvance :: Vertical advance height. */
87 typedef struct FT_Glyph_Metrics_
89 FT_Pos width; /* glyph width */
90 FT_Pos height; /* glyph height */
92 FT_Pos horiBearingX; /* left side bearing in horizontal layouts */
93 FT_Pos horiBearingY; /* top side bearing in horizontal layouts */
94 FT_Pos horiAdvance; /* advance width for horizontal layout */
96 FT_Pos vertBearingX; /* left side bearing in vertical layouts */
97 FT_Pos vertBearingY; /* top side bearing in vertical layouts */
98 FT_Pos vertAdvance; /* advance height for vertical layout */
103 /*************************************************************************/
106 /* FT_Generic_Finalizer */
109 /* Describes a function used to destroy the `client' data of any */
110 /* FreeType object. See the description of the FT_Generic type for */
111 /* details of usage. */
114 /* The address of the FreeType object which is under finalization. */
115 /* Its client data is accessed through its `generic' field. */
117 typedef void (*FT_Generic_Finalizer)(void* object);
120 /*************************************************************************/
126 /* Client applications often need to associate their own data to a */
127 /* variety of FreeType core objects. For example, a text layout API */
128 /* might want to associate a glyph cache to a given size object. */
130 /* Most FreeType object contains a `generic' field, of type */
131 /* FT_Generic, which usage is left to client applications and font */
134 /* It can be used to store a pointer to client-specific data, as well */
135 /* as the address of a `finalizer' function, which will be called by */
136 /* FreeType when the object is destroyed (for example, the previous */
137 /* client example would put the address of the glyph cache destructor */
138 /* in the `finalizer' field). */
141 /* data :: A typeless pointer to any client-specified data. This */
142 /* field is completely ignored by the FreeType library. */
144 /* finalizer :: A pointer to a `generic finalizer' function, which */
145 /* will be called when the object is destroyed. If this */
146 /* field is set to NULL, no code will be called. */
148 typedef struct FT_Generic_
151 FT_Generic_Finalizer finalizer;
156 /*************************************************************************/
162 /* An extremely simple structure used to model the size of a bitmap */
163 /* strike (i.e., a bitmap instance of the font for a given */
164 /* resolution) in a fixed-size font face. This is used for the */
165 /* `available_sizes' field of the FT_Face_Properties structure. */
168 /* height :: The character height in pixels. */
170 /* width :: The character width in pixels. */
172 typedef struct FT_Bitmap_Size_
180 /*************************************************************************/
181 /*************************************************************************/
183 /* O B J E C T C L A S S E S */
185 /*************************************************************************/
186 /*************************************************************************/
188 /*************************************************************************/
194 /* A handle to a FreeType library instance. Each `library' is */
195 /* completely independent from the others; it is the `root' of a set */
196 /* of objects like fonts, faces, sizes, etc. */
198 /* It also embeds a system object (see FT_System), as well as a */
199 /* scan-line converter object (see FT_Raster). */
202 /* Library objects are created through FT_Init_FreeType(). */
204 typedef struct FT_LibraryRec_ *FT_Library;
207 /*************************************************************************/
213 /* A handle to a given FreeType module object. Each module can be a */
214 /* font driver, a renderer, or anything else that provides services */
215 /* to the formers. */
217 typedef struct FT_ModuleRec_* FT_Module;
220 /*************************************************************************/
226 /* A handle to a given FreeType font driver object. Each font driver */
227 /* is able to create faces, sizes, glyph slots, and charmaps from the */
228 /* resources whose format it supports. */
230 /* A driver can support either bitmap, graymap, or scalable font */
233 typedef struct FT_DriverRec_* FT_Driver;
236 /*************************************************************************/
242 /* A handle to a given FreeType renderer. A renderer is in charge of */
243 /* converting a glyph image to a bitmap, when necessary. Each */
244 /* supports a given glyph image format, and one or more target */
245 /* surface depths. */
247 typedef struct FT_RendererRec_* FT_Renderer;
250 /*************************************************************************/
256 /* A handle to a given driver face object. A face object contains */
257 /* all the instance and glyph independent data of a font file */
260 /* A face object is created from a resource object through the */
261 /* new_face() method of a given driver. */
263 typedef struct FT_FaceRec_* FT_Face;
266 /*************************************************************************/
272 /* A handle to a given driver size object. Such an object models the */
273 /* _resolution_ AND _size_ dependent state of a given driver face */
276 /* A size object is always created from a given face object. It is */
277 /* discarded automatically by its parent face. */
279 typedef struct FT_SizeRec_* FT_Size;
282 /*************************************************************************/
288 /* A handle to a given `glyph slot'. A slot is a container where it */
289 /* is possible to load any of the glyphs contained within its parent */
292 /* A glyph slot is created from a given face object. It is discarded */
293 /* automatically by its parent face. */
295 typedef struct FT_GlyphSlotRec_* FT_GlyphSlot;
298 /*************************************************************************/
304 /* A handle to a given character map. A charmap is used to translate */
305 /* character codes in a given encoding into glyph indexes for its */
306 /* parent's face. Some font formats may provide several charmaps per */
309 /* A charmap is created from a given face object. It is discarded */
310 /* automatically by its parent face. */
312 typedef struct FT_CharMapRec_* FT_CharMap;
315 /*************************************************************************/
321 /* An enumeration used to specify encodings supported by charmaps. */
322 /* Used in the FT_Select_CharMap() API function. */
325 /* Because of 32-bit charcodes defined in Unicode (i.e., surrogates), */
326 /* all character codes must be expressed as FT_Longs. */
328 typedef enum FT_Encoding_
330 ft_encoding_none = 0,
331 ft_encoding_symbol = FT_MAKE_TAG( 's', 'y', 'm', 'b' ),
332 ft_encoding_unicode = FT_MAKE_TAG( 'u', 'n', 'i', 'c' ),
333 ft_encoding_latin_2 = FT_MAKE_TAG( 'l', 'a', 't', '2' ),
334 ft_encoding_sjis = FT_MAKE_TAG( 's', 'j', 'i', 's' ),
335 ft_encoding_gb2312 = FT_MAKE_TAG( 'g', 'b', ' ', ' ' ),
336 ft_encoding_big5 = FT_MAKE_TAG( 'b', 'i', 'g', '5' ),
337 ft_encoding_wansung = FT_MAKE_TAG( 'w', 'a', 'n', 's' ),
338 ft_encoding_johab = FT_MAKE_TAG( 'j', 'o', 'h', 'a' ),
340 ft_encoding_adobe_standard = FT_MAKE_TAG( 'A', 'D', 'O', 'B' ),
341 ft_encoding_adobe_expert = FT_MAKE_TAG( 'A', 'D', 'B', 'E' ),
342 ft_encoding_adobe_custom = FT_MAKE_TAG( 'A', 'D', 'B', 'C' ),
344 ft_encoding_apple_roman = FT_MAKE_TAG( 'a', 'r', 'm', 'n' )
346 /* other encodings might be defined in the future */
351 /*************************************************************************/
357 /* The base charmap class. */
360 /* face :: A handle to the parent face object. */
362 /* flags :: A set of bit flags used to describe the charmap. */
363 /* Each bit indicates that a given encoding is */
366 /* platform_id :: An ID number describing the platform for the */
367 /* following encoding ID. This comes directly from */
368 /* the TrueType specification and should be emulated */
369 /* for other formats. */
371 /* encoding_id :: A platform specific encoding number. This also */
372 /* comes from the TrueType specification and should be */
373 /* emulated similarly. */
376 /* We STRONGLY recommmend emulating a Unicode charmap for drivers */
377 /* that do not support TrueType or OpenType. */
379 typedef struct FT_CharMapRec_
382 FT_Encoding encoding;
383 FT_UShort platform_id;
384 FT_UShort encoding_id;
389 /*************************************************************************/
390 /*************************************************************************/
392 /* B A S E O B J E C T C L A S S E S */
394 /*************************************************************************/
395 /*************************************************************************/
397 /*************************************************************************/
399 /* FreeType base face class */
405 /* FreeType root face class structure. A face object models the */
406 /* resolution and point-size independent data found in a font file. */
409 /* num_faces :: In the case where the face is located in a */
410 /* collection (i.e., a resource which embeds */
411 /* several faces), this is the total number of */
412 /* faces found in the resource. 1 by default. */
414 /* face_index :: The index of the face in its resource. */
415 /* Usually, this is 0 for all normal font */
416 /* formats. It can be more in the case of */
417 /* collections (which embed several fonts in a */
418 /* single resource/file). */
420 /* face_flags :: A set of bit flags that give important */
421 /* information about the face; see the */
422 /* FT_FACE_FLAG_XXX macros for details. */
424 /* style_flags :: A set of bit flags indicating the style of */
425 /* the face (i.e., italic, bold, underline, */
428 /* num_glyphs :: The total number of glyphs in the face. */
430 /* family_name :: The face's family name. This is an ASCII */
431 /* string, usually in English, which describes */
432 /* the typeface's family (like `Times New */
433 /* Roman', `Bodoni', `Garamond', etc). This */
434 /* is a least common denominator used to list */
435 /* fonts. Some formats (TrueType & OpenType) */
436 /* provide localized and Unicode versions of */
437 /* this string. Applications should use the */
438 /* format specific interface to access them. */
440 /* style_name :: The face's style name. This is an ASCII */
441 /* string, usually in English, which describes */
442 /* the typeface's style (like `Italic', */
443 /* `Bold', `Condensed', etc). Not all font */
444 /* formats provide a style name, so this field */
445 /* is optional, and can be set to NULL. As */
446 /* for `family_name', some formats provide */
447 /* localized/Unicode versions of this string. */
448 /* Applications should use the format specific */
449 /* interface to access them. */
451 /* num_fixed_sizes :: The number of fixed sizes available in this */
452 /* face. This should be set to 0 for scalable */
453 /* fonts, unless its resource includes a */
454 /* complete set of glyphs (called a `strike') */
455 /* for the specified size. */
457 /* available_sizes :: An array of sizes specifying the available */
458 /* bitmap/graymap sizes that are contained in */
459 /* in the font resource. Should be set to */
460 /* NULL if the field `num_fixed_sizes' is set */
463 /* num_charmaps :: The total number of character maps in the */
466 /* charmaps :: A table of pointers to the face's charmaps */
467 /* Used to scan the list of available charmaps */
468 /* this table might change after a call to */
469 /* FT_Attach_File/Stream (e.g. when it used */
470 /* to hook and additional encoding/CMap to */
471 /* the face object). */
473 /* generic :: A field reserved for client uses. See the */
474 /* FT_Generic type description. */
476 /* bbox :: The font bounding box. Coordinates are */
477 /* expressed in font units (see units_per_EM). */
478 /* The box is large enough to contain any */
479 /* glyph from the font. Thus, bbox.yMax can */
480 /* be seen as the `maximal ascender', */
481 /* bbox.yMin as the `minimal descender', and */
482 /* the maximal glyph width is given by */
483 /* `bbox.xMax-bbox.xMin' (not to be confused */
484 /* with the maximal _advance_width_). Only */
485 /* relevant for scalable formats. */
487 /* units_per_EM :: The number of font units per EM square for */
488 /* this face. This is typically 2048 for */
489 /* TrueType fonts, 1000 for Type1 fonts, and */
490 /* should be set to the (unrealistic) value 1 */
491 /* for fixed-sizes fonts. Only relevant for */
492 /* scalable formats. */
494 /* ascender :: The face's ascender is the vertical */
495 /* distance from the baseline to the topmost */
496 /* point of any glyph in the face. This */
497 /* field's value is positive, expressed in */
498 /* font units. Some font designs use a value */
499 /* different from `bbox.yMax'. Only relevant */
500 /* for scalable formats. */
502 /* descender :: The face's descender is the vertical */
503 /* distance from the baseline to the */
504 /* bottommost point of any glyph in the face. */
505 /* This field's value is positive, expressed */
506 /* in font units. Some font designs use a */
507 /* value different from `-bbox.yMin'. Only */
508 /* relevant for scalable formats. */
510 /* height :: The face's height is the vertical distance */
511 /* from one baseline to the next when writing */
512 /* several lines of text. Its value is always */
513 /* positive, expressed in font units. The */
514 /* value can be computed as */
515 /* `ascender+descender+line_gap' where the */
516 /* value of `line_gap' is also called */
517 /* `external leading'. Only relevant for */
518 /* scalable formats. */
520 /* max_advance_width :: The maximal advance width, in font units, */
521 /* for all glyphs in this face. This can be */
522 /* used to make word wrapping computations */
523 /* faster. Only relevant for scalable */
526 /* max_advance_height :: The maximal advance height, in font units, */
527 /* for all glyphs in this face. This is only */
528 /* relevant for vertical layouts, and should */
529 /* be set to the `height' for fonts that do */
530 /* not provide vertical metrics. Only */
531 /* relevant for scalable formats. */
533 /* underline_position :: The position, in font units, of the */
534 /* underline line for this face. It's the */
535 /* center of the underlining stem. Only */
536 /* relevant for scalable formats. */
538 /* underline_thickness :: The thickness, in font units, of the */
539 /* underline for this face. Only relevant for */
540 /* scalable formats. */
542 /* driver :: A handle to the face's parent driver */
545 /* memory :: A handle to the face's parent memory */
546 /* object. Used for the allocation of */
547 /* subsequent objects. */
549 /* stream :: A handle to the face's stream. */
551 /* glyph :: The face's associated glyph slot(s). This */
552 /* object is created automatically with a new */
553 /* face object. However, certain kinds of */
554 /* applications (mainly tools like converters) */
555 /* can need more than one slot to ease their */
558 /* sizes_list :: The list of child sizes for this face. */
560 /* max_points :: The maximal number of points used to store */
561 /* the vectorial outline of any glyph in this */
562 /* face. If this value cannot be known in */
563 /* advance, or if the face isn't scalable, */
564 /* this should be set to 0. Only relevant for */
565 /* scalable formats. */
567 /* max_contours :: The maximal number of contours used to */
568 /* store the vectorial outline of any glyph in */
569 /* this face. If this value cannot be known */
570 /* in advance, or if the face isn't scalable, */
571 /* this should be set to 0. Only relevant for */
572 /* scalable formats. */
574 /* transform_matrix :: A 2x2 matrix of 16.16 coefficients used */
575 /* to transform glyph outlines after they are */
576 /* loaded from the font. Only used by the */
577 /* convenience functions. */
579 /* transform_delta :: A translation vector used to transform */
580 /* glyph outlines after they are loaded from */
581 /* the font. Only used by the convenience */
584 /* transform_flags :: Some flags used to classify the transform. */
585 /* Only used by the convenience functions. */
587 typedef struct FT_FaceRec_
597 FT_String* family_name;
598 FT_String* style_name;
600 FT_Int num_fixed_sizes;
601 FT_Bitmap_Size* available_sizes;
603 /* the face's table of available charmaps */
605 FT_CharMap* charmaps;
609 /* the following are only relevant for scalable outlines */
612 FT_UShort units_per_EM;
617 FT_Short max_advance_width;
618 FT_Short max_advance_height;
620 FT_Short underline_position;
621 FT_Short underline_thickness;
626 /************************************************************/
627 /* The following fields should be considered private and */
628 /* rarely, if ever, used directly by client applications. */
635 FT_ListRec sizes_list;
640 FT_UShort max_points;
641 FT_Short max_contours;
643 FT_Matrix transform_matrix;
644 FT_Vector transform_delta;
645 FT_Int transform_flags;
650 /*************************************************************************/
653 /* FT_FACE_FLAG_SCALABLE */
656 /* A bit-field constant, used to indicate that a given face provides */
657 /* vectorial outlines (i.e., TrueType or Type1). This doesn't */
658 /* prevent embedding of bitmap strikes though, i.e., a given face can */
659 /* have both this bit set, and a `num_fixed_sizes' property > 0. */
661 #define FT_FACE_FLAG_SCALABLE 1
664 /*************************************************************************/
667 /* FT_FACE_FLAG_FIXED_SIZES */
670 /* A bit-field constant, used to indicate that a given face contains */
671 /* `fixed sizes', i.e., bitmap strikes for some given pixel sizes. */
672 /* See the `num_fixed_sizes' and `available_sizes' face properties */
673 /* for more information. */
675 #define FT_FACE_FLAG_FIXED_SIZES 2
678 /*************************************************************************/
681 /* FT_FACE_FLAG_FIXED_WIDTH */
684 /* A bit-field constant, used to indicate that a given face contains */
685 /* fixed-width characters (like Courier, Lucida, MonoType, etc.). */
687 #define FT_FACE_FLAG_FIXED_WIDTH 4
690 /*************************************************************************/
693 /* FT_FACE_FLAG_SFNT */
696 /* A bit-field constant, used to indicate that a given face uses the */
697 /* `sfnt' storage fomat. For now, this means TrueType or OpenType. */
699 #define FT_FACE_FLAG_SFNT 8
702 /*************************************************************************/
705 /* FT_FACE_FLAG_HORIZONTAL */
708 /* A bit-field constant, used to indicate that a given face contains */
709 /* horizontal glyph metrics. This should be set for all common */
710 /* formats, but who knows. */
712 #define FT_FACE_FLAG_HORIZONTAL 0x10
715 /*************************************************************************/
718 /* FT_FACE_FLAG_VERTICAL */
721 /* A bit-field constant, used to indicate that a given face contains */
722 /* vertical glyph metrics. If not set, the glyph loader will */
723 /* synthetize vertical metrics itself to help display vertical text */
726 #define FT_FACE_FLAG_VERTICAL 0x20
729 /*************************************************************************/
732 /* FT_FACE_FLAG_KERNING */
735 /* A bit-field constant, used to indicate that a given face contains */
736 /* kerning information. When set, this information can be retrieved */
737 /* through the function FT_Get_Kerning(). Note that when unset, this */
738 /* function will always return the kerning vector (0,0). */
740 #define FT_FACE_FLAG_KERNING 0x40
743 /*************************************************************************/
746 /* FT_FACE_FLAG_FAST_GLYPHS */
749 /* A bit-field constant, used to indicate that the glyphs in a given */
750 /* font can be retrieved very quickly, and that a glyph cache is thus */
751 /* not necessary for any of its child size objects. */
753 /* This flag should really be set for fixed-size formats like FNT, */
754 /* where each glyph bitmap is available directly in binary form */
755 /* without any kind of compression. */
757 #define FT_FACE_FLAG_FAST_GLYPHS 0x80
760 /*************************************************************************/
763 /* FT_FACE_FLAG_MULTIPLE_MASTERS */
766 /* A bit-field constant, used to indicate that the font contains */
767 /* multiple masters and is capable of interpolating between them. */
769 #define FT_FACE_FLAG_MULTIPLE_MASTERS 0x100
772 /*************************************************************************/
775 /* FT_FACE_FLAG_GLYPH_NAMES */
778 /* A bit-field constant, used to indicate that the font contains */
779 /* glyph names that can be retrieved through FT_Get_Glyph_Name(). */
781 #define FT_FACE_FLAG_GLYPH_NAMES 0x200
784 /*************************************************************************/
787 /* FT_FACE_FLAG_EXTERNAL_STREAM */
790 /* This bit field is used internally by FreeType to indicate that */
791 /* a face's stream was provided by the client application and should */
792 /* not be destroyed by FT_Done_Face(). */
794 #define FT_FACE_FLAG_EXTERNAL_STREAM 0x4000
797 #define FT_HAS_HORIZONTAL( face ) \
798 ( face->face_flags & FT_FACE_FLAG_HORIZONTAL )
799 #define FT_HAS_VERTICAL( face ) \
800 ( face->face_flags & FT_FACE_FLAG_VERTICAL )
801 #define FT_HAS_KERNING( face ) \
802 ( face->face_flags & FT_FACE_FLAG_KERNING )
803 #define FT_IS_SCALABLE( face ) \
804 ( face->face_flags & FT_FACE_FLAG_SCALABLE )
805 #define FT_IS_SFNT( face ) \
806 ( face->face_flags & FT_FACE_FLAG_SFNT )
807 #define FT_IS_FIXED_WIDTH( face ) \
808 ( face->face_flags & FT_FACE_FLAG_FIXED_WIDTH )
809 #define FT_HAS_FIXED_SIZES( face ) \
810 ( face->face_flags & FT_FACE_FLAG_FIXED_SIZES )
811 #define FT_HAS_FAST_GLYPHS( face ) \
812 ( face->face_flags & FT_FACE_FLAG_FAST_GLYPHS )
813 #define FT_HAS_GLYPH_NAMES( face ) \
814 ( face->face_flags & FT_FACE_FLAG_GLYPH_NAMES )
816 #define FT_HAS_MULTIPLE_MASTERS( face ) \
817 ( face->face_flags & FT_FACE_FLAG_MULTIPLE_MASTERS )
820 /*************************************************************************/
823 /* FT_STYLE_FLAG_ITALIC */
826 /* A bit-field constant, used to indicate that a given face is */
829 #define FT_STYLE_FLAG_ITALIC 1
832 /*************************************************************************/
835 /* FT_STYLE_FLAG_BOLD */
838 /* A bit-field constant, used to indicate that a given face is */
841 #define FT_STYLE_FLAG_BOLD 2
844 /*************************************************************************/
846 /* FreeType base size metrics */
849 /* FT_Size_Metrics */
852 /* The size metrics structure returned scaled important distances for */
853 /* a given size object. */
856 /* x_ppem :: The character width, expressed in integer pixels. */
857 /* This is the width of the EM square expressed in */
858 /* pixels, hence the term `ppem' (pixels per EM). */
860 /* y_ppem :: The character height, expressed in integer pixels. */
861 /* This is the height of the EM square expressed in */
862 /* pixels, hence the term `ppem' (pixels per EM). */
864 /* x_scale :: A simple 16.16 fixed point format coefficient used */
865 /* to scale horizontal distances expressed in font */
866 /* units to fractional (26.6) pixel coordinates. */
868 /* y_scale :: A simple 16.16 fixed point format coefficient used */
869 /* to scale vertical distances expressed in font */
870 /* units to fractional (26.6) pixel coordinates. */
872 /* x_resolution :: The horizontal device resolution for this size */
873 /* object, expressed in integer dots per inches */
874 /* (dpi). As a convention, fixed font formats set */
875 /* this value to 72. */
877 /* y_resolution :: The vertical device resolution for this size */
878 /* object, expressed in integer dots per inches */
879 /* (dpi). As a convention, fixed font formats set */
880 /* this value to 72. */
882 /* ascender :: The ascender, expressed in 26.6 fixed point */
883 /* pixels. Always positive. */
885 /* descender :: The descender, expressed in 26.6 fixed point */
886 /* pixels. Always positive. */
888 /* height :: The text height, expressed in 26.6 fixed point */
889 /* pixels. Always positive. */
891 /* max_advance :: Maximum horizontal advance, expressed in 26.6 */
892 /* fixed point pixels. Always positive. */
895 /* The values of `ascender', `descender', and `height' are only the */
896 /* scaled versions of `face->ascender', `face->descender', and */
897 /* `face->height'. */
899 /* Unfortunately, due to glyph hinting, these values might not be */
900 /* exact for certain fonts, they thus must be treated as unreliable */
901 /* with an error margin of at least one pixel! */
903 /* Indeed, the only way to get the exact pixel ascender and descender */
904 /* is to render _all_ glyphs. As this would be a definite */
905 /* performance hit, it is up to client applications to perform such */
908 typedef struct FT_Size_Metrics_
910 FT_UShort x_ppem; /* horizontal pixels per EM */
911 FT_UShort y_ppem; /* vertical pixels per EM */
913 FT_Fixed x_scale; /* two scales used to convert font units */
914 FT_Fixed y_scale; /* to 26.6 frac. pixel coordinates.. */
916 FT_Pos ascender; /* ascender in 26.6 frac. pixels */
917 FT_Pos descender; /* descender in 26.6 frac. pixels */
918 FT_Pos height; /* text height in 26.6 frac. pixels */
919 FT_Pos max_advance; /* max horizontal advance, in 26.6 pixels */
924 /*************************************************************************/
926 /* FreeType base size class */
932 /* FreeType root size class structure. A size object models the */
933 /* resolution and pointsize dependent data of a given face. */
936 /* face :: Handle to the parent face object. */
938 /* generic :: A typeless pointer, which is unused by the FreeType */
939 /* library or any of its drivers. It can be used by */
940 /* client applications to link their own data to each size */
943 /* metrics :: Metrics for this size object. This field is read-only. */
945 typedef struct FT_SizeRec_
947 FT_Face face; /* parent face object */
948 FT_Generic generic; /* generic pointer for client uses */
949 FT_Size_Metrics metrics; /* size metrics */
954 /*************************************************************************/
960 /* The subglyph structure is an internal object used to describe */
961 /* subglyphs (for example, in the case of composites). */
964 /* The subglyph implementation is not part of the high-level API, */
965 /* hence the forward structure declaration. */
967 typedef struct FT_SubGlyph_ FT_SubGlyph;
970 /*************************************************************************/
976 /* The glyph loader is an internal object used to load several glyphs */
977 /* together (for example, in the case of composites). */
980 /* The glyph loader implementation is not part of the high-level API, */
981 /* hence the forward structure declaration. */
983 typedef struct FT_GlyphLoader_ FT_GlyphLoader;
986 /*************************************************************************/
988 /* FreeType Glyph Slot base class */
991 /* FT_GlyphSlotRec */
994 /* FreeType root glyph slot class structure. A glyph slot is a */
995 /* container where individual glyphs can be loaded, be they */
996 /* vectorial or bitmap/graymaps. */
999 /* library :: A handle to the FreeType library instance */
1000 /* this slot belongs to. */
1002 /* face :: A handle to the parent face object. */
1004 /* next :: In some cases (like some font tools), several */
1005 /* glyph slots per face object can be a good */
1006 /* thing. As this is rare, the glyph slots are */
1007 /* listed through a direct, single-linked list */
1008 /* using its `next' field. */
1010 /* generic :: A typeless pointer which is unused by the */
1011 /* FreeType library or any of its drivers. It */
1012 /* can be used by client applications to link */
1013 /* their own data to each size object. */
1015 /* metrics :: The metrics of the last loaded glyph in the */
1016 /* slot. The returned values depend on the last */
1017 /* load flags (see the FT_Load_Glyph() API */
1018 /* function) and can be expressed either in 26.6 */
1019 /* fractional pixels or font units. */
1021 /* Note that even when the glyph image is */
1022 /* transformed, the metrics are not. */
1024 /* linearHoriAdvance :: For scalable formats only, this field holds */
1025 /* the linearly scaled horizontal advance width */
1026 /* for the glyph (i.e. the scaled and unhinted */
1027 /* value of the hori advance). This can be */
1028 /* important to perform correct WYSIWYG layout */
1030 /* Note that this value is expressed by default */
1031 /* in 16.16 pixels. However, when the glyph is */
1032 /* loaded with the FT_LOAD_UNSCALED_LINEAR flag, */
1033 /* this field contains simply the value of the */
1034 /* advance in original font units. */
1036 /* linearVertAdvance :: For scalable formats only, this field holds */
1037 /* the linearly scaled vertical advance height */
1038 /* for the glyph. See linearHoriAdvance for */
1041 /* advance :: This is the transformed advance width for the */
1044 /* format :: This field indicates the format of the image */
1045 /* contained in the glyph slot. Typically */
1046 /* ft_glyph_format_bitmap, */
1047 /* ft_glyph_format_outline, and */
1048 /* ft_glyph_format_composite, but others are */
1051 /* bitmap :: This field is used as a bitmap descriptor */
1052 /* when the slot format is */
1053 /* ft_glyph_format_bitmap. Note that the */
1054 /* address and content of the bitmap buffer can */
1055 /* change between calls of FT_Load_Glyph() and a */
1056 /* few other functions. */
1058 /* bitmap_left :: This is the bitmap's left bearing expressed */
1059 /* in integer pixels. Of course, this is only */
1060 /* valid if the format is */
1061 /* ft_glyph_format_bitmap. */
1063 /* bitmap_top :: This is the bitmap's top bearing expressed in */
1064 /* integer pixels. Remember that this is the */
1065 /* distance from the baseline to the top-most */
1066 /* glyph scanline, upwards y-coordinates being */
1069 /* outline :: The outline descriptor for the current glyph */
1070 /* image if its format is */
1071 /* ft_glyph_bitmap_outline. */
1073 /* num_subglyphs :: The number of subglyphs in a composite glyph. */
1074 /* This format is only valid for the composite */
1075 /* glyph format, that should normally only be */
1076 /* loaded with the FT_LOAD_NO_RECURSE flag. */
1078 /* subglyphs :: An array of subglyph descriptors for */
1079 /* composite glyphs. There are `num_subglyphs' */
1080 /* elements in there. */
1082 /* control_data :: Certain font drivers can also return the */
1083 /* control data for a given glyph image (e.g. */
1084 /* TrueType bytecode, Type 1 charstrings, etc.). */
1085 /* This field is a pointer to such data. */
1087 /* control_len :: This is the length in bytes of the control */
1090 /* other :: Really wicked formats can use this pointer to */
1091 /* present their own glyph image to client apps. */
1092 /* Note that the app will need to know about the */
1095 /* loader :: This is a private object for the glyph slot. */
1096 /* Do not touch this. */
1099 /* If FT_Load_Glyph() is called with default flags (FT_LOAD_DEFAULT), */
1100 /* the glyph image is loaded in the glyph slot in its native format */
1101 /* (e.g. a vectorial outline for TrueType and Type 1 formats). */
1103 /* This image can later be converted into a bitmap by calling */
1104 /* FT_Render_Glyph(). This function finds the current renderer for */
1105 /* the native image's format then invokes it. */
1107 /* The renderer is in charge of transforming the native image through */
1108 /* the slot's face transformation fields, then convert it into a */
1109 /* bitmap that is returned in `slot->bitmap'. */
1111 /* Note that `slot->bitmap_left' and `slot->bitmap_top' are also used */
1112 /* to specify the position of the bitmap relative to the current pen */
1113 /* position (e.g. coordinates [0,0] on the baseline). Of course, */
1114 /* `slot->format' is also changed to `ft_glyph_format_bitmap' . */
1116 typedef struct FT_GlyphSlotRec_
1124 FT_Glyph_Metrics metrics;
1125 FT_Fixed linearHoriAdvance;
1126 FT_Fixed linearVertAdvance;
1129 FT_Glyph_Format format;
1137 FT_UInt num_subglyphs;
1138 FT_SubGlyph* subglyphs;
1145 /* private fields */
1146 FT_GlyphLoader* loader;
1151 /*************************************************************************/
1152 /*************************************************************************/
1154 /* F U N C T I O N S */
1156 /*************************************************************************/
1157 /*************************************************************************/
1160 /*************************************************************************/
1163 /* FT_Init_FreeType */
1166 /* Initializes a new FreeType library object. The set of drivers */
1167 /* that are registered by this function is determined at build time. */
1170 /* library :: A handle to a new library object. */
1173 /* FreeType error code. 0 means success. */
1175 FT_EXPORT_DEF( FT_Error ) FT_Init_FreeType( FT_Library* library );
1178 /*************************************************************************/
1181 /* FT_Done_FreeType */
1184 /* Destroys a given FreeType library object and all of its childs, */
1185 /* including resources, drivers, faces, sizes, etc. */
1188 /* library :: A handle to the target library object. */
1191 /* FreeType error code. 0 means success. */
1193 FT_EXPORT_DEF( FT_Error ) FT_Done_FreeType( FT_Library library );
1196 /*************************************************************************/
1202 /* An enumeration used to list the bit flags used within */
1203 /* FT_Open_Args(). */
1206 /* ft_open_memory :: This is a memory-based stream. */
1208 /* ft_open_stream :: Copy the stream from the `stream' field. */
1210 /* ft_open_pathname :: Create a new input stream from a C pathname. */
1212 /* ft_open_driver :: Use the `driver' field. */
1214 /* ft_open_params :: Use the `num_params' & `params' field. */
1220 ft_open_pathname = 4,
1227 /*************************************************************************/
1233 /* A simple structure used to pass more or less generic parameters */
1234 /* to FT_Open_Face(). */
1237 /* tag :: A 4-byte identification tag. */
1239 /* data :: A pointer to the parameter data. */
1242 /* The id and function of parameters are driver-specific. */
1244 typedef struct FT_Parameter_
1252 /*************************************************************************/
1258 /* A structure used to indicate how to open a new font file/stream. */
1259 /* A pointer to such a structure can be used as a parameter for the */
1260 /* functions FT_Open_Face() & FT_Attach_Stream(). */
1263 /* flags :: A set of bit flags indicating how to use the */
1266 /* memory_base :: The first byte of the file in memory. */
1268 /* memory_size :: The size in bytes of the file in memory. */
1270 /* pathname :: A pointer to an 8-bit file pathname. */
1272 /* stream :: A handle to a source stream object. */
1274 /* driver :: This field is exclusively used by FT_Open_Face(); */
1275 /* it simply specifies the font driver to use to open */
1276 /* the face. If set to 0, FreeType will try to load */
1277 /* the face with each one of the drivers in its list. */
1279 /* num_params :: The number of extra parameters. */
1281 /* params :: Extra parameters passed to the font driver when */
1282 /* opening a new face. */
1285 /* `stream_type' determines which fields are used to create a new */
1288 /* If it is `ft_stream_memory', a new memory-based stream will be */
1289 /* created using the memory block specified by `memory_base' and */
1290 /* `memory_size'. */
1292 /* If it is `ft_stream_pathname', a new stream will be created with */
1293 /* the `pathname' field, calling the system-specific FT_New_Stream() */
1296 /* If is is `ft_stream_copy', then the content of `stream' will be */
1297 /* copied to a new input stream object. The object will be closed */
1298 /* and destroyed when the face is destroyed itself. Note that this */
1299 /* means that you should not close the stream before the library */
1302 typedef struct FT_Open_Args_
1304 FT_Open_Flags flags;
1305 FT_Byte* memory_base;
1306 FT_Long memory_size;
1307 FT_String* pathname;
1311 FT_Parameter* params;
1316 /*************************************************************************/
1322 /* Creates a new face object from a given resource and typeface index */
1323 /* using a pathname to the font file. */
1326 /* library :: A handle to the library resource. */
1329 /* pathname :: A path to the font file. */
1331 /* face_index :: The index of the face within the resource. The */
1332 /* first face has index 0. */
1334 /* aface :: A handle to a new face object. */
1337 /* FreeType error code. 0 means success. */
1340 /* Unlike FreeType 1.x, this function automatically creates a glyph */
1341 /* slot for the face object which can be accessed directly through */
1342 /* `face->glyph'. */
1344 /* Note that additional slots can be added to each face with the */
1345 /* FT_New_GlyphSlot() API function. Slots are linked in a single */
1346 /* list through their `next' field. */
1348 /* FT_New_Face() can be used to determine and/or check the font */
1349 /* format of a given font resource. If the `face_index' field is */
1350 /* negative, the function will _not_ return any face handle in */
1351 /* `*face'. Its return value should be 0 if the resource is */
1352 /* recognized, or non-zero if not. */
1354 FT_EXPORT_DEF( FT_Error ) FT_New_Face( FT_Library library,
1355 const char* filepathname,
1360 /*************************************************************************/
1363 /* FT_New_Memory_Face */
1366 /* Creates a new face object from a given resource and typeface index */
1367 /* using a font file already loaded into memory. */
1370 /* library :: A handle to the library resource. */
1373 /* file_base :: A pointer to the beginning of the font data. */
1375 /* file_size :: The size of the memory chunk used by the font data. */
1377 /* face_index :: The index of the face within the resource. The */
1378 /* first face has index 0. */
1380 /* face :: A handle to a new face object. */
1383 /* FreeType error code. 0 means success. */
1386 /* Unlike FreeType 1.x, this function automatically creates a glyph */
1387 /* slot for the face object which can be accessed directly through */
1388 /* `face->glyph'. */
1390 /* Note that additional slots can be added to each face with the */
1391 /* FT_New_GlyphSlot() API function. Slots are linked in a single */
1392 /* list through their `next' field. */
1394 /* FT_New_Memory_Face() can be used to determine and/or check the */
1395 /* font format of a given font resource. If the `face_index' field */
1396 /* is negative, the function will _not_ return any face handle in */
1397 /* `*face'. Its return value should be 0 if the resource is */
1398 /* recognized, or non-zero if not. */
1400 FT_EXPORT_DEF( FT_Error ) FT_New_Memory_Face( FT_Library library,
1407 /*************************************************************************/
1413 /* Opens a face object from a given resource and typeface index using */
1414 /* an `FT_Open_Args' structure. If the face object doesn't exist, it */
1415 /* will be created. */
1418 /* library :: A handle to the library resource. */
1421 /* args :: A pointer to an `FT_Open_Args' structure which must */
1422 /* be filled by the caller. */
1424 /* face_index :: The index of the face within the resource. The */
1425 /* first face has index 0. */
1427 /* aface :: A handle to a new face object. */
1430 /* FreeType error code. 0 means success. */
1433 /* Unlike FreeType 1.x, this function automatically creates a glyph */
1434 /* slot for the face object which can be accessed directly through */
1435 /* `face->glyph'. */
1437 /* Note that additional slots can be added to each face with the */
1438 /* FT_New_GlyphSlot() API function. Slots are linked in a single */
1439 /* list through their `next' field. */
1441 /* FT_Open_Face() can be used to determine and/or check the font */
1442 /* format of a given font resource. If the `face_index' field is */
1443 /* negative, the function will _not_ return any face handle in */
1444 /* `*face'. Its return value should be 0 if the resource is */
1445 /* recognized, or non-zero if not. */
1447 FT_EXPORT_DEF( FT_Error ) FT_Open_Face( FT_Library library,
1453 /*************************************************************************/
1456 /* FT_Attach_File */
1459 /* `Attaches' a given font file to an existing face. This is usually */
1460 /* to read additional information for a single face object. For */
1461 /* example, it is used to read the AFM files that come with Type 1 */
1462 /* fonts in order to add kerning data and other metrics. */
1465 /* face :: The target face object. */
1468 /* filepathname :: An 8-bit pathname naming the `metrics' file. */
1471 /* FreeType error code. 0 means success. */
1474 /* If your font file is in memory, or if you want to provide your */
1475 /* own input stream object, use FT_Attach_Stream(). */
1477 /* The meaning of the `attach' action (i.e., what really happens when */
1478 /* the new file is read) is not fixed by FreeType itself. It really */
1479 /* depends on the font format (and thus the font driver). */
1481 /* Client applications are expected to know what they are doing */
1482 /* when invoking this function. Most drivers simply do not implement */
1483 /* file attachments. */
1485 FT_EXPORT_DEF( FT_Error ) FT_Attach_File( FT_Face face,
1486 const char* filepathname );
1489 /*************************************************************************/
1492 /* FT_Attach_Stream */
1495 /* This function is similar to FT_Attach_File() with the exception */
1496 /* that it reads the attachment from an arbitrary stream. */
1499 /* face :: The target face object. */
1501 /* parameters :: A pointer to an FT_Open_Args structure used to */
1502 /* describe the input stream to FreeType. */
1504 /* FreeType error code. 0 means success. */
1507 /* The meaning of the `attach' (i.e. what really happens when the */
1508 /* new file is read) is not fixed by FreeType itself. It really */
1509 /* depends on the font format (and thus the font driver). */
1511 /* Client applications are expected to know what they are doing */
1512 /* when invoking this function. Most drivers simply do not implement */
1513 /* file attachments. */
1515 FT_EXPORT_DEF( FT_Error ) FT_Attach_Stream( FT_Face face,
1516 FT_Open_Args* parameters );
1519 /*************************************************************************/
1525 /* Discards a given face object, as well as all of its child slots */
1529 /* face :: A handle to a target face object. */
1532 /* FreeType error code. 0 means success. */
1534 FT_EXPORT_DEF( FT_Error ) FT_Done_Face( FT_Face face );
1537 /*************************************************************************/
1540 /* FT_Set_Char_Size */
1543 /* Sets the character dimensions of a given face object. The */
1544 /* `char_width' and `char_height' values are used for the width and */
1545 /* height, respectively, expressed in 26.6 fractional points. */
1547 /* If the horizontal or vertical resolution values are zero, a */
1548 /* default value of 72dpi is used. Similarly, if one of the */
1549 /* character dimensions is zero, its value is set equal to the other. */
1552 /* size :: A handle to a target size object. */
1555 /* char_width :: The character width, in 26.6 fractional points. */
1557 /* char_height :: The character height, in 26.6 fractional */
1560 /* horz_resolution :: The horizontal resolution. */
1562 /* vert_resolution :: The vertical resolution. */
1565 /* FreeType error code. 0 means success. */
1568 /* When dealing with fixed-size faces (i.e., non-scalable formats), */
1569 /* use the function FT_Set_Pixel_Sizes(). */
1571 FT_EXPORT_DEF( FT_Error ) FT_Set_Char_Size( FT_Face face,
1572 FT_F26Dot6 char_width,
1573 FT_F26Dot6 char_height,
1574 FT_UInt horz_resolution,
1575 FT_UInt vert_resolution );
1578 /*************************************************************************/
1581 /* FT_Set_Pixel_Sizes */
1584 /* Sets the character dimensions of a given face object. The width */
1585 /* and height are expressed in integer pixels. */
1587 /* If one of the character dimensions is zero, its value is set equal */
1591 /* face :: A handle to the target face object. */
1594 /* pixel_width :: The character width, in integer pixels. */
1596 /* pixel_height :: The character height, in integer pixels. */
1599 /* FreeType error code. 0 means success. */
1601 FT_EXPORT_DEF( FT_Error ) FT_Set_Pixel_Sizes( FT_Face face,
1602 FT_UInt pixel_width,
1603 FT_UInt pixel_height );
1606 /*************************************************************************/
1612 /* A function used to load a single glyph within a given glyph slot, */
1613 /* for a given size. */
1616 /* face :: A handle to the target face object where the glyph */
1617 /* will be loaded. */
1619 /* glyph_index :: The index of the glyph in the font file. */
1621 /* load_flags :: A flag indicating what to load for this glyph. The */
1622 /* FT_LOAD_XXX constants can be used to control the */
1623 /* glyph loading process (e.g., whether the outline */
1624 /* should be scaled, whether to load bitmaps or not, */
1625 /* whether to hint the outline, etc). */
1628 /* FreeType error code. 0 means success. */
1631 /* If the glyph image is not a bitmap, and if the bit flag */
1632 /* FT_LOAD_IGNORE_TRANSFORM is unset, the glyph image will be */
1633 /* transformed with the information passed to a previous call to */
1634 /* FT_Set_Transform. */
1636 /* Note that this also transforms the `face.glyph.advance' field, but */
1637 /* *not* the values in `face.glyph.metrics'. */
1639 FT_EXPORT_DEF( FT_Error ) FT_Load_Glyph( FT_Face face,
1640 FT_UInt glyph_index,
1641 FT_Int load_flags );
1644 /*************************************************************************/
1650 /* A function used to load a single glyph within a given glyph slot, */
1651 /* for a given size, according to its character code. */
1654 /* face :: A handle to a target face object where the glyph */
1655 /* will be loaded. */
1657 /* char_code :: The glyph's character code, according to the */
1658 /* current charmap used in the face. */
1660 /* load_flags :: A flag indicating what to load for this glyph. The */
1661 /* FT_LOAD_XXX constants can be used to control the */
1662 /* glyph loading process (e.g., whether the outline */
1663 /* should be scaled, whether to load bitmaps or not, */
1664 /* whether to hint the outline, etc). */
1667 /* FreeType error code. 0 means success. */
1670 /* If the face has no current charmap, or if the character code */
1671 /* is not defined in the charmap, this function will return an */
1674 /* If the glyph image is not a bitmap, and if the bit flag */
1675 /* FT_LOAD_IGNORE_TRANSFORM is unset, the glyph image will be */
1676 /* transformed with the information passed to a previous call to */
1677 /* FT_Set_Transform(). */
1679 /* Note that this also transforms the `face.glyph.advance' field, but */
1680 /* *not* the values in `face.glyph.metrics'. */
1682 FT_EXPORT_DEF( FT_Error ) FT_Load_Char( FT_Face face,
1684 FT_Int load_flags );
1687 /*************************************************************************/
1690 /* FT_LOAD_NO_SCALE */
1693 /* A bit field constant, used with FT_Load_Glyph() to indicate that */
1694 /* the vector outline being loaded should not be scaled to 26.6 */
1695 /* fractional pixels, but kept in notional units. */
1697 #define FT_LOAD_NO_SCALE 1
1700 /*************************************************************************/
1703 /* FT_LOAD_NO_HINTING */
1706 /* A bit-field constant, used with FT_Load_Glyph() to indicate that */
1707 /* the vector outline being loaded should not be fitted to the pixel */
1708 /* grid but simply scaled to 26.6 fractional pixels. */
1710 /* This flag is ignored if FT_LOAD_NO_SCALE is set. */
1712 #define FT_LOAD_NO_HINTING 2
1715 /*************************************************************************/
1718 /* FT_LOAD_RENDER */
1721 /* A bit-field constant, used with FT_Load_Glyph() to indicate that */
1722 /* the function should load the glyph and immediately convert it into */
1723 /* a bitmap, if necessary, by calling FT_Render_Glyph(). */
1725 /* Note that by default, FT_Load_Glyph() loads the glyph image in its */
1726 /* native format. */
1728 #define FT_LOAD_RENDER 4
1731 /*************************************************************************/
1734 /* FT_LOAD_NO_BITMAP */
1737 /* A bit-field constant, used with FT_Load_Glyph() to indicate that */
1738 /* the function should not load the bitmap or pixmap of a given */
1739 /* glyph. This is useful when you do not want to load the embedded */
1740 /* bitmaps of scalable formats, as the native glyph image will be */
1741 /* loaded, and can then be rendered through FT_Render_Glyph(). */
1743 #define FT_LOAD_NO_BITMAP 8
1746 /*************************************************************************/
1749 /* FT_LOAD_VERTICAL_LAYOUT */
1752 /* A bit-field constant, used with FT_Load_Glyph() to indicate that */
1753 /* the glyph image should be prepared for vertical layout. This */
1754 /* basically means that `face.glyph.advance' will correspond to the */
1755 /* vertical advance height (instead of the default horizontal */
1756 /* advance width), and that the glyph image will translated to match */
1757 /* the vertical bearings positions. */
1759 #define FT_LOAD_VERTICAL_LAYOUT 16
1762 /*************************************************************************/
1765 /* FT_LOAD_FORCE_AUTOHINT */
1768 /* A bit-field constant, used with FT_Load_Glyph() to indicate that */
1769 /* the function should try to auto-hint the glyphs, even if a driver */
1770 /* specific hinter is available. */
1772 #define FT_LOAD_FORCE_AUTOHINT 32
1775 /*************************************************************************/
1778 /* FT_LOAD_CROP_BITMAP */
1781 /* A bit-field constant, used with FT_Load_Glyph() to indicate that */
1782 /* the font driver should try to crop the bitmap (i.e. remove all */
1783 /* space around its black bits) when loading it. For now, this */
1784 /* really only works with embedded bitmaps in TrueType fonts. */
1786 #define FT_LOAD_CROP_BITMAP 64
1789 /*************************************************************************/
1792 /* FT_LOAD_PEDANTIC */
1795 /* A bit-field constant, used with FT_Load_Glyph() to indicate that */
1796 /* the glyph loader should perform a pedantic bytecode */
1797 /* interpretation. Many popular fonts come with broken glyph */
1798 /* programs. When this flag is set, loading them will return an */
1799 /* error. Otherwise, errors are ignored by the loader, sometimes */
1800 /* resulting in ugly glyphs. */
1802 #define FT_LOAD_PEDANTIC 128
1805 /*************************************************************************/
1808 /* FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH */
1811 /* A bit-field constant, used with FT_Load_Glyph() to indicate that */
1812 /* the glyph loader should ignore the global advance width defined */
1813 /* in the font. As far as we know, this is only used by the */
1814 /* X-TrueType font server, in order to deal correctly with the */
1815 /* incorrect metrics contained in DynaLab's TrueType CJK fonts. */
1817 #define FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH 512
1820 /*************************************************************************/
1823 /* FT_LOAD_NO_RECURSE */
1826 /* A bit-field constant, used with FT_Load_Glyph() to indicate that */
1827 /* the glyph loader should not load composite glyph recursively. */
1828 /* Rather, when a composite glyph is encountered, it should set */
1829 /* the values of `num_subglyphs' and `subglyphs', as well as set */
1830 /* `face->glyph.format' to ft_glyph_format_composite. */
1832 /* This is for use by the auto-hinter and possibly other tools. */
1833 /* For nearly all applications, this flags should be left unset */
1834 /* when invoking FT_Load_Glyph(). */
1836 /* Note that the flag forces the load of unscaled glyphs. */
1838 #define FT_LOAD_NO_RECURSE 1024
1841 /*************************************************************************/
1844 /* FT_LOAD_IGNORE_TRANSFORM */
1847 /* A bit-field constant, used with FT_Load_Glyph() to indicate that */
1848 /* the glyph loader should not try to transform the loaded glyph */
1851 #define FT_LOAD_IGNORE_TRANSFORM 2048
1854 /*************************************************************************/
1857 /* FT_LOAD_MONOCHROME */
1860 /* Only used with FT_LOAD_RENDER set, it indicates that the returned */
1861 /* glyph image should be 1-bit monochrome. This really tells the */
1862 /* glyph loader to use `ft_render_mode_mono' when calling */
1863 /* FT_Render_Glyph(). */
1865 #define FT_LOAD_MONOCHROME 4096
1868 /*************************************************************************/
1871 /* FT_LOAD_LINEAR_DESIGN */
1874 /* A bit-field constant, used with FT_Load_Glyph() to indicate that */
1875 /* the function should return the linearly scaled metrics expressed */
1876 /* in original font units, instead of the default 16.16 pixel values. */
1878 #define FT_LOAD_LINEAR_DESIGN 8192
1881 /*************************************************************************/
1884 /* FT_LOAD_DEFAULT */
1887 /* A bit-field constant, used with FT_Load_Glyph() to indicate that */
1888 /* the function should try to load the glyph normally, i.e., */
1889 /* embedded bitmaps are favored over outlines, vectors are always */
1890 /* scaled and grid-fitted. */
1892 #define FT_LOAD_DEFAULT 0
1895 /*************************************************************************/
1898 /* FT_Set_Transform */
1901 /* A function used to set the transformation that is applied to glyph */
1902 /* images just before they are converted to bitmaps in a glyph slot */
1903 /* when FT_Render_Glyph() is called. */
1906 /* face :: A handle to the source face object. */
1909 /* matrix :: A pointer to the transformation's 2x2 matrix. Use 0 for */
1910 /* the identity matrix. */
1911 /* delta :: A pointer to the translation vector. Use 0 for the null */
1915 /* The transformation is only applied to scalable image formats after */
1916 /* the glyph has been loaded. It means that hinting is unaltered by */
1917 /* the transformation and is performed on the character size given in */
1918 /* the last call to FT_Set_Char_Sizes() or FT_Set_Pixel_Sizes(). */
1920 FT_EXPORT_DEF( void ) FT_Set_Transform( FT_Face face,
1925 /*************************************************************************/
1928 /* FT_Render_Mode */
1931 /* An enumeration type that lists the render modes supported by the */
1932 /* FreeType 2 renderer(s). A renderer is in charge of converting a */
1933 /* glyph image into a bitmap. */
1936 /* ft_render_mode_normal :: This is the default render mode; it */
1937 /* corresponds to 8-bit anti-aliased */
1938 /* bitmaps, using 256 levels of gray. */
1940 /* ft_render_mode_mono :: This render mode is used to produce 1-bit */
1941 /* monochrome bitmaps. */
1944 /* There is no render mode to produce 8-bit `monochrome' bitmaps -- */
1945 /* you have to make the conversion yourself if you need such things */
1946 /* (besides, FreeType is not a graphics library). */
1948 /* More modes might appear later for specific display modes (e.g. TV, */
1949 /* LCDs, etc.). They will be supported through the simple addition */
1950 /* of a renderer module, with no changes to the rest of the engine. */
1952 typedef enum FT_Render_Mode_
1954 ft_render_mode_normal = 0,
1955 ft_render_mode_mono = 1
1960 /*************************************************************************/
1963 /* FT_Render_Glyph */
1966 /* Converts a given glyph image to a bitmap. It does so by */
1967 /* inspecting the glyph image format, find the relevant renderer, and */
1971 /* slot :: A handle to the glyph slot containing the image to */
1974 /* render_mode :: This is the render mode used to render the glyph */
1975 /* image into a bitmap. See FT_Render_Mode for a list */
1976 /* of possible values. */
1979 /* FreeType error code. 0 means success. */
1981 FT_EXPORT_DEF( FT_Error ) FT_Render_Glyph( FT_GlyphSlot slot,
1982 FT_UInt render_mode );
1985 /*************************************************************************/
1988 /* FT_Kerning_Mode */
1991 /* An enumeration used to specify which kerning values to return in */
1992 /* FT_Get_Kerning(). */
1995 /* ft_kerning_default :: Return scaled and grid-fitted kerning */
1996 /* distances (value is 0). */
1998 /* ft_kerning_unfitted :: Return scaled but un-grid-fitted kerning */
2001 /* ft_kerning_unscaled :: Return the kerning vector in original font */
2004 typedef enum FT_Kerning_Mode_
2006 ft_kerning_default = 0,
2007 ft_kerning_unfitted,
2013 /*************************************************************************/
2016 /* FT_Get_Kerning */
2019 /* Returns the kerning vector between two glyphs of a same face. */
2022 /* face :: A handle to a source face object. */
2024 /* left_glyph :: The index of the left glyph in the kern pair. */
2026 /* right_glyph :: The index of the right glyph in the kern pair. */
2028 /* kern_mode :: See FT_Kerning_Mode() for more information. */
2029 /* Determines the scale/dimension of the returned */
2030 /* kerning vector. */
2033 /* kerning :: The kerning vector. This is in font units for */
2034 /* scalable formats, and in pixels for fixed-sizes */
2038 /* FreeType error code. 0 means success. */
2041 /* Only horizontal layouts (left-to-right & right-to-left) are */
2042 /* supported by this method. Other layouts, or more sophisticated */
2043 /* kernings, are out of the scope of this API function -- they can be */
2044 /* implemented through format-specific interfaces. */
2046 FT_EXPORT_DEF( FT_Error ) FT_Get_Kerning( FT_Face face,
2048 FT_UInt right_glyph,
2050 FT_Vector* kerning );
2053 /*************************************************************************/
2056 /* FT_Get_Glyph_Name */
2059 /* Retrieves the ASCII name of a given glyph in a face. This only */
2060 /* works for those faces where FT_HAS_GLYPH_NAME(face) returns true. */
2063 /* face :: A handle to a source face object. */
2065 /* glyph_index :: The glyph index. */
2067 /* buffer :: A pointer to a target buffer where the name will be */
2070 /* buffer_max :: The maximal number of bytes available in the */
2074 /* FreeType error code. 0 means success. */
2077 /* An error is returned if the face doesn't provide glyph names or if */
2078 /* the glyph index is invalid. In all cases of failure, the first */
2079 /* byte of `buffer' will be set to 0 to indicate an empty name. */
2081 /* The glyph name is truncated to fit within the buffer if it is too */
2082 /* long. The returned string is always zero-terminated. */
2084 /* This function is not compiled within the library if the config */
2085 /* macro FT_CONFIG_OPTION_NO_GLYPH_NAMES is defined in */
2086 /* `include/freetype/config/ftoptions.h' */
2088 FT_EXPORT_DEF( FT_Error ) FT_Get_Glyph_Name( FT_Face face,
2089 FT_UInt glyph_index,
2091 FT_UInt buffer_max );
2094 /*************************************************************************/
2097 /* FT_Select_Charmap */
2100 /* Selects a given charmap by its encoding tag (as listed in */
2101 /* `freetype.h'). */
2104 /* face :: A handle to the source face object. */
2106 /* encoding :: A handle to the selected charmap. */
2109 /* FreeType error code. 0 means success. */
2112 /* This function will return an error if no charmap in the face */
2113 /* corresponds to the encoding queried here. */
2115 FT_EXPORT_DEF( FT_Error ) FT_Select_Charmap( FT_Face face,
2116 FT_Encoding encoding );
2119 /*************************************************************************/
2122 /* FT_Set_Charmap */
2125 /* Selects a given charmap for character code to glyph index */
2129 /* face :: A handle to the source face object. */
2130 /* charmap :: A handle to the selected charmap. */
2133 /* FreeType error code. 0 means success. */
2136 /* This function will return an error if the charmap is not part of */
2137 /* the face (i.e., if it is not listed in the face->charmaps[] */
2140 FT_EXPORT_DEF( FT_Error ) FT_Set_Charmap( FT_Face face,
2141 FT_CharMap charmap );
2144 /*************************************************************************/
2147 /* FT_Get_Char_Index */
2150 /* Returns the glyph index of a given character code. This function */
2151 /* uses a charmap object to do the translation. */
2154 /* face :: A handle to the source face object. */
2156 /* charcode :: The character code. */
2159 /* The glyph index. 0 means `undefined character code'. */
2161 FT_EXPORT_DEF( FT_UInt ) FT_Get_Char_Index( FT_Face face,
2162 FT_ULong charcode );
2165 /*************************************************************************/
2171 /* A very simple function used to perform the computation `(a*b)/c' */
2172 /* with maximal accuracy (it uses a 64-bit intermediate integer */
2173 /* whenever necessary). */
2175 /* This function isn't necessarily as fast as some processor specific */
2176 /* operations, but is at least completely portable. */
2179 /* a :: The first multiplier. */
2180 /* b :: The second multiplier. */
2181 /* c :: The divisor. */
2184 /* The result of `(a*b)/c'. This function never traps when trying to */
2185 /* divide by zero; it simply returns `MaxInt' or `MinInt' depending */
2186 /* on the signs of `a' and `b'. */
2188 FT_EXPORT_DEF( FT_Long ) FT_MulDiv( FT_Long a,
2193 /*************************************************************************/
2199 /* A very simple function used to perform the computation */
2200 /* `(a*b)/0x10000' with maximal accuracy. Most of the time this is */
2201 /* used to multiply a given value by a 16.16 fixed float factor. */
2204 /* a :: The first multiplier. */
2205 /* b :: The second multiplier. Use a 16.16 factor here whenever */
2206 /* possible (see note below). */
2209 /* The result of `(a*b)/0x10000'. */
2212 /* This function has been optimized for the case where the absolute */
2213 /* value of `a' is less than 2048, and `b' is a 16.16 scaling factor. */
2214 /* As this happens mainly when scaling from notional units to */
2215 /* fractional pixels in FreeType, it resulted in noticeable speed */
2216 /* improvements between versions 2.x and 1.x. */
2218 /* As a conclusion, always try to place a 16.16 factor as the */
2219 /* _second_ argument of this function; this can make a great */
2222 FT_EXPORT_DEF( FT_Long ) FT_MulFix( FT_Long a,
2226 /*************************************************************************/
2232 /* A very simple function used to perform the computation */
2233 /* `(a*0x10000)/b' with maximal accuracy. Most of the time, this is */
2234 /* used to divide a given value by a 16.16 fixed float factor. */
2237 /* a :: The first multiplier. */
2238 /* b :: The second multiplier. Use a 16.16 factor here whenever */
2239 /* possible (see note below). */
2242 /* The result of `(a*0x10000)/b'. */
2245 /* The optimization for FT_DivFix() is simple: If (a << 16) fits in */
2246 /* 32 bits, then the division is computed directly. Otherwise, we */
2247 /* use a specialized version of the old FT_MulDiv64(). */
2249 FT_EXPORT_DEF( FT_Long ) FT_DivFix( FT_Long a,
2253 /*************************************************************************/
2256 /* FT_Vector_Transform */
2259 /* Transforms a single vector through a 2x2 matrix. */
2262 /* vector :: The target vector to transform. */
2265 /* matrix :: A pointer to the source 2x2 matrix. */
2271 /* The result is undefined if either `vector' or `matrix' is invalid. */
2273 FT_EXPORT_DEF( void ) FT_Vector_Transform( FT_Vector* vec,
2274 FT_Matrix* matrix );
2283 #endif /* FREETYPE_H */