Bringing apdf from vendor into main branch.
[AROS-Contrib.git] / apdf / freetype2 / include / freetype / freetype.h
blob0102a372f1b39d586365de6682a33ae1e72bb9a5
1 /***************************************************************************/
2 /* */
3 /* freetype.h */
4 /* */
5 /* FreeType high-level API and common types (specification only). */
6 /* */
7 /* Copyright 1996-2001, 2002 by */
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
9 /* */
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. */
15 /* */
16 /***************************************************************************/
19 #ifndef __FREETYPE_H__
20 #define __FREETYPE_H__
23 /*************************************************************************/
24 /* */
25 /* The `raster' component duplicates some of the declarations in */
26 /* freetype.h for stand-alone use if _FREETYPE_ isn't defined. */
27 /* */
30 /*************************************************************************/
31 /* */
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. */
35 /* */
36 #define FREETYPE_MAJOR 2
37 #define FREETYPE_MINOR 1
38 #define FREETYPE_PATCH 0
41 #include <ft2build.h>
42 #include FT_CONFIG_CONFIG_H
43 #include FT_ERRORS_H
44 #include FT_TYPES_H
47 FT_BEGIN_HEADER
50 /*************************************************************************/
51 /*************************************************************************/
52 /* */
53 /* B A S I C T Y P E S */
54 /* */
55 /*************************************************************************/
56 /*************************************************************************/
59 /*************************************************************************/
60 /* */
61 /* <Section> */
62 /* base_interface */
63 /* */
64 /* <Title> */
65 /* Base Interface */
66 /* */
67 /* <Abstract> */
68 /* The FreeType 2 base font interface. */
69 /* */
70 /* <Description> */
71 /* This section describes the public high-level API of FreeType 2. */
72 /* */
73 /* <Order> */
74 /* FT_Library */
75 /* FT_Face */
76 /* FT_Size */
77 /* FT_GlyphSlot */
78 /* FT_CharMap */
79 /* FT_Encoding */
80 /* */
81 /* FT_FaceRec */
82 /* */
83 /* FT_FACE_FLAG_SCALABLE */
84 /* FT_FACE_FLAG_FIXED_SIZES */
85 /* FT_FACE_FLAG_FIXED_WIDTH */
86 /* FT_FACE_FLAG_HORIZONTAL */
87 /* FT_FACE_FLAG_VERTICAL */
88 /* FT_FACE_FLAG_SFNT */
89 /* FT_FACE_FLAG_KERNING */
90 /* FT_FACE_FLAG_MULTIPLE_MASTERS */
91 /* FT_FACE_FLAG_GLYPH_NAMES */
92 /* FT_FACE_FLAG_EXTERNAL_STREAM */
93 /* FT_FACE_FLAG_FAST_GLYPHS */
94 /* */
95 /* FT_STYLE_FLAG_BOLD */
96 /* FT_STYLE_FLAG_ITALIC */
97 /* */
98 /* FT_SizeRec */
99 /* FT_Size_Metrics */
100 /* */
101 /* FT_GlyphSlotRec */
102 /* FT_Glyph_Metrics */
103 /* FT_SubGlyph */
104 /* */
105 /* FT_Bitmap_Size */
106 /* */
107 /* FT_Init_FreeType */
108 /* FT_Done_FreeType */
109 /* FT_Library_Version */
110 /* */
111 /* FT_New_Face */
112 /* FT_Done_Face */
113 /* FT_New_Memory_Face */
114 /* FT_Open_Face */
115 /* FT_Open_Args */
116 /* FT_Open_Flags */
117 /* FT_Parameter */
118 /* FT_Attach_File */
119 /* FT_Attach_Stream */
120 /* */
121 /* FT_Set_Char_Size */
122 /* FT_Set_Pixel_Sizes */
123 /* FT_Set_Transform */
124 /* FT_Load_Glyph */
125 /* FT_Get_Char_Index */
126 /* FT_Get_Name_Index */
127 /* FT_Load_Char */
128 /* */
129 /* FT_LOAD_DEFAULT */
130 /* FT_LOAD_RENDER */
131 /* FT_LOAD_MONOCHROME */
132 /* FT_LOAD_LINEAR_DESIGN */
133 /* FT_LOAD_NO_SCALE */
134 /* FT_LOAD_NO_HINTING */
135 /* FT_LOAD_NO_BITMAP */
136 /* FT_LOAD_CROP_BITMAP */
137 /* */
138 /* FT_LOAD_VERTICAL_LAYOUT */
139 /* FT_LOAD_IGNORE_TRANSFORM */
140 /* FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH */
141 /* FT_LOAD_FORCE_AUTOHINT */
142 /* FT_LOAD_NO_RECURSE */
143 /* FT_LOAD_PEDANTIC */
144 /* */
145 /* FT_Render_Glyph */
146 /* FT_Render_Mode */
147 /* FT_Get_Kerning */
148 /* FT_Kerning_Mode */
149 /* FT_Get_Glyph_Name */
150 /* FT_Get_Postscript_Name */
151 /* */
152 /* FT_CharMapRec */
153 /* FT_Select_Charmap */
154 /* FT_Set_Charmap */
155 /* */
156 /*************************************************************************/
159 /*************************************************************************/
160 /* */
161 /* <Struct> */
162 /* FT_Glyph_Metrics */
163 /* */
164 /* <Description> */
165 /* A structure used to model the metrics of a single glyph. Note */
166 /* that values are expressed in 26.6 fractional pixel format or in */
167 /* font units, depending on context. */
168 /* */
169 /* <Fields> */
170 /* width :: The glyph's width. */
171 /* */
172 /* height :: The glyph's height. */
173 /* */
174 /* horiBearingX :: Horizontal left side bearing. */
175 /* */
176 /* horiBearingY :: Horizontal top side bearing. */
177 /* */
178 /* horiAdvance :: Horizontal advance width. */
179 /* */
180 /* vertBearingX :: Vertical left side bearing. */
181 /* */
182 /* vertBearingY :: Vertical top side bearing. */
183 /* */
184 /* vertAdvance :: Vertical advance height. */
185 /* */
186 typedef struct FT_Glyph_Metrics_
188 FT_Pos width; /* glyph width */
189 FT_Pos height; /* glyph height */
191 FT_Pos horiBearingX; /* left side bearing in horizontal layouts */
192 FT_Pos horiBearingY; /* top side bearing in horizontal layouts */
193 FT_Pos horiAdvance; /* advance width for horizontal layout */
195 FT_Pos vertBearingX; /* left side bearing in vertical layouts */
196 FT_Pos vertBearingY; /* top side bearing in vertical layouts */
197 FT_Pos vertAdvance; /* advance height for vertical layout */
199 } FT_Glyph_Metrics;
202 /*************************************************************************/
203 /* */
204 /* <Struct> */
205 /* FT_Bitmap_Size */
206 /* */
207 /* <Description> */
208 /* An extremely simple structure used to model the size of a bitmap */
209 /* strike (i.e., a bitmap instance of the font for a given */
210 /* resolution) in a fixed-size font face. This is used for the */
211 /* `available_sizes' field of the FT_Face_Properties structure. */
212 /* */
213 /* <Fields> */
214 /* height :: The character height in pixels. */
215 /* */
216 /* width :: The character width in pixels. */
217 /* */
218 typedef struct FT_Bitmap_Size_
220 FT_Short height;
221 FT_Short width;
223 } FT_Bitmap_Size;
226 /*************************************************************************/
227 /*************************************************************************/
228 /* */
229 /* O B J E C T C L A S S E S */
230 /* */
231 /*************************************************************************/
232 /*************************************************************************/
234 /*************************************************************************/
235 /* */
236 /* <Type> */
237 /* FT_Library */
238 /* */
239 /* <Description> */
240 /* A handle to a FreeType library instance. Each `library' is */
241 /* completely independent from the others; it is the `root' of a set */
242 /* of objects like fonts, faces, sizes, etc. */
243 /* */
244 /* It also embeds a memory manager (see @FT_Memory), as well as a */
245 /* scan-line converter object (see @FT_Raster). */
246 /* */
247 /* <Note> */
248 /* Library objects are normally created by @FT_Init_FreeType, and */
249 /* destroyed with @FT_Done_FreeType */
250 /* */
251 typedef struct FT_LibraryRec_ *FT_Library;
254 /*************************************************************************/
255 /* */
256 /* <Type> */
257 /* FT_Module */
258 /* */
259 /* <Description> */
260 /* A handle to a given FreeType module object. Each module can be a */
261 /* font driver, a renderer, or anything else that provides services */
262 /* to the formers. */
263 /* */
264 typedef struct FT_ModuleRec_* FT_Module;
267 /*************************************************************************/
268 /* */
269 /* <Type> */
270 /* FT_Driver */
271 /* */
272 /* <Description> */
273 /* A handle to a given FreeType font driver object. Each font driver */
274 /* is a special module capable of creating faces from font files. */
275 /* */
276 typedef struct FT_DriverRec_* FT_Driver;
279 /*************************************************************************/
280 /* */
281 /* <Type> */
282 /* FT_Renderer */
283 /* */
284 /* <Description> */
285 /* A handle to a given FreeType renderer. A renderer is a special */
286 /* module in charge of converting a glyph image to a bitmap, when */
287 /* necessary. Each renderer supports a given glyph image format, and */
288 /* one or more target surface depths. */
289 /* */
290 typedef struct FT_RendererRec_* FT_Renderer;
293 /*************************************************************************/
294 /* */
295 /* <Type> */
296 /* FT_Face */
297 /* */
298 /* <Description> */
299 /* A handle to a given typographic face object. A face object models */
300 /* a given typeface, in a given style. */
301 /* */
302 /* <Note> */
303 /* Each face object also owns a single @FT_GlyphSlot object, as well */
304 /* as one or more @FT_Size objects. */
305 /* */
306 /* use @FT_New_Face or @FT_Open_Face to create a new face object from */
307 /* a given filepathname or a custom input stream. */
308 /* */
309 /* use @FT_Done_Face to destroy it (along with its slot and sizes) */
310 /* */
311 /* <Also> */
312 /* the @FT_FaceRec details the publicly accessible fields of a given */
313 /* face object. */
314 /* */
315 typedef struct FT_FaceRec_* FT_Face;
318 /*************************************************************************/
319 /* */
320 /* <Type> */
321 /* FT_Size */
322 /* */
323 /* <Description> */
324 /* A handle to a given size object. Such an object models the */
325 /* data that depends on the current _resolution_ and _character_ */
326 /* _size_ in a given @FT_Face. */
327 /* */
328 /* <Note> */
329 /* Each face object owns one or more sizes. There is however a */
330 /* single _active_ size for the face at any time that will be */
331 /* used by functions like @FT_Load_Glyph, @FT_Get_Kerning, etc... */
332 /* */
333 /* you can use the @FT_Activate_Size API to change the current */
334 /* active size of any given face */
335 /* */
336 /* <Also> */
337 /* the @FT_SizeRec structure details the publicly accessible fields */
338 /* of a given face object. */
339 /* */
340 typedef struct FT_SizeRec_* FT_Size;
343 /*************************************************************************/
344 /* */
345 /* <Type> */
346 /* FT_GlyphSlot */
347 /* */
348 /* <Description> */
349 /* A handle to a given `glyph slot'. A slot is a container where it */
350 /* is possible to load any one of the glyphs contained in its parent */
351 /* face. */
352 /* */
353 /* In other words, each time you call @FT_Load_Glyph or */
354 /* @FT_Load_Char, the slot's content is erased by the new glyph data, */
355 /* i.e. the glyph's metrics, its image (bitmap or outline), and */
356 /* other control information */
357 /* */
358 /* <Also> */
359 /* @FT_GlyphSlotRec details the publicly accessible glyph fields */
360 /* */
361 typedef struct FT_GlyphSlotRec_* FT_GlyphSlot;
364 /*************************************************************************/
365 /* */
366 /* <Type> */
367 /* FT_CharMap */
368 /* */
369 /* <Description> */
370 /* A handle to a given character map. A charmap is used to translate */
371 /* character codes in a given encoding into glyph indexes for its */
372 /* parent's face. Some font formats may provide several charmaps per */
373 /* font. */
374 /* */
375 /* Each face object owns zero or more charmaps, but only one of */
376 /* them can be "active" and used by @FT_Get_Char_Index or */
377 /* @FT_Load_Char */
378 /* */
379 /* The list of available charmaps in a face is available through the */
380 /* "face->num_charmaps" and "face->charmaps" fields of @FT_FaceRec */
381 /* */
382 /* the currently active charmap is available as "face->charmap". */
383 /* You should call @FT_Set_Charmap to change it */
384 /* */
385 /* <Note> */
386 /* when a new face is created (either through @FT_New_Face or */
387 /* @FT_Open_Face), the library looks for a Unicode charmap within */
388 /* the list and automatically activates it */
389 /* */
390 typedef struct FT_CharMapRec_* FT_CharMap;
393 /*************************************************************************/
394 /* */
395 /* <Macro> */
396 /* FT_ENC_TAG */
397 /* */
398 /* <Description> */
399 /* This macro converts four letter tags into an unsigned long. */
400 /* It is used to define "encoding" identifiers (see @FT_Encoding) */
401 /* */
402 /* */
403 #ifndef FT_ENC_TAG
404 #define FT_ENC_TAG( value, _x1, _x2, _x3, _x4 ) \
405 value = ( ( (unsigned long)_x1 << 24 ) | \
406 ( (unsigned long)_x2 << 16 ) | \
407 ( (unsigned long)_x3 << 8 ) | \
408 (unsigned long)_x4 )
409 #endif /* FT_ENC_TAG */
412 /*************************************************************************/
413 /* */
414 /* <Enum> */
415 /* FT_Encoding */
416 /* */
417 /* <Description> */
418 /* An enumeration used to specify encodings supported by charmaps. */
419 /* Used in the FT_Select_Charmap() API function. */
420 /* */
421 /* <Note> */
422 /* Because of 32-bit charcodes defined in Unicode (i.e., surrogates), */
423 /* all character codes must be expressed as FT_Longs. */
424 /* */
425 /* Other encodings might be defined in the future. */
426 /* */
427 typedef enum FT_Encoding_
429 FT_ENC_TAG( ft_encoding_none, 0, 0, 0, 0 ),
431 FT_ENC_TAG( ft_encoding_symbol, 's', 'y', 'm', 'b' ),
432 FT_ENC_TAG( ft_encoding_unicode, 'u', 'n', 'i', 'c' ),
433 FT_ENC_TAG( ft_encoding_latin_1, 'l', 'a', 't', '1' ),
434 FT_ENC_TAG( ft_encoding_latin_2, 'l', 'a', 't', '2' ),
435 FT_ENC_TAG( ft_encoding_sjis, 's', 'j', 'i', 's' ),
436 FT_ENC_TAG( ft_encoding_gb2312, 'g', 'b', ' ', ' ' ),
437 FT_ENC_TAG( ft_encoding_big5, 'b', 'i', 'g', '5' ),
438 FT_ENC_TAG( ft_encoding_wansung, 'w', 'a', 'n', 's' ),
439 FT_ENC_TAG( ft_encoding_johab, 'j', 'o', 'h', 'a' ),
441 FT_ENC_TAG( ft_encoding_adobe_standard, 'A', 'D', 'O', 'B' ),
442 FT_ENC_TAG( ft_encoding_adobe_expert, 'A', 'D', 'B', 'E' ),
443 FT_ENC_TAG( ft_encoding_adobe_custom, 'A', 'D', 'B', 'C' ),
445 FT_ENC_TAG( ft_encoding_apple_roman, 'a', 'r', 'm', 'n' )
447 } FT_Encoding;
450 /*************************************************************************/
451 /* */
452 /* <Struct> */
453 /* FT_CharMapRec */
454 /* */
455 /* <Description> */
456 /* The base charmap structure. */
457 /* */
458 /* <Fields> */
459 /* face :: A handle to the parent face object. */
460 /* */
461 /* encoding :: A @FT_Encoding tag identifying the charmap. Use */
462 /* this with @FT_Select_Charmap(). */
463 /* */
464 /* platform_id :: An ID number describing the platform for the */
465 /* following encoding ID. This comes directly from */
466 /* the TrueType specification and should be emulated */
467 /* for other formats. */
468 /* */
469 /* encoding_id :: A platform specific encoding number. This also */
470 /* comes from the TrueType specification and should be */
471 /* emulated similarly. */
472 /* */
473 typedef struct FT_CharMapRec_
475 FT_Face face;
476 FT_Encoding encoding;
477 FT_UShort platform_id;
478 FT_UShort encoding_id;
480 } FT_CharMapRec;
483 /*************************************************************************/
484 /*************************************************************************/
485 /* */
486 /* B A S E O B J E C T C L A S S E S */
487 /* */
488 /*************************************************************************/
489 /*************************************************************************/
492 /*************************************************************************/
493 /* */
494 /* <Type> */
495 /* FT_Face_Internal */
496 /* */
497 /* <Description> */
498 /* An opaque handle to an FT_Face_InternalRec structure, used to */
499 /* model private data of a given @FT_Face object. */
500 /* */
501 /* This structure might change between releases of FreeType 2 and are */
502 /* not generally available to client applications. */
503 /* */
504 typedef struct FT_Face_InternalRec_* FT_Face_Internal;
507 /*************************************************************************/
508 /* */
509 /* FreeType base face object */
510 /* */
511 /* <Struct> */
512 /* FT_FaceRec */
513 /* */
514 /* <Description> */
515 /* FreeType root face class structure. A face object models the */
516 /* resolution and point-size independent data found in a font file. */
517 /* */
518 /* <Fields> */
519 /* num_faces :: In the case where the face is located in a */
520 /* collection (i.e., a file which embed */
521 /* several faces), this is the total number of */
522 /* faces found in the resource. 1 by default. */
523 /* */
524 /* face_index :: The index of the face in its font file. */
525 /* Usually, this is 0 for all normal font */
526 /* formats. It can be more in the case of */
527 /* collections (which embed several fonts in a */
528 /* single resource/file). */
529 /* */
530 /* face_flags :: A set of bit flags that give important */
531 /* information about the face; see the */
532 /* FT_FACE_FLAG_XXX constants for details. */
533 /* */
534 /* style_flags :: A set of bit flags indicating the style of */
535 /* the face (i.e., italic, bold, underline, */
536 /* etc). */
537 /* */
538 /* num_glyphs :: The total number of glyphs in the face. */
539 /* */
540 /* family_name :: The face's family name. This is an ASCII */
541 /* string, usually in English, which describes */
542 /* the typeface's family (like `Times New */
543 /* Roman', `Bodoni', `Garamond', etc). This */
544 /* is a least common denominator used to list */
545 /* fonts. Some formats (TrueType & OpenType) */
546 /* provide localized and Unicode versions of */
547 /* this string. Applications should use the */
548 /* format specific interface to access them. */
549 /* */
550 /* style_name :: The face's style name. This is an ASCII */
551 /* string, usually in English, which describes */
552 /* the typeface's style (like `Italic', */
553 /* `Bold', `Condensed', etc). Not all font */
554 /* formats provide a style name, so this field */
555 /* is optional, and can be set to NULL. As */
556 /* for `family_name', some formats provide */
557 /* localized/Unicode versions of this string. */
558 /* Applications should use the format specific */
559 /* interface to access them. */
560 /* */
561 /* num_fixed_sizes :: The number of fixed sizes available in this */
562 /* face. This should be set to 0 for scalable */
563 /* fonts, unless its face includes a complete */
564 /* set of glyphs (called a `strike') for the */
565 /* specified sizes. */
566 /* */
567 /* available_sizes :: An array of sizes specifying the available */
568 /* bitmap/graymap sizes that are contained in */
569 /* in the font face. Should be set to NULL if */
570 /* the field `num_fixed_sizes' is set to 0. */
571 /* */
572 /* num_charmaps :: The total number of character maps in the */
573 /* face. */
574 /* */
575 /* charmaps :: A table of pointers to the face's charmaps. */
576 /* Used to scan the list of available charmaps */
577 /* -- this table might change after a call to */
578 /* @FT_Attach_File or @FT_Attach_Stream (e.g. */
579 /* when used to hook an additional encoding or */
580 /* CMap to the face object). */
581 /* */
582 /* generic :: A field reserved for client uses. See the */
583 /* @FT_Generic type description. */
584 /* */
585 /* bbox :: The font bounding box. Coordinates are */
586 /* expressed in font units (see units_per_EM). */
587 /* The box is large enough to contain any */
588 /* glyph from the font. Thus, bbox.yMax can */
589 /* be seen as the `maximal ascender', */
590 /* bbox.yMin as the `minimal descender', and */
591 /* the maximal glyph width is given by */
592 /* `bbox.xMax-bbox.xMin' (not to be confused */
593 /* with the maximal _advance_width_). Only */
594 /* relevant for scalable formats. */
595 /* */
596 /* units_per_EM :: The number of font units per EM square for */
597 /* this face. This is typically 2048 for */
598 /* TrueType fonts, 1000 for Type1 fonts, and */
599 /* should be set to the (unrealistic) value 1 */
600 /* for fixed-sizes fonts. Only relevant for */
601 /* scalable formats. */
602 /* */
603 /* ascender :: The face's ascender is the vertical */
604 /* distance from the baseline to the topmost */
605 /* point of any glyph in the face. This */
606 /* field's value is positive, expressed in */
607 /* font units. Some font designs use a value */
608 /* different from `bbox.yMax'. Only relevant */
609 /* for scalable formats. */
610 /* */
611 /* descender :: The face's descender is the vertical */
612 /* distance from the baseline to the */
613 /* bottommost point of any glyph in the face. */
614 /* This field's value is positive, expressed */
615 /* in font units. Some font designs use a */
616 /* value different from `-bbox.yMin'. Only */
617 /* relevant for scalable formats. */
618 /* */
619 /* height :: The face's height is the vertical distance */
620 /* from one baseline to the next when writing */
621 /* several lines of text. Its value is always */
622 /* positive, expressed in font units. The */
623 /* value can be computed as */
624 /* `ascender+descender+line_gap' where the */
625 /* value of `line_gap' is also called */
626 /* `external leading'. Only relevant for */
627 /* scalable formats. */
628 /* */
629 /* max_advance_width :: The maximal advance width, in font units, */
630 /* for all glyphs in this face. This can be */
631 /* used to make word wrapping computations */
632 /* faster. Only relevant for scalable */
633 /* formats. */
634 /* */
635 /* max_advance_height :: The maximal advance height, in font units, */
636 /* for all glyphs in this face. This is only */
637 /* relevant for vertical layouts, and should */
638 /* be set to the `height' for fonts that do */
639 /* not provide vertical metrics. Only */
640 /* relevant for scalable formats. */
641 /* */
642 /* underline_position :: The position, in font units, of the */
643 /* underline line for this face. It's the */
644 /* center of the underlining stem. Only */
645 /* relevant for scalable formats. */
646 /* */
647 /* underline_thickness :: The thickness, in font units, of the */
648 /* underline for this face. Only relevant for */
649 /* scalable formats. */
650 /* */
651 /* glyph :: The face's associated glyph slot(s). This */
652 /* object is created automatically with a new */
653 /* face object. However, certain kinds of */
654 /* applications (mainly tools like converters) */
655 /* can need more than one slot to ease their */
656 /* task. */
657 /* */
658 /* size :: the current active size for this face */
659 /* */
660 /* charmap :: the current active charmap for this face */
661 /* */
662 typedef struct FT_FaceRec_
664 FT_Long num_faces;
665 FT_Long face_index;
667 FT_Long face_flags;
668 FT_Long style_flags;
670 FT_Long num_glyphs;
672 FT_String* family_name;
673 FT_String* style_name;
675 FT_Int num_fixed_sizes;
676 FT_Bitmap_Size* available_sizes;
678 FT_Int num_charmaps;
679 FT_CharMap* charmaps;
681 FT_Generic generic;
683 /*# the following are only relevant to scalable outlines */
684 FT_BBox bbox;
686 FT_UShort units_per_EM;
687 FT_Short ascender;
688 FT_Short descender;
689 FT_Short height;
691 FT_Short max_advance_width;
692 FT_Short max_advance_height;
694 FT_Short underline_position;
695 FT_Short underline_thickness;
697 FT_GlyphSlot glyph;
698 FT_Size size;
699 FT_CharMap charmap;
701 /*@private begin */
703 FT_Driver driver;
704 FT_Memory memory;
705 FT_Stream stream;
707 FT_ListRec sizes_list;
709 FT_Generic autohint;
710 void* extensions;
712 FT_Face_Internal internal;
714 /*@private end */
716 } FT_FaceRec;
719 /*************************************************************************/
720 /* */
721 /* <Constant> */
722 /* FT_FACE_FLAG_SCALABLE */
723 /* */
724 /* <Description> */
725 /* A bit-field constant, used to indicate that a given face provides */
726 /* vectorial outlines (i.e., TrueType or Type1). This doesn't */
727 /* prevent embedding of bitmap strikes though, i.e., a given face can */
728 /* have both this bit set, and a `num_fixed_sizes' property > 0. */
729 /* */
730 #define FT_FACE_FLAG_SCALABLE 1
733 /*************************************************************************/
734 /* */
735 /* <Constant> */
736 /* FT_FACE_FLAG_FIXED_SIZES */
737 /* */
738 /* <Description> */
739 /* A bit-field constant, used to indicate that a given face contains */
740 /* `fixed sizes', i.e., bitmap strikes for some given pixel sizes. */
741 /* See the `num_fixed_sizes' and `available_sizes' face properties */
742 /* for more information. */
743 /* */
744 #define FT_FACE_FLAG_FIXED_SIZES 2
747 /*************************************************************************/
748 /* */
749 /* <Constant> */
750 /* FT_FACE_FLAG_FIXED_WIDTH */
751 /* */
752 /* <Description> */
753 /* A bit-field constant, used to indicate that a given face contains */
754 /* fixed-width characters (like Courier, Lucida, MonoType, etc.). */
755 /* */
756 #define FT_FACE_FLAG_FIXED_WIDTH 4
759 /*************************************************************************/
760 /* */
761 /* <Constant> */
762 /* FT_FACE_FLAG_SFNT */
763 /* */
764 /* <Description> */
765 /* A bit-field constant, used to indicate that a given face uses the */
766 /* `sfnt' storage fomat. For now, this means TrueType or OpenType. */
767 /* */
768 #define FT_FACE_FLAG_SFNT 8
771 /*************************************************************************/
772 /* */
773 /* <Constant> */
774 /* FT_FACE_FLAG_HORIZONTAL */
775 /* */
776 /* <Description> */
777 /* A bit-field constant, used to indicate that a given face contains */
778 /* horizontal glyph metrics. This should be set for all common */
779 /* formats, but who knows. */
780 /* */
781 #define FT_FACE_FLAG_HORIZONTAL 0x10
784 /*************************************************************************/
785 /* */
786 /* <Constant> */
787 /* FT_FACE_FLAG_VERTICAL */
788 /* */
789 /* <Description> */
790 /* A bit-field constant, used to indicate that a given face contains */
791 /* vertical glyph metrics. If not set, the glyph loader will */
792 /* synthetize vertical metrics itself to help display vertical text */
793 /* correctly. */
794 /* */
795 #define FT_FACE_FLAG_VERTICAL 0x20
798 /*************************************************************************/
799 /* */
800 /* <Constant> */
801 /* FT_FACE_FLAG_KERNING */
802 /* */
803 /* <Description> */
804 /* A bit-field constant, used to indicate that a given face contains */
805 /* kerning information. When set, this information can be retrieved */
806 /* through the function @FT_Get_Kerning(). Note that when unset, */
807 /* this function will always return the kerning vector (0,0). */
808 /* */
809 #define FT_FACE_FLAG_KERNING 0x40
812 /*************************************************************************/
813 /* */
814 /* <Constant> */
815 /* FT_FACE_FLAG_FAST_GLYPHS */
816 /* */
817 /* <Description> */
818 /* A bit-field constant, used to indicate that the glyphs in a given */
819 /* font can be retrieved very quickly, and that a glyph cache is thus */
820 /* not necessary for any of its child size objects. */
821 /* */
822 /* This flag should really be set for fixed-size formats like FNT, */
823 /* where each glyph bitmap is available directly in binary form */
824 /* without any kind of compression. */
825 /* */
826 /* <Note> */
827 /* This bit flag is deprecated, because even if the bitmaps are */
828 /* available directly in the font file, the glyph sub-system is */
829 /* very likely to be faster anyway... */
830 /* */
831 #define FT_FACE_FLAG_FAST_GLYPHS 0x80
834 /*************************************************************************/
835 /* */
836 /* <Constant> */
837 /* FT_FACE_FLAG_MULTIPLE_MASTERS */
838 /* */
839 /* <Description> */
840 /* A bit-field constant, used to indicate that the font contains */
841 /* multiple masters and is capable of interpolating between them. */
842 /* See the multiple-masters specific API for more details */
843 /* */
844 #define FT_FACE_FLAG_MULTIPLE_MASTERS 0x100
847 /*************************************************************************/
848 /* */
849 /* <Constant> */
850 /* FT_FACE_FLAG_GLYPH_NAMES */
851 /* */
852 /* <Description> */
853 /* A bit-field constant, used to indicate that the font contains */
854 /* glyph names that can be retrieved through @FT_Get_Glyph_Name(). */
855 /* */
856 #define FT_FACE_FLAG_GLYPH_NAMES 0x200
859 /*************************************************************************/
860 /* */
861 /* <Constant> */
862 /* FT_FACE_FLAG_EXTERNAL_STREAM */
863 /* */
864 /* <Description> */
865 /* This bit field is used internally by FreeType to indicate that */
866 /* a face's stream was provided by the client application and should */
867 /* not be destroyed by @FT_Done_Face(). */
868 /* */
869 #define FT_FACE_FLAG_EXTERNAL_STREAM 0x4000
872 /* */
875 /*************************************************************************/
876 /* */
877 /* @macro: FT_HAS_HORIZONTAL (face) */
878 /* */
879 /* @description: */
880 /* A macro that returns true whenever a face object contains */
881 /* horizontal metrics (this is true for all font formats though). */
882 /* */
883 /* @also: */
884 /* @FT_HAS_VERTICAL can be used to check for vertical metrics. */
885 /* */
886 #define FT_HAS_HORIZONTAL( face ) \
887 ( face->face_flags & FT_FACE_FLAG_HORIZONTAL )
890 /*************************************************************************/
891 /* */
892 /* @macro: FT_HAS_VERTICAL (face) */
893 /* */
894 /* @description: */
895 /* A macro that returns true whenever a face object contains vertical */
896 /* metrics. */
897 /* */
898 #define FT_HAS_VERTICAL( face ) \
899 ( face->face_flags & FT_FACE_FLAG_VERTICAL )
902 /*************************************************************************/
903 /* */
904 /* @macro: FT_HAS_KERNING (face) */
905 /* */
906 /* @description: */
907 /* A macro that returns true whenever a face object contains kerning */
908 /* data that can be accessed with @FT_Get_Kerning. */
909 /* */
910 #define FT_HAS_KERNING( face ) \
911 ( face->face_flags & FT_FACE_FLAG_KERNING )
914 /*************************************************************************/
915 /* */
916 /* @macro: FT_IS_SCALABLE (face) */
917 /* */
918 /* @description: */
919 /* A macro that returns true whenever a face object contains a */
920 /* scalable font face (true for TrueType, Type 1, CID, and */
921 /* OpenType/CFF font formats. */
922 /* */
923 #define FT_IS_SCALABLE( face ) \
924 ( face->face_flags & FT_FACE_FLAG_SCALABLE )
927 /*************************************************************************/
928 /* */
929 /* @macro: FT_IS_SFNT (face) */
930 /* */
931 /* @description: */
932 /* A macro that returns true whenever a face object contains a font */
933 /* whose format is based on the SFNT storage scheme. This usually */
934 /* means: TrueType fonts, OpenType fonts, as well as SFNT-based */
935 /* embedded bitmap fonts. */
936 /* */
937 /* If this macro is true, all functions defined in @FT_SFNT_NAMES_H */
938 /* and @FT_TRUETYPE_TABLES_H are available. */
939 /* */
940 #define FT_IS_SFNT( face ) \
941 ( face->face_flags & FT_FACE_FLAG_SFNT )
944 /*************************************************************************/
945 /* */
946 /* @macro: FT_IS_FIXED_WIDTH (face) */
947 /* */
948 /* @description: */
949 /* A macro that returns true whenever a face object contains a font */
950 /* face that contains fixed-width (or "monospace", "fixed-pitch", */
951 /* etc.) glyphs. */
952 /* */
953 #define FT_IS_FIXED_WIDTH( face ) \
954 ( face->face_flags & FT_FACE_FLAG_FIXED_WIDTH )
957 /*************************************************************************/
958 /* */
959 /* @macro: FT_IS_FIXED_SIZES (face) */
960 /* */
961 /* @description: */
962 /* A macro that returns true whenever a face object contains some */
963 /* embedded bitmaps. See the `fixed_sizes' field of the @FT_FaceRec */
964 /* structure. */
965 /* */
966 #define FT_HAS_FIXED_SIZES( face ) \
967 ( face->face_flags & FT_FACE_FLAG_FIXED_SIZES )
970 /* */
973 /*************************************************************************/
974 /* */
975 /* @macro: FT_HAS_FAST_GLYPHS (face) */
976 /* */
977 /* @description: */
978 /* Deprecated, indicates that the face contains so-called "fast" */
979 /* glyph bitmaps. */
980 /* */
981 #define FT_HAS_FAST_GLYPHS( face ) \
982 ( face->face_flags & FT_FACE_FLAG_FAST_GLYPHS )
985 /*************************************************************************/
986 /* */
987 /* @macro: FT_HAS_GLYPH_NAMES (face) */
988 /* */
989 /* @description: */
990 /* A macro that returns true whenever a face object contains some */
991 /* glyph names that can be accessed through @FT_Get_Glyph_Names. */
992 /* */
993 #define FT_HAS_GLYPH_NAMES( face ) \
994 ( face->face_flags & FT_FACE_FLAG_GLYPH_NAMES )
997 /*************************************************************************/
998 /* */
999 /* @macro: FT_HAS_MULTIPLE_MASTERS (face) */
1000 /* */
1001 /* @description: */
1002 /* A macro that returns true whenever a face object contains some */
1003 /* multiple masters. The functions provided by */
1004 /* @FT_MULTIPLE_MASTERS_H are then available to choose the exact */
1005 /* design you want. */
1006 /* */
1007 #define FT_HAS_MULTIPLE_MASTERS( face ) \
1008 ( face->face_flags & FT_FACE_FLAG_MULTIPLE_MASTERS )
1011 /*************************************************************************/
1012 /* */
1013 /* <Constant> */
1014 /* FT_STYLE_FLAG_ITALIC */
1015 /* */
1016 /* <Description> */
1017 /* A bit-field constant, used to indicate that a given face is */
1018 /* italicized. */
1019 /* */
1020 #define FT_STYLE_FLAG_ITALIC 1
1023 /*************************************************************************/
1024 /* */
1025 /* <Constant> */
1026 /* FT_STYLE_FLAG_BOLD */
1027 /* */
1028 /* <Description> */
1029 /* A bit-field constant, used to indicate that a given face is */
1030 /* emboldened. */
1031 /* */
1032 #define FT_STYLE_FLAG_BOLD 2
1035 /*************************************************************************/
1036 /* */
1037 /* <Type> */
1038 /* FT_Size_Internal */
1039 /* */
1040 /* <Description> */
1041 /* An opaque handle to an FT_Size_InternalRec structure, used to */
1042 /* model private data of a given FT_Size object. */
1043 /* */
1044 typedef struct FT_Size_InternalRec_* FT_Size_Internal;
1047 /*************************************************************************/
1048 /* */
1049 /* FreeType base size metrics */
1050 /* */
1051 /* <Struct> */
1052 /* FT_Size_Metrics */
1053 /* */
1054 /* <Description> */
1055 /* The size metrics structure returned scaled important distances for */
1056 /* a given size object. */
1057 /* */
1058 /* <Fields> */
1059 /* x_ppem :: The character width, expressed in integer pixels. */
1060 /* This is the width of the EM square expressed in */
1061 /* pixels, hence the term `ppem' (pixels per EM). */
1062 /* */
1063 /* y_ppem :: The character height, expressed in integer pixels. */
1064 /* This is the height of the EM square expressed in */
1065 /* pixels, hence the term `ppem' (pixels per EM). */
1066 /* */
1067 /* x_scale :: A simple 16.16 fixed point format coefficient used */
1068 /* to scale horizontal distances expressed in font */
1069 /* units to fractional (26.6) pixel coordinates. */
1070 /* */
1071 /* y_scale :: A simple 16.16 fixed point format coefficient used */
1072 /* to scale vertical distances expressed in font */
1073 /* units to fractional (26.6) pixel coordinates. */
1074 /* */
1075 /* ascender :: The ascender, expressed in 26.6 fixed point */
1076 /* pixels. Always positive. */
1077 /* */
1078 /* descender :: The descender, expressed in 26.6 fixed point */
1079 /* pixels. Always positive. */
1080 /* */
1081 /* height :: The text height, expressed in 26.6 fixed point */
1082 /* pixels. Always positive. */
1083 /* */
1084 /* max_advance :: Maximum horizontal advance, expressed in 26.6 */
1085 /* fixed point pixels. Always positive. */
1086 /* */
1087 /* <Note> */
1088 /* The values of `ascender', `descender', and `height' are only the */
1089 /* scaled versions of `face->ascender', `face->descender', and */
1090 /* `face->height'. */
1091 /* */
1092 /* Unfortunately, due to glyph hinting, these values might not be */
1093 /* exact for certain fonts, they thus must be treated as unreliable */
1094 /* with an error margin of at least one pixel! */
1095 /* */
1096 /* Indeed, the only way to get the exact pixel ascender and descender */
1097 /* is to render _all_ glyphs. As this would be a definite */
1098 /* performance hit, it is up to client applications to perform such */
1099 /* computations. */
1100 /* */
1101 typedef struct FT_Size_Metrics_
1103 FT_UShort x_ppem; /* horizontal pixels per EM */
1104 FT_UShort y_ppem; /* vertical pixels per EM */
1106 FT_Fixed x_scale; /* two scales used to convert font units */
1107 FT_Fixed y_scale; /* to 26.6 frac. pixel coordinates.. */
1109 FT_Pos ascender; /* ascender in 26.6 frac. pixels */
1110 FT_Pos descender; /* descender in 26.6 frac. pixels */
1111 FT_Pos height; /* text height in 26.6 frac. pixels */
1112 FT_Pos max_advance; /* max horizontal advance, in 26.6 pixels */
1114 } FT_Size_Metrics;
1117 /*************************************************************************/
1118 /* */
1119 /* FreeType base size class */
1120 /* */
1121 /* <Struct> */
1122 /* FT_SizeRec */
1123 /* */
1124 /* <Description> */
1125 /* FreeType root size class structure. A size object models the */
1126 /* resolution and pointsize dependent data of a given face. */
1127 /* */
1128 /* <Fields> */
1129 /* face :: Handle to the parent face object. */
1130 /* */
1131 /* generic :: A typeless pointer, which is unused by the FreeType */
1132 /* library or any of its drivers. It can be used by */
1133 /* client applications to link their own data to each size */
1134 /* object. */
1135 /* */
1136 /* metrics :: Metrics for this size object. This field is read-only. */
1137 /* */
1138 typedef struct FT_SizeRec_
1140 FT_Face face; /* parent face object */
1141 FT_Generic generic; /* generic pointer for client uses */
1142 FT_Size_Metrics metrics; /* size metrics */
1143 FT_Size_Internal internal;
1145 } FT_SizeRec;
1148 /*************************************************************************/
1149 /* */
1150 /* <Struct> */
1151 /* FT_SubGlyph */
1152 /* */
1153 /* <Description> */
1154 /* The subglyph structure is an internal object used to describe */
1155 /* subglyphs (for example, in the case of composites). */
1156 /* */
1157 /* <Note> */
1158 /* The subglyph implementation is not part of the high-level API, */
1159 /* hence the forward structure declaration. */
1160 /* */
1161 typedef struct FT_SubGlyphRec_* FT_SubGlyph;
1164 /*************************************************************************/
1165 /* */
1166 /* <Type> */
1167 /* FT_Slot_Internal */
1168 /* */
1169 /* <Description> */
1170 /* An opaque handle to an FT_Slot_InternalRec structure, used to */
1171 /* model private data of a given FT_GlyphSlot object. */
1172 /* */
1173 typedef struct FT_Slot_InternalRec_* FT_Slot_Internal;
1176 /*************************************************************************/
1177 /* */
1178 /* FreeType Glyph Slot base class */
1179 /* */
1180 /* <Struct> */
1181 /* FT_GlyphSlotRec */
1182 /* */
1183 /* <Description> */
1184 /* FreeType root glyph slot class structure. A glyph slot is a */
1185 /* container where individual glyphs can be loaded, be they */
1186 /* vectorial or bitmap/graymaps. */
1187 /* */
1188 /* <Fields> */
1189 /* library :: A handle to the FreeType library instance */
1190 /* this slot belongs to. */
1191 /* */
1192 /* face :: A handle to the parent face object. */
1193 /* */
1194 /* next :: In some cases (like some font tools), several */
1195 /* glyph slots per face object can be a good */
1196 /* thing. As this is rare, the glyph slots are */
1197 /* listed through a direct, single-linked list */
1198 /* using its `next' field. */
1199 /* */
1200 /* generic :: A typeless pointer which is unused by the */
1201 /* FreeType library or any of its drivers. It */
1202 /* can be used by client applications to link */
1203 /* their own data to each glyph slot object. */
1204 /* */
1205 /* metrics :: The metrics of the last loaded glyph in the */
1206 /* slot. The returned values depend on the last */
1207 /* load flags (see the FT_Load_Glyph() API */
1208 /* function) and can be expressed either in 26.6 */
1209 /* fractional pixels or font units. */
1210 /* */
1211 /* Note that even when the glyph image is */
1212 /* transformed, the metrics are not. */
1213 /* */
1214 /* linearHoriAdvance :: For scalable formats only, this field holds */
1215 /* the linearly scaled horizontal advance width */
1216 /* for the glyph (i.e. the scaled and unhinted */
1217 /* value of the hori advance). This can be */
1218 /* important to perform correct WYSIWYG layout. */
1219 /* */
1220 /* Note that this value is expressed by default */
1221 /* in 16.16 pixels. However, when the glyph is */
1222 /* loaded with the FT_LOAD_LINEAR_DESIGN flag, */
1223 /* this field contains simply the value of the */
1224 /* advance in original font units. */
1225 /* */
1226 /* linearVertAdvance :: For scalable formats only, this field holds */
1227 /* the linearly scaled vertical advance height */
1228 /* for the glyph. See linearHoriAdvance for */
1229 /* comments. */
1230 /* */
1231 /* advance :: This is the transformed advance width for the */
1232 /* glyph. */
1233 /* */
1234 /* format :: This field indicates the format of the image */
1235 /* contained in the glyph slot. Typically */
1236 /* ft_glyph_format_bitmap, */
1237 /* ft_glyph_format_outline, and */
1238 /* ft_glyph_format_composite, but others are */
1239 /* possible. */
1240 /* */
1241 /* bitmap :: This field is used as a bitmap descriptor */
1242 /* when the slot format is */
1243 /* ft_glyph_format_bitmap. Note that the */
1244 /* address and content of the bitmap buffer can */
1245 /* change between calls of @FT_Load_Glyph() and */
1246 /* a few other functions. */
1247 /* */
1248 /* bitmap_left :: This is the bitmap's left bearing expressed */
1249 /* in integer pixels. Of course, this is only */
1250 /* valid if the format is */
1251 /* ft_glyph_format_bitmap. */
1252 /* */
1253 /* bitmap_top :: This is the bitmap's top bearing expressed in */
1254 /* integer pixels. Remember that this is the */
1255 /* distance from the baseline to the top-most */
1256 /* glyph scanline, upwards y-coordinates being */
1257 /* *positive*. */
1258 /* */
1259 /* outline :: The outline descriptor for the current glyph */
1260 /* image if its format is */
1261 /* ft_glyph_bitmap_outline. */
1262 /* */
1263 /* num_subglyphs :: The number of subglyphs in a composite glyph. */
1264 /* This format is only valid for the composite */
1265 /* glyph format, that should normally only be */
1266 /* loaded with the FT_LOAD_NO_RECURSE flag. */
1267 /* */
1268 /* subglyphs :: An array of subglyph descriptors for */
1269 /* composite glyphs. There are `num_subglyphs' */
1270 /* elements in there. */
1271 /* */
1272 /* control_data :: Certain font drivers can also return the */
1273 /* control data for a given glyph image (e.g. */
1274 /* TrueType bytecode, Type 1 charstrings, etc.). */
1275 /* This field is a pointer to such data. */
1276 /* */
1277 /* control_len :: This is the length in bytes of the control */
1278 /* data. */
1279 /* */
1280 /* other :: Really wicked formats can use this pointer to */
1281 /* present their own glyph image to client apps. */
1282 /* Note that the app will need to know about the */
1283 /* image format. */
1284 /* */
1285 /* <Note> */
1286 /* If @FT_Load_Glyph() is called with default flags (see */
1287 /* @FT_LOAD_DEFAULT ) the glyph image is loaded in the glyph slot in */
1288 /* its native format (e.g. a vectorial outline for TrueType and */
1289 /* Type 1 formats). */
1290 /* */
1291 /* This image can later be converted into a bitmap by calling */
1292 /* FT_Render_Glyph(). This function finds the current renderer for */
1293 /* the native image's format then invokes it. */
1294 /* */
1295 /* The renderer is in charge of transforming the native image through */
1296 /* the slot's face transformation fields, then convert it into a */
1297 /* bitmap that is returned in `slot->bitmap'. */
1298 /* */
1299 /* Note that `slot->bitmap_left' and `slot->bitmap_top' are also used */
1300 /* to specify the position of the bitmap relative to the current pen */
1301 /* position (e.g. coordinates [0,0] on the baseline). Of course, */
1302 /* `slot->format' is also changed to `ft_glyph_format_bitmap' . */
1303 /* */
1304 typedef struct FT_GlyphSlotRec_
1306 FT_Library library;
1307 FT_Face face;
1308 FT_GlyphSlot next;
1309 FT_UInt flags;
1310 FT_Generic generic;
1312 FT_Glyph_Metrics metrics;
1313 FT_Fixed linearHoriAdvance;
1314 FT_Fixed linearVertAdvance;
1315 FT_Vector advance;
1317 FT_Glyph_Format format;
1319 FT_Bitmap bitmap;
1320 FT_Int bitmap_left;
1321 FT_Int bitmap_top;
1323 FT_Outline outline;
1325 FT_UInt num_subglyphs;
1326 FT_SubGlyph subglyphs;
1328 void* control_data;
1329 long control_len;
1331 void* other;
1333 FT_Slot_Internal internal;
1335 } FT_GlyphSlotRec;
1338 /*************************************************************************/
1339 /*************************************************************************/
1340 /* */
1341 /* F U N C T I O N S */
1342 /* */
1343 /*************************************************************************/
1344 /*************************************************************************/
1347 /*************************************************************************/
1348 /* */
1349 /* <Function> */
1350 /* FT_Init_FreeType */
1351 /* */
1352 /* <Description> */
1353 /* Initializes a new FreeType library object. The set of modules */
1354 /* that are registered by this function is determined at build time. */
1355 /* */
1356 /* <Output> */
1357 /* alibrary :: A handle to a new library object. */
1358 /* */
1359 /* <Return> */
1360 /* FreeType error code. 0 means success. */
1361 /* */
1362 FT_EXPORT( FT_Error )
1363 FT_Init_FreeType( FT_Library *alibrary );
1366 /*************************************************************************/
1367 /* */
1368 /* <Function> */
1369 /* FT_Library_Version */
1370 /* */
1371 /* <Description> */
1372 /* Return the version of the FreeType library being used. This is */
1373 /* useful when dynamically linking to the library, since one cannot */
1374 /* use the macros FT_FREETYPE_MAJOR, FT_FREETYPE_MINOR, and */
1375 /* FT_FREETYPE_PATCH. */
1376 /* */
1377 /* <Input> */
1378 /* library :: A source library handle. */
1379 /* */
1380 /* <Output> */
1381 /* amajor :: The major version number. */
1382 /* */
1383 /* aminor :: The minor version number. */
1384 /* */
1385 /* apatch :: The patch version number. */
1386 /* */
1387 /* <Note> */
1388 /* The reason why this function takes a 'library' argument is because */
1389 /* certain programs implement library initialization in a custom way */
1390 /* that doesn't use `FT_Init_FreeType'. */
1391 /* */
1392 /* In such cases, the library version might not be available before */
1393 /* the library object has been created. */
1394 /* */
1395 FT_EXPORT( void )
1396 FT_Library_Version( FT_Library library,
1397 FT_Int *amajor,
1398 FT_Int *aminor,
1399 FT_Int *apatch );
1402 /*************************************************************************/
1403 /* */
1404 /* <Function> */
1405 /* FT_Done_FreeType */
1406 /* */
1407 /* <Description> */
1408 /* Destroys a given FreeType library object and all of its childs, */
1409 /* including resources, drivers, faces, sizes, etc. */
1410 /* */
1411 /* <Input> */
1412 /* library :: A handle to the target library object. */
1413 /* */
1414 /* <Return> */
1415 /* FreeType error code. 0 means success. */
1416 /* */
1417 FT_EXPORT( FT_Error )
1418 FT_Done_FreeType( FT_Library library );
1421 /*************************************************************************/
1422 /* */
1423 /* <Enum> */
1424 /* FT_Open_Flags */
1425 /* */
1426 /* <Description> */
1427 /* An enumeration used to list the bit flags used within the */
1428 /* `flags' field of the @FT_Open_Args structure. */
1429 /* */
1430 /* <Fields> */
1431 /* ft_open_memory :: This is a memory-based stream. */
1432 /* */
1433 /* ft_open_stream :: Copy the stream from the `stream' field. */
1434 /* */
1435 /* ft_open_pathname :: Create a new input stream from a C pathname. */
1436 /* */
1437 /* ft_open_driver :: Use the `driver' field. */
1438 /* */
1439 /* ft_open_params :: Use the `num_params' & `params' field. */
1440 /* */
1441 /* <Note> */
1442 /* The `ft_open_memory', `ft_open_stream', and `ft_open_pathname' */
1443 /* flags are mutually exclusive. */
1444 /* */
1445 typedef enum
1447 ft_open_memory = 1,
1448 ft_open_stream = 2,
1449 ft_open_pathname = 4,
1450 ft_open_driver = 8,
1451 ft_open_params = 16
1453 } FT_Open_Flags;
1456 /*************************************************************************/
1457 /* */
1458 /* <Struct> */
1459 /* FT_Parameter */
1460 /* */
1461 /* <Description> */
1462 /* A simple structure used to pass more or less generic parameters */
1463 /* to FT_Open_Face(). */
1464 /* */
1465 /* <Fields> */
1466 /* tag :: A 4-byte identification tag. */
1467 /* */
1468 /* data :: A pointer to the parameter data. */
1469 /* */
1470 /* <Note> */
1471 /* The id and function of parameters are driver-specific. */
1472 /* */
1473 typedef struct FT_Parameter_
1475 FT_ULong tag;
1476 FT_Pointer data;
1478 } FT_Parameter;
1481 /*************************************************************************/
1482 /* */
1483 /* <Struct> */
1484 /* FT_Open_Args */
1485 /* */
1486 /* <Description> */
1487 /* A structure used to indicate how to open a new font file/stream. */
1488 /* A pointer to such a structure can be used as a parameter for the */
1489 /* functions @FT_Open_Face() & @FT_Attach_Stream(). */
1490 /* */
1491 /* <Fields> */
1492 /* flags :: A set of bit flags indicating how to use the */
1493 /* structure. */
1494 /* */
1495 /* memory_base :: The first byte of the file in memory. */
1496 /* */
1497 /* memory_size :: The size in bytes of the file in memory. */
1498 /* */
1499 /* pathname :: A pointer to an 8-bit file pathname. */
1500 /* */
1501 /* stream :: A handle to a source stream object. */
1502 /* */
1503 /* driver :: This field is exclusively used by FT_Open_Face(); */
1504 /* it simply specifies the font driver to use to open */
1505 /* the face. If set to 0, FreeType will try to load */
1506 /* the face with each one of the drivers in its list. */
1507 /* */
1508 /* num_params :: The number of extra parameters. */
1509 /* */
1510 /* params :: Extra parameters passed to the font driver when */
1511 /* opening a new face. */
1512 /* */
1513 /* <Note> */
1514 /* The stream type is determined by the contents of `flags' which */
1515 /* are tested in the following order by @FT_Open_Face: */
1516 /* */
1517 /* If the `ft_open_memory' bit is set, assume that this is a */
1518 /* memory file of `memory_size' bytes,located at `memory_address'. */
1519 /* */
1520 /* Otherwise, if the `ft_open_stream' bit is set, assume that a */
1521 /* custom input stream `stream' is used. */
1522 /* */
1523 /* Otherwise, if the `ft_open_pathname' bit is set, assume that this */
1524 /* is a normal file and use `pathname' to open it. */
1525 /* */
1526 /* If the `ft_open_driver' bit is set, @FT_Open_Face() will only */
1527 /* try to open the file with the driver whose handler is in `driver'. */
1528 /* */
1529 /* If the `ft_open_params' bit is set, the parameters given by */
1530 /* `num_params' and `params' will be used. They are ignored */
1531 /* otherwise. */
1532 /* */
1533 typedef struct FT_Open_Args_
1535 FT_Open_Flags flags;
1536 const FT_Byte* memory_base;
1537 FT_Long memory_size;
1538 FT_String* pathname;
1539 FT_Stream stream;
1540 FT_Module driver;
1541 FT_Int num_params;
1542 FT_Parameter* params;
1544 } FT_Open_Args;
1547 /*************************************************************************/
1548 /* */
1549 /* <Function> */
1550 /* FT_New_Face */
1551 /* */
1552 /* <Description> */
1553 /* Creates a new face object from a given resource and typeface index */
1554 /* using a pathname to the font file. */
1555 /* */
1556 /* <InOut> */
1557 /* library :: A handle to the library resource. */
1558 /* */
1559 /* <Input> */
1560 /* pathname :: A path to the font file. */
1561 /* */
1562 /* face_index :: The index of the face within the resource. The */
1563 /* first face has index 0. */
1564 /* <Output> */
1565 /* aface :: A handle to a new face object. */
1566 /* */
1567 /* <Return> */
1568 /* FreeType error code. 0 means success. */
1569 /* */
1570 /* <Note> */
1571 /* Unlike FreeType 1.x, this function automatically creates a glyph */
1572 /* slot for the face object which can be accessed directly through */
1573 /* `face->glyph'. */
1574 /* */
1575 /* FT_New_Face() can be used to determine and/or check the font */
1576 /* format of a given font resource. If the `face_index' field is */
1577 /* negative, the function will _not_ return any face handle in */
1578 /* `aface'. Its return value should be 0 if the font format is */
1579 /* recognized, or non-zero otherwise. */
1580 /* */
1581 /* Each new face object created with this function also owns a */
1582 /* default @FT_Size object, accessible as `face->size' */
1583 /* */
1584 FT_EXPORT( FT_Error )
1585 FT_New_Face( FT_Library library,
1586 const char* filepathname,
1587 FT_Long face_index,
1588 FT_Face *aface );
1591 /*************************************************************************/
1592 /* */
1593 /* <Function> */
1594 /* FT_New_Memory_Face */
1595 /* */
1596 /* <Description> */
1597 /* Creates a new face object from a given resource and typeface index */
1598 /* using a font file already loaded into memory. */
1599 /* */
1600 /* <InOut> */
1601 /* library :: A handle to the library resource. */
1602 /* */
1603 /* <Input> */
1604 /* file_base :: A pointer to the beginning of the font data. */
1605 /* */
1606 /* file_size :: The size of the memory chunk used by the font data. */
1607 /* */
1608 /* face_index :: The index of the face within the resource. The */
1609 /* first face has index 0. */
1610 /* <Output> */
1611 /* aface :: A handle to a new face object. */
1612 /* */
1613 /* <Return> */
1614 /* FreeType error code. 0 means success. */
1615 /* */
1616 /* <Note> */
1617 /* The font data bytes are used _directly_ by the @FT_Face object. */
1618 /* This means that they are not copied, and that the client is */
1619 /* responsible for releasing/destroying them _after_ the */
1620 /* corresponding call to @FT_Done_Face . */
1621 /* */
1622 /* Unlike FreeType 1.x, this function automatically creates a glyph */
1623 /* slot for the face object which can be accessed directly through */
1624 /* `face->glyph'. */
1625 /* */
1626 /* FT_New_Memory_Face() can be used to determine and/or check the */
1627 /* font format of a given font resource. If the `face_index' field */
1628 /* is negative, the function will _not_ return any face handle in */
1629 /* `aface'. Its return value should be 0 if the font format is */
1630 /* recognized, or non-zero otherwise. */
1631 /* */
1632 FT_EXPORT( FT_Error )
1633 FT_New_Memory_Face( FT_Library library,
1634 const FT_Byte* file_base,
1635 FT_Long file_size,
1636 FT_Long face_index,
1637 FT_Face *aface );
1640 /*************************************************************************/
1641 /* */
1642 /* <Function> */
1643 /* FT_Open_Face */
1644 /* */
1645 /* <Description> */
1646 /* Opens a face object from a given resource and typeface index using */
1647 /* an `FT_Open_Args' structure. If the face object doesn't exist, it */
1648 /* will be created. */
1649 /* */
1650 /* <InOut> */
1651 /* library :: A handle to the library resource. */
1652 /* */
1653 /* <Input> */
1654 /* args :: A pointer to an `FT_Open_Args' structure which must */
1655 /* be filled by the caller. */
1656 /* */
1657 /* face_index :: The index of the face within the resource. The */
1658 /* first face has index 0. */
1659 /* <Output> */
1660 /* aface :: A handle to a new face object. */
1661 /* */
1662 /* <Return> */
1663 /* FreeType error code. 0 means success. */
1664 /* */
1665 /* <Note> */
1666 /* Unlike FreeType 1.x, this function automatically creates a glyph */
1667 /* slot for the face object which can be accessed directly through */
1668 /* `face->glyph'. */
1669 /* */
1670 /* FT_Open_Face() can be used to determine and/or check the font */
1671 /* format of a given font resource. If the `face_index' field is */
1672 /* negative, the function will _not_ return any face handle in */
1673 /* `*face'. Its return value should be 0 if the font format is */
1674 /* recognized, or non-zero otherwise. */
1675 /* */
1676 FT_EXPORT( FT_Error )
1677 FT_Open_Face( FT_Library library,
1678 FT_Open_Args* args,
1679 FT_Long face_index,
1680 FT_Face *aface );
1683 /*************************************************************************/
1684 /* */
1685 /* <Function> */
1686 /* FT_Attach_File */
1687 /* */
1688 /* <Description> */
1689 /* `Attaches' a given font file to an existing face. This is usually */
1690 /* to read additional information for a single face object. For */
1691 /* example, it is used to read the AFM files that come with Type 1 */
1692 /* fonts in order to add kerning data and other metrics. */
1693 /* */
1694 /* <InOut> */
1695 /* face :: The target face object. */
1696 /* */
1697 /* <Input> */
1698 /* filepathname :: An 8-bit pathname naming the `metrics' file. */
1699 /* */
1700 /* <Return> */
1701 /* FreeType error code. 0 means success. */
1702 /* */
1703 /* <Note> */
1704 /* If your font file is in memory, or if you want to provide your */
1705 /* own input stream object, use FT_Attach_Stream(). */
1706 /* */
1707 /* The meaning of the `attach' action (i.e., what really happens when */
1708 /* the new file is read) is not fixed by FreeType itself. It really */
1709 /* depends on the font format (and thus the font driver). */
1710 /* */
1711 /* Client applications are expected to know what they are doing */
1712 /* when invoking this function. Most drivers simply do not implement */
1713 /* file attachments. */
1714 /* */
1715 FT_EXPORT( FT_Error )
1716 FT_Attach_File( FT_Face face,
1717 const char* filepathname );
1720 /*************************************************************************/
1721 /* */
1722 /* <Function> */
1723 /* FT_Attach_Stream */
1724 /* */
1725 /* <Description> */
1726 /* This function is similar to FT_Attach_File() with the exception */
1727 /* that it reads the attachment from an arbitrary stream. */
1728 /* */
1729 /* <InOut> */
1730 /* face :: The target face object. */
1731 /* */
1732 /* <Input> */
1733 /* parameters :: A pointer to an FT_Open_Args structure used to */
1734 /* describe the input stream to FreeType. */
1735 /* <Return> */
1736 /* FreeType error code. 0 means success. */
1737 /* */
1738 /* <Note> */
1739 /* The meaning of the `attach' (i.e. what really happens when the */
1740 /* new file is read) is not fixed by FreeType itself. It really */
1741 /* depends on the font format (and thus the font driver). */
1742 /* */
1743 /* Client applications are expected to know what they are doing */
1744 /* when invoking this function. Most drivers simply do not implement */
1745 /* file attachments. */
1746 /* */
1747 FT_EXPORT( FT_Error )
1748 FT_Attach_Stream( FT_Face face,
1749 FT_Open_Args* parameters );
1752 /*************************************************************************/
1753 /* */
1754 /* <Function> */
1755 /* FT_Done_Face */
1756 /* */
1757 /* <Description> */
1758 /* Discards a given face object, as well as all of its child slots */
1759 /* and sizes. */
1760 /* */
1761 /* <Input> */
1762 /* face :: A handle to a target face object. */
1763 /* */
1764 /* <Return> */
1765 /* FreeType error code. 0 means success. */
1766 /* */
1767 FT_EXPORT( FT_Error )
1768 FT_Done_Face( FT_Face face );
1771 /*************************************************************************/
1772 /* */
1773 /* <Function> */
1774 /* FT_Set_Char_Size */
1775 /* */
1776 /* <Description> */
1777 /* Sets the character dimensions of a given face object. The */
1778 /* `char_width' and `char_height' values are used for the width and */
1779 /* height, respectively, expressed in 26.6 fractional points. */
1780 /* */
1781 /* If the horizontal or vertical resolution values are zero, a */
1782 /* default value of 72dpi is used. Similarly, if one of the */
1783 /* character dimensions is zero, its value is set equal to the other. */
1784 /* */
1785 /* <InOut> */
1786 /* size :: A handle to a target size object. */
1787 /* */
1788 /* <Input> */
1789 /* char_width :: The character width, in 26.6 fractional points. */
1790 /* */
1791 /* char_height :: The character height, in 26.6 fractional */
1792 /* points. */
1793 /* */
1794 /* horz_resolution :: The horizontal resolution. */
1795 /* */
1796 /* vert_resolution :: The vertical resolution. */
1797 /* */
1798 /* <Return> */
1799 /* FreeType error code. 0 means success. */
1800 /* */
1801 /* <Note> */
1802 /* When dealing with fixed-size faces (i.e., non-scalable formats), */
1803 /* use the function FT_Set_Pixel_Sizes(). */
1804 /* */
1805 FT_EXPORT( FT_Error )
1806 FT_Set_Char_Size( FT_Face face,
1807 FT_F26Dot6 char_width,
1808 FT_F26Dot6 char_height,
1809 FT_UInt horz_resolution,
1810 FT_UInt vert_resolution );
1813 /*************************************************************************/
1814 /* */
1815 /* <Function> */
1816 /* FT_Set_Pixel_Sizes */
1817 /* */
1818 /* <Description> */
1819 /* Sets the character dimensions of a given face object. The width */
1820 /* and height are expressed in integer pixels. */
1821 /* */
1822 /* If one of the character dimensions is zero, its value is set equal */
1823 /* to the other. */
1824 /* */
1825 /* <InOut> */
1826 /* face :: A handle to the target face object. */
1827 /* */
1828 /* <Input> */
1829 /* pixel_width :: The character width, in integer pixels. */
1830 /* */
1831 /* pixel_height :: The character height, in integer pixels. */
1832 /* */
1833 /* <Return> */
1834 /* FreeType error code. 0 means success. */
1835 /* */
1836 /* */
1837 /* <Note> */
1838 /* The values of `pixel_width' and `pixel_height' correspond to the */
1839 /* pixel values of the _typographic_ character size, which are NOT */
1840 /* necessarily the same as the dimensions of the glyph `bitmap */
1841 /* cells'. */
1842 /* */
1843 /* The `character size' is really the size of an abstract square */
1844 /* called the `EM', used to design the font. However, depending */
1845 /* on the font design, glyphs will be smaller or greater than the */
1846 /* EM. */
1847 /* */
1848 /* This means that setting the pixel size to, say, 8x8 doesn't */
1849 /* guarantee in any way that you will get glyph bitmaps that all fit */
1850 /* within an 8x8 cell (sometimes even far from it). */
1851 /* */
1852 FT_EXPORT( FT_Error )
1853 FT_Set_Pixel_Sizes( FT_Face face,
1854 FT_UInt pixel_width,
1855 FT_UInt pixel_height );
1858 /*************************************************************************/
1859 /* */
1860 /* <Function> */
1861 /* FT_Load_Glyph */
1862 /* */
1863 /* <Description> */
1864 /* A function used to load a single glyph within a given glyph slot, */
1865 /* for a given size. */
1866 /* */
1867 /* <InOut> */
1868 /* face :: A handle to the target face object where the glyph */
1869 /* will be loaded. */
1870 /* */
1871 /* <Input> */
1872 /* glyph_index :: The index of the glyph in the font file. */
1873 /* */
1874 /* load_flags :: A flag indicating what to load for this glyph. The */
1875 /* FT_LOAD_XXX constants can be used to control the */
1876 /* glyph loading process (e.g., whether the outline */
1877 /* should be scaled, whether to load bitmaps or not, */
1878 /* whether to hint the outline, etc). */
1879 /* */
1880 /* <Return> */
1881 /* FreeType error code. 0 means success. */
1882 /* */
1883 /* <Note> */
1884 /* If the glyph image is not a bitmap, and if the bit flag */
1885 /* FT_LOAD_IGNORE_TRANSFORM is unset, the glyph image will be */
1886 /* transformed with the information passed to a previous call to */
1887 /* FT_Set_Transform(). */
1888 /* */
1889 /* Note that this also transforms the `face.glyph.advance' field, but */
1890 /* *not* the values in `face.glyph.metrics'. */
1891 /* */
1892 FT_EXPORT( FT_Error )
1893 FT_Load_Glyph( FT_Face face,
1894 FT_UInt glyph_index,
1895 FT_Int load_flags );
1898 /*************************************************************************/
1899 /* */
1900 /* <Function> */
1901 /* FT_Load_Char */
1902 /* */
1903 /* <Description> */
1904 /* A function used to load a single glyph within a given glyph slot, */
1905 /* for a given size, according to its character code. */
1906 /* */
1907 /* <InOut> */
1908 /* face :: A handle to a target face object where the glyph */
1909 /* will be loaded. */
1910 /* */
1911 /* <Input> */
1912 /* char_code :: The glyph's character code, according to the */
1913 /* current charmap used in the face. */
1914 /* */
1915 /* load_flags :: A flag indicating what to load for this glyph. The */
1916 /* FT_LOAD_XXX constants can be used to control the */
1917 /* glyph loading process (e.g., whether the outline */
1918 /* should be scaled, whether to load bitmaps or not, */
1919 /* whether to hint the outline, etc). */
1920 /* */
1921 /* <Return> */
1922 /* FreeType error code. 0 means success. */
1923 /* */
1924 /* <Note> */
1925 /* If the face has no current charmap, or if the character code */
1926 /* is not defined in the charmap, this function will return an */
1927 /* error. */
1928 /* */
1929 /* If the glyph image is not a bitmap, and if the bit flag */
1930 /* FT_LOAD_IGNORE_TRANSFORM is unset, the glyph image will be */
1931 /* transformed with the information passed to a previous call to */
1932 /* FT_Set_Transform(). */
1933 /* */
1934 /* Note that this also transforms the `face.glyph.advance' field, but */
1935 /* *not* the values in `face.glyph.metrics'. */
1936 /* */
1937 FT_EXPORT( FT_Error )
1938 FT_Load_Char( FT_Face face,
1939 FT_ULong char_code,
1940 FT_Int load_flags );
1943 /*************************************************************************/
1944 /* */
1945 /* <Constant> */
1946 /* FT_LOAD_NO_SCALE */
1947 /* */
1948 /* <Description> */
1949 /* A bit field constant, used with FT_Load_Glyph() to indicate that */
1950 /* the vector outline being loaded should not be scaled to 26.6 */
1951 /* fractional pixels, but kept in notional units. */
1952 /* */
1953 #define FT_LOAD_NO_SCALE 1
1956 /*************************************************************************/
1957 /* */
1958 /* <Constant> */
1959 /* FT_LOAD_NO_HINTING */
1960 /* */
1961 /* <Description> */
1962 /* A bit-field constant, used with FT_Load_Glyph() to indicate that */
1963 /* the vector outline being loaded should not be fitted to the pixel */
1964 /* grid but simply scaled to 26.6 fractional pixels. */
1965 /* */
1966 /* This flag is ignored if FT_LOAD_NO_SCALE is set. */
1967 /* */
1968 #define FT_LOAD_NO_HINTING 2
1971 /*************************************************************************/
1972 /* */
1973 /* <Constant> */
1974 /* FT_LOAD_RENDER */
1975 /* */
1976 /* <Description> */
1977 /* A bit-field constant, used with FT_Load_Glyph() to indicate that */
1978 /* the function should load the glyph and immediately convert it into */
1979 /* a bitmap, if necessary, by calling FT_Render_Glyph(). */
1980 /* */
1981 /* Note that by default, FT_Load_Glyph() loads the glyph image in its */
1982 /* native format. */
1983 /* */
1984 #define FT_LOAD_RENDER 4
1987 /*************************************************************************/
1988 /* */
1989 /* <Constant> */
1990 /* FT_LOAD_NO_BITMAP */
1991 /* */
1992 /* <Description> */
1993 /* A bit-field constant, used with FT_Load_Glyph() to indicate that */
1994 /* the function should not load the bitmap or pixmap of a given */
1995 /* glyph. This is useful when you do not want to load the embedded */
1996 /* bitmaps of scalable formats, as the native glyph image will be */
1997 /* loaded, and can then be rendered through FT_Render_Glyph(). */
1998 /* */
1999 #define FT_LOAD_NO_BITMAP 8
2002 /*************************************************************************/
2003 /* */
2004 /* <Constant> */
2005 /* FT_LOAD_VERTICAL_LAYOUT */
2006 /* */
2007 /* <Description> */
2008 /* A bit-field constant, used with FT_Load_Glyph() to indicate that */
2009 /* the glyph image should be prepared for vertical layout. This */
2010 /* basically means that `face.glyph.advance' will correspond to the */
2011 /* vertical advance height (instead of the default horizontal */
2012 /* advance width), and that the glyph image will translated to match */
2013 /* the vertical bearings positions. */
2014 /* */
2015 #define FT_LOAD_VERTICAL_LAYOUT 16
2018 /*************************************************************************/
2019 /* */
2020 /* <Constant> */
2021 /* FT_LOAD_FORCE_AUTOHINT */
2022 /* */
2023 /* <Description> */
2024 /* A bit-field constant, used with FT_Load_Glyph() to indicate that */
2025 /* the function should try to auto-hint the glyphs, even if a driver */
2026 /* specific hinter is available. */
2027 /* */
2028 #define FT_LOAD_FORCE_AUTOHINT 32
2031 /*************************************************************************/
2032 /* */
2033 /* <Constant> */
2034 /* FT_LOAD_CROP_BITMAP */
2035 /* */
2036 /* <Description> */
2037 /* A bit-field constant, used with FT_Load_Glyph() to indicate that */
2038 /* the font driver should try to crop the bitmap (i.e. remove all */
2039 /* space around its black bits) when loading it. For now, this */
2040 /* really only works with embedded bitmaps in TrueType fonts. */
2041 /* */
2042 #define FT_LOAD_CROP_BITMAP 64
2045 /*************************************************************************/
2046 /* */
2047 /* <Constant> */
2048 /* FT_LOAD_PEDANTIC */
2049 /* */
2050 /* <Description> */
2051 /* A bit-field constant, used with FT_Load_Glyph() to indicate that */
2052 /* the glyph loader should perform a pedantic bytecode */
2053 /* interpretation. Many popular fonts come with broken glyph */
2054 /* programs. When this flag is set, loading them will return an */
2055 /* error. Otherwise, errors are ignored by the loader, sometimes */
2056 /* resulting in ugly glyphs. */
2057 /* */
2058 #define FT_LOAD_PEDANTIC 128
2061 /*************************************************************************/
2062 /* */
2063 /* <Constant> */
2064 /* FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH */
2065 /* */
2066 /* <Description> */
2067 /* A bit-field constant, used with FT_Load_Glyph() to indicate that */
2068 /* the glyph loader should ignore the global advance width defined */
2069 /* in the font. As far as we know, this is only used by the */
2070 /* X-TrueType font server, in order to deal correctly with the */
2071 /* incorrect metrics contained in DynaLab's TrueType CJK fonts. */
2072 /* */
2073 #define FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH 512
2076 /*************************************************************************/
2077 /* */
2078 /* <Constant> */
2079 /* FT_LOAD_NO_RECURSE */
2080 /* */
2081 /* <Description> */
2082 /* A bit-field constant, used with FT_Load_Glyph() to indicate that */
2083 /* the glyph loader should not load composite glyph recursively. */
2084 /* Rather, when a composite glyph is encountered, it should set */
2085 /* the values of `num_subglyphs' and `subglyphs', as well as set */
2086 /* `face->glyph.format' to ft_glyph_format_composite. */
2087 /* */
2088 /* This is for use by the auto-hinter and possibly other tools. */
2089 /* For nearly all applications, this flags should be left unset */
2090 /* when invoking FT_Load_Glyph(). */
2091 /* */
2092 /* Note that the flag forces the load of unscaled glyphs. */
2093 /* */
2094 #define FT_LOAD_NO_RECURSE 1024
2097 /*************************************************************************/
2098 /* */
2099 /* <Constant> */
2100 /* FT_LOAD_IGNORE_TRANSFORM */
2101 /* */
2102 /* <Description> */
2103 /* A bit-field constant, used with FT_Load_Glyph() to indicate that */
2104 /* the glyph loader should not try to transform the loaded glyph */
2105 /* image. */
2106 /* */
2107 #define FT_LOAD_IGNORE_TRANSFORM 2048
2110 /*************************************************************************/
2111 /* */
2112 /* <Constant> */
2113 /* FT_LOAD_MONOCHROME */
2114 /* */
2115 /* <Description> */
2116 /* Only used with FT_LOAD_RENDER set, it indicates that the returned */
2117 /* glyph image should be 1-bit monochrome. This really tells the */
2118 /* glyph loader to use `ft_render_mode_mono' when calling */
2119 /* FT_Render_Glyph(). */
2120 /* */
2121 #define FT_LOAD_MONOCHROME 4096
2124 /*************************************************************************/
2125 /* */
2126 /* <Constant> */
2127 /* FT_LOAD_LINEAR_DESIGN */
2128 /* */
2129 /* <Description> */
2130 /* A bit-field constant, used with FT_Load_Glyph() to indicate that */
2131 /* the function should return the linearly scaled metrics expressed */
2132 /* in original font units, instead of the default 16.16 pixel values. */
2133 /* */
2134 #define FT_LOAD_LINEAR_DESIGN 8192
2136 /* temporary hack! */
2137 #define FT_LOAD_SBITS_ONLY 16384
2140 /*************************************************************************/
2141 /* */
2142 /* <Constant> */
2143 /* FT_LOAD_DEFAULT */
2144 /* */
2145 /* <Description> */
2146 /* A bit-field constant, used with FT_Load_Glyph() to indicate that */
2147 /* the function should try to load the glyph normally, i.e., */
2148 /* embedded bitmaps are favored over outlines, vectors are always */
2149 /* scaled and grid-fitted. */
2150 /* */
2151 #define FT_LOAD_DEFAULT 0
2154 /*************************************************************************/
2155 /* */
2156 /* <Function> */
2157 /* FT_Set_Transform */
2158 /* */
2159 /* <Description> */
2160 /* A function used to set the transformation that is applied to glyph */
2161 /* images just before they are converted to bitmaps in a glyph slot */
2162 /* when FT_Render_Glyph() is called. */
2163 /* */
2164 /* <InOut> */
2165 /* face :: A handle to the source face object. */
2166 /* */
2167 /* <Input> */
2168 /* matrix :: A pointer to the transformation's 2x2 matrix. Use 0 for */
2169 /* the identity matrix. */
2170 /* delta :: A pointer to the translation vector. Use 0 for the null */
2171 /* vector. */
2172 /* */
2173 /* <Note> */
2174 /* The transformation is only applied to scalable image formats after */
2175 /* the glyph has been loaded. It means that hinting is unaltered by */
2176 /* the transformation and is performed on the character size given in */
2177 /* the last call to FT_Set_Char_Sizes() or FT_Set_Pixel_Sizes(). */
2178 /* */
2179 FT_EXPORT( void )
2180 FT_Set_Transform( FT_Face face,
2181 FT_Matrix* matrix,
2182 FT_Vector* delta );
2185 /*************************************************************************/
2186 /* */
2187 /* <Enum> */
2188 /* FT_Render_Mode */
2189 /* */
2190 /* <Description> */
2191 /* An enumeration type that lists the render modes supported by the */
2192 /* FreeType 2 renderer(s). A renderer is in charge of converting a */
2193 /* glyph image into a bitmap. */
2194 /* */
2195 /* <Fields> */
2196 /* ft_render_mode_normal :: This is the default render mode; it */
2197 /* corresponds to 8-bit anti-aliased */
2198 /* bitmaps, using 256 levels of gray. */
2199 /* */
2200 /* ft_render_mode_mono :: This render mode is used to produce 1-bit */
2201 /* monochrome bitmaps. */
2202 /* */
2203 /* <Note> */
2204 /* There is no render mode to produce 8-bit `monochrome' bitmaps -- */
2205 /* you have to make the conversion yourself if you need such things */
2206 /* (besides, FreeType is not a graphics library). */
2207 /* */
2208 /* More modes might appear later for specific display modes (e.g. TV, */
2209 /* LCDs, etc.). They will be supported through the simple addition */
2210 /* of a renderer module, with no changes to the rest of the engine. */
2211 /* */
2212 typedef enum FT_Render_Mode_
2214 ft_render_mode_normal = 0,
2215 ft_render_mode_mono = 1
2217 } FT_Render_Mode;
2220 /*************************************************************************/
2221 /* */
2222 /* <Function> */
2223 /* FT_Render_Glyph */
2224 /* */
2225 /* <Description> */
2226 /* Converts a given glyph image to a bitmap. It does so by */
2227 /* inspecting the glyph image format, find the relevant renderer, and */
2228 /* invoke it. */
2229 /* */
2230 /* <InOut> */
2231 /* slot :: A handle to the glyph slot containing the image to */
2232 /* convert. */
2233 /* */
2234 /* <Input> */
2235 /* render_mode :: This is the render mode used to render the glyph */
2236 /* image into a bitmap. See FT_Render_Mode for a list */
2237 /* of possible values. */
2238 /* */
2239 /* <Return> */
2240 /* FreeType error code. 0 means success. */
2241 /* */
2242 FT_EXPORT( FT_Error )
2243 FT_Render_Glyph( FT_GlyphSlot slot,
2244 FT_UInt render_mode );
2247 /*************************************************************************/
2248 /* */
2249 /* <Enum> */
2250 /* FT_Kerning_Mode */
2251 /* */
2252 /* <Description> */
2253 /* An enumeration used to specify which kerning values to return in */
2254 /* FT_Get_Kerning(). */
2255 /* */
2256 /* <Fields> */
2257 /* ft_kerning_default :: Return scaled and grid-fitted kerning */
2258 /* distances (value is 0). */
2259 /* */
2260 /* ft_kerning_unfitted :: Return scaled but un-grid-fitted kerning */
2261 /* distances. */
2262 /* */
2263 /* ft_kerning_unscaled :: Return the kerning vector in original font */
2264 /* units. */
2265 /* */
2266 typedef enum FT_Kerning_Mode_
2268 ft_kerning_default = 0,
2269 ft_kerning_unfitted,
2270 ft_kerning_unscaled
2272 } FT_Kerning_Mode;
2275 /*************************************************************************/
2276 /* */
2277 /* <Function> */
2278 /* FT_Get_Kerning */
2279 /* */
2280 /* <Description> */
2281 /* Returns the kerning vector between two glyphs of a same face. */
2282 /* */
2283 /* <Input> */
2284 /* face :: A handle to a source face object. */
2285 /* */
2286 /* left_glyph :: The index of the left glyph in the kern pair. */
2287 /* */
2288 /* right_glyph :: The index of the right glyph in the kern pair. */
2289 /* */
2290 /* kern_mode :: See FT_Kerning_Mode() for more information. */
2291 /* Determines the scale/dimension of the returned */
2292 /* kerning vector. */
2293 /* */
2294 /* <Output> */
2295 /* akerning :: The kerning vector. This is in font units for */
2296 /* scalable formats, and in pixels for fixed-sizes */
2297 /* formats. */
2298 /* */
2299 /* <Return> */
2300 /* FreeType error code. 0 means success. */
2301 /* */
2302 /* <Note> */
2303 /* Only horizontal layouts (left-to-right & right-to-left) are */
2304 /* supported by this method. Other layouts, or more sophisticated */
2305 /* kernings, are out of the scope of this API function -- they can be */
2306 /* implemented through format-specific interfaces. */
2307 /* */
2308 FT_EXPORT( FT_Error )
2309 FT_Get_Kerning( FT_Face face,
2310 FT_UInt left_glyph,
2311 FT_UInt right_glyph,
2312 FT_UInt kern_mode,
2313 FT_Vector *akerning );
2316 /*************************************************************************/
2317 /* */
2318 /* <Function> */
2319 /* FT_Get_Glyph_Name */
2320 /* */
2321 /* <Description> */
2322 /* Retrieves the ASCII name of a given glyph in a face. This only */
2323 /* works for those faces where FT_HAS_GLYPH_NAME(face) returns true. */
2324 /* */
2325 /* <Input> */
2326 /* face :: A handle to a source face object. */
2327 /* */
2328 /* glyph_index :: The glyph index. */
2329 /* */
2330 /* buffer_max :: The maximal number of bytes available in the */
2331 /* buffer. */
2332 /* */
2333 /* <Output> */
2334 /* buffer :: A pointer to a target buffer where the name will be */
2335 /* copied to. */
2336 /* */
2337 /* <Return> */
2338 /* FreeType error code. 0 means success. */
2339 /* */
2340 /* <Note> */
2341 /* An error is returned if the face doesn't provide glyph names or if */
2342 /* the glyph index is invalid. In all cases of failure, the first */
2343 /* byte of `buffer' will be set to 0 to indicate an empty name. */
2344 /* */
2345 /* The glyph name is truncated to fit within the buffer if it is too */
2346 /* long. The returned string is always zero-terminated. */
2347 /* */
2348 /* This function is not compiled within the library if the config */
2349 /* macro FT_CONFIG_OPTION_NO_GLYPH_NAMES is defined in */
2350 /* `include/freetype/config/ftoptions.h' */
2351 /* */
2352 FT_EXPORT( FT_Error )
2353 FT_Get_Glyph_Name( FT_Face face,
2354 FT_UInt glyph_index,
2355 FT_Pointer buffer,
2356 FT_UInt buffer_max );
2359 /*************************************************************************/
2360 /* */
2361 /* <Function> */
2362 /* FT_Get_Postscript_Name */
2363 /* */
2364 /* <Description> */
2365 /* Retrieves the ASCII Postscript name of a given face, if available. */
2366 /* This should only work with Postscript and TrueType fonts. */
2367 /* */
2368 /* <Input> */
2369 /* face :: A handle to the source face object. */
2370 /* */
2371 /* <Return> */
2372 /* A pointer to the face's Postscript name. NULL if un-available. */
2373 /* */
2374 /* <Note> */
2375 /* The returned pointer is owned by the face and will be destroyed */
2376 /* with it. */
2377 /* */
2378 FT_EXPORT( const char* )
2379 FT_Get_Postscript_Name( FT_Face face );
2382 /*************************************************************************/
2383 /* */
2384 /* <Function> */
2385 /* FT_Select_Charmap */
2386 /* */
2387 /* <Description> */
2388 /* Selects a given charmap by its encoding tag (as listed in */
2389 /* `freetype.h'). */
2390 /* */
2391 /* <InOut> */
2392 /* face :: A handle to the source face object. */
2393 /* */
2394 /* <Input> */
2395 /* encoding :: A handle to the selected charmap. */
2396 /* */
2397 /* <Return> */
2398 /* FreeType error code. 0 means success. */
2399 /* */
2400 /* <Note> */
2401 /* This function will return an error if no charmap in the face */
2402 /* corresponds to the encoding queried here. */
2403 /* */
2404 FT_EXPORT( FT_Error )
2405 FT_Select_Charmap( FT_Face face,
2406 FT_Encoding encoding );
2409 /*************************************************************************/
2410 /* */
2411 /* <Function> */
2412 /* FT_Set_Charmap */
2413 /* */
2414 /* <Description> */
2415 /* Selects a given charmap for character code to glyph index */
2416 /* decoding. */
2417 /* */
2418 /* <InOut> */
2419 /* face :: A handle to the source face object. */
2420 /* */
2421 /* <Input> */
2422 /* charmap :: A handle to the selected charmap. */
2423 /* */
2424 /* <Return> */
2425 /* FreeType error code. 0 means success. */
2426 /* */
2427 /* <Note> */
2428 /* This function will return an error if the charmap is not part of */
2429 /* the face (i.e., if it is not listed in the face->charmaps[] */
2430 /* table). */
2431 /* */
2432 FT_EXPORT( FT_Error )
2433 FT_Set_Charmap( FT_Face face,
2434 FT_CharMap charmap );
2437 /*************************************************************************/
2438 /* */
2439 /* <Function> */
2440 /* FT_Get_Char_Index */
2441 /* */
2442 /* <Description> */
2443 /* Returns the glyph index of a given character code. This function */
2444 /* uses a charmap object to do the translation. */
2445 /* */
2446 /* <Input> */
2447 /* face :: A handle to the source face object. */
2448 /* */
2449 /* charcode :: The character code. */
2450 /* */
2451 /* <Return> */
2452 /* The glyph index. 0 means `undefined character code'. */
2453 /* */
2454 /* <Note> */
2455 /* FreeType computes its own glyph indices which are not necessarily */
2456 /* the same as used in the font in case the font is based on glyph */
2457 /* indices. Reason for this behaviour is to assure that index 0 is */
2458 /* never used, representing the missing glyph. */
2459 /* */
2460 FT_EXPORT( FT_UInt )
2461 FT_Get_Char_Index( FT_Face face,
2462 FT_ULong charcode );
2465 /*************************************************************************/
2466 /* */
2467 /* <Function> */
2468 /* FT_Get_First_Char */
2469 /* */
2470 /* <Description> */
2471 /* This function is used to return the first character code in the */
2472 /* current charmap of a given face. It will also return the */
2473 /* corresponding glyph index. */
2474 /* */
2475 /* <Input> */
2476 /* face :: A handle to the source face object. */
2477 /* */
2478 /* <Output> */
2479 /* agindex :: Glyph index of first character code. 0 if charmap is */
2480 /* empty. */
2481 /* */
2482 /* <Return> */
2483 /* The charmap's first character code. */
2484 /* */
2485 /* <Note> */
2486 /* You should use this function with @FT_Get_Next_Char to be able to */
2487 /* parse all character codes available in a given charmap. The code */
2488 /* should look like this: */
2489 /* */
2490 /* { */
2491 /* FT_ULong charcode; */
2492 /* FT_UInt gindex; */
2493 /* */
2494 /* */
2495 /* charcode = FT_Get_First_Char( face, &gindex ); */
2496 /* while ( gindex != 0 ) */
2497 /* { */
2498 /* ... do something with (charcode,gindex) pair ... */
2499 /* */
2500 /* charcode = FT_Get_Next_Char( face, charcode, &gindex ); */
2501 /* } */
2502 /* } */
2503 /* */
2504 /* Note that `*agindex' will be set to 0 if the charmap is empty. */
2505 /* The result itself can be 0 in two cases: if the charmap is empty */
2506 /* or when the value 0 is the first valid character code. */
2507 /* */
2508 FT_EXPORT( FT_ULong )
2509 FT_Get_First_Char( FT_Face face,
2510 FT_UInt *agindex );
2513 /*************************************************************************/
2514 /* */
2515 /* <Function> */
2516 /* FT_Get_Next_Char */
2517 /* */
2518 /* <Description> */
2519 /* This function is used to return the next character code in the */
2520 /* current charmap of a given face following the value 'char_code', */
2521 /* as well as the corresponding glyph index. */
2522 /* */
2523 /* <Input> */
2524 /* face :: A handle to the source face object. */
2525 /* char_code :: The starting character code. */
2526 /* */
2527 /* <Output> */
2528 /* agindex :: Glyph index of first character code. 0 if charmap */
2529 /* is empty. */
2530 /* */
2531 /* <Return> */
2532 /* The charmap's next character code. */
2533 /* */
2534 /* <Note> */
2535 /* You should use this function with @FT_Get_First_Char to walk */
2536 /* through all character codes available in a given charmap. See */
2537 /* the note for this function for a simple code example. */
2538 /* */
2539 /* Note that `*agindex' will be set to 0 when there are no more codes */
2540 /* in the charmap. */
2541 /* */
2542 FT_EXPORT( FT_ULong )
2543 FT_Get_Next_Char( FT_Face face,
2544 FT_ULong char_code,
2545 FT_UInt *agindex );
2548 /*************************************************************************/
2549 /* */
2550 /* <Function> */
2551 /* FT_Get_Name_Index */
2552 /* */
2553 /* <Description> */
2554 /* Returns the glyph index of a given glyph name. This function uses */
2555 /* driver specific objects to do the translation. */
2556 /* */
2557 /* <Input> */
2558 /* face :: A handle to the source face object. */
2559 /* */
2560 /* glyph_name :: The glyph name. */
2561 /* */
2562 /* <Return> */
2563 /* The glyph index. 0 means `undefined character code'. */
2564 /* */
2565 FT_EXPORT( FT_UInt )
2566 FT_Get_Name_Index( FT_Face face,
2567 FT_String* glyph_name );
2571 /*************************************************************************/
2572 /* */
2573 /* <Section> */
2574 /* computations */
2575 /* */
2576 /* <Title> */
2577 /* Computations */
2578 /* */
2579 /* <Abstract> */
2580 /* Crunching fixed numbers and vectors */
2581 /* */
2582 /* <Description> */
2583 /* This section contains various functions used to perform */
2584 /* computations on 16.16 fixed-float numbers or 2d vectors. */
2585 /* */
2586 /* <Order> */
2587 /* FT_MulDiv */
2588 /* FT_MulFix */
2589 /* FT_DivFix */
2590 /* FT_RoundFix */
2591 /* FT_CeilFix */
2592 /* FT_FloorFix */
2593 /* FT_Vector_Transform */
2594 /* FT_Matrix_Multiply */
2595 /* FT_Matrix_Invert */
2596 /* */
2597 /*************************************************************************/
2600 /*************************************************************************/
2601 /* */
2602 /* <Function> */
2603 /* FT_MulDiv */
2604 /* */
2605 /* <Description> */
2606 /* A very simple function used to perform the computation `(a*b)/c' */
2607 /* with maximal accuracy (it uses a 64-bit intermediate integer */
2608 /* whenever necessary). */
2609 /* */
2610 /* This function isn't necessarily as fast as some processor specific */
2611 /* operations, but is at least completely portable. */
2612 /* */
2613 /* <Input> */
2614 /* a :: The first multiplier. */
2615 /* b :: The second multiplier. */
2616 /* c :: The divisor. */
2617 /* */
2618 /* <Return> */
2619 /* The result of `(a*b)/c'. This function never traps when trying to */
2620 /* divide by zero; it simply returns `MaxInt' or `MinInt' depending */
2621 /* on the signs of `a' and `b'. */
2622 /* */
2623 FT_EXPORT( FT_Long )
2624 FT_MulDiv( FT_Long a,
2625 FT_Long b,
2626 FT_Long c );
2629 /*************************************************************************/
2630 /* */
2631 /* <Function> */
2632 /* FT_MulFix */
2633 /* */
2634 /* <Description> */
2635 /* A very simple function used to perform the computation */
2636 /* `(a*b)/0x10000' with maximal accuracy. Most of the time this is */
2637 /* used to multiply a given value by a 16.16 fixed float factor. */
2638 /* */
2639 /* <Input> */
2640 /* a :: The first multiplier. */
2641 /* b :: The second multiplier. Use a 16.16 factor here whenever */
2642 /* possible (see note below). */
2643 /* */
2644 /* <Return> */
2645 /* The result of `(a*b)/0x10000'. */
2646 /* */
2647 /* <Note> */
2648 /* This function has been optimized for the case where the absolute */
2649 /* value of `a' is less than 2048, and `b' is a 16.16 scaling factor. */
2650 /* As this happens mainly when scaling from notional units to */
2651 /* fractional pixels in FreeType, it resulted in noticeable speed */
2652 /* improvements between versions 2.x and 1.x. */
2653 /* */
2654 /* As a conclusion, always try to place a 16.16 factor as the */
2655 /* _second_ argument of this function; this can make a great */
2656 /* difference. */
2657 /* */
2658 FT_EXPORT( FT_Long )
2659 FT_MulFix( FT_Long a,
2660 FT_Long b );
2663 /*************************************************************************/
2664 /* */
2665 /* <Function> */
2666 /* FT_DivFix */
2667 /* */
2668 /* <Description> */
2669 /* A very simple function used to perform the computation */
2670 /* `(a*0x10000)/b' with maximal accuracy. Most of the time, this is */
2671 /* used to divide a given value by a 16.16 fixed float factor. */
2672 /* */
2673 /* <Input> */
2674 /* a :: The first multiplier. */
2675 /* b :: The second multiplier. Use a 16.16 factor here whenever */
2676 /* possible (see note below). */
2677 /* */
2678 /* <Return> */
2679 /* The result of `(a*0x10000)/b'. */
2680 /* */
2681 /* <Note> */
2682 /* The optimization for FT_DivFix() is simple: If (a << 16) fits in */
2683 /* 32 bits, then the division is computed directly. Otherwise, we */
2684 /* use a specialized version of the old FT_MulDiv64(). */
2685 /* */
2686 FT_EXPORT( FT_Long )
2687 FT_DivFix( FT_Long a,
2688 FT_Long b );
2691 /*************************************************************************/
2692 /* */
2693 /* <Function> */
2694 /* FT_RoundFix */
2695 /* */
2696 /* <Description> */
2697 /* A very simple function used to round a 16.16 fixed number. */
2698 /* */
2699 /* <Input> */
2700 /* a :: The number to be rounded. */
2701 /* */
2702 /* <Return> */
2703 /* The result of `(a + 0x8000) & -0x10000'. */
2704 /* */
2705 FT_EXPORT( FT_Fixed )
2706 FT_RoundFix( FT_Fixed a );
2709 /*************************************************************************/
2710 /* */
2711 /* <Function> */
2712 /* FT_CeilFix */
2713 /* */
2714 /* <Description> */
2715 /* A very simple function used to compute the ceiling function of a */
2716 /* 16.16 fixed number. */
2717 /* */
2718 /* <Input> */
2719 /* a :: The number for which the ceiling function is to be computed. */
2720 /* */
2721 /* <Return> */
2722 /* The result of `(a + 0x10000 - 1) & -0x10000'. */
2723 /* */
2724 FT_EXPORT( FT_Fixed )
2725 FT_CeilFix( FT_Fixed a );
2728 /*************************************************************************/
2729 /* */
2730 /* <Function> */
2731 /* FT_FloorFix */
2732 /* */
2733 /* <Description> */
2734 /* A very simple function used to compute the floor function of a */
2735 /* 16.16 fixed number. */
2736 /* */
2737 /* <Input> */
2738 /* a :: The number for which the floor function is to be computed. */
2739 /* */
2740 /* <Return> */
2741 /* The result of `a & -0x10000'. */
2742 /* */
2743 FT_EXPORT( FT_Fixed )
2744 FT_FloorFix( FT_Fixed a );
2747 /*************************************************************************/
2748 /* */
2749 /* <Function> */
2750 /* FT_Vector_Transform */
2751 /* */
2752 /* <Description> */
2753 /* Transforms a single vector through a 2x2 matrix. */
2754 /* */
2755 /* <InOut> */
2756 /* vector :: The target vector to transform. */
2757 /* */
2758 /* <Input> */
2759 /* matrix :: A pointer to the source 2x2 matrix. */
2760 /* */
2761 /* <Note> */
2762 /* The result is undefined if either `vector' or `matrix' is invalid. */
2763 /* */
2764 FT_EXPORT( void )
2765 FT_Vector_Transform( FT_Vector* vec,
2766 FT_Matrix* matrix );
2769 /* */
2771 FT_END_HEADER
2773 #endif /* __FREETYPE_H__ */
2776 /* END */