1 | /***************************************************************************/ |
2 | /* */ |
3 | /* freetype.h */ |
4 | /* */ |
5 | /* FreeType high-level API and common types (specification only). */ |
6 | /* */ |
7 | /* Copyright 1996-2017 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 | /***************************************************************************/ |
17 | |
18 | |
19 | #ifndef FREETYPE_H_ |
20 | #define FREETYPE_H_ |
21 | |
22 | |
23 | #ifndef FT_FREETYPE_H |
24 | #error "`ft2build.h' hasn't been included yet!" |
25 | #error "Please always use macros to include FreeType header files." |
26 | #error "Example:" |
27 | #error " #include <ft2build.h>" |
28 | #error " #include FT_FREETYPE_H" |
29 | #endif |
30 | |
31 | |
32 | #include <ft2build.h> |
33 | #include FT_CONFIG_CONFIG_H |
34 | #include FT_TYPES_H |
35 | #include FT_ERRORS_H |
36 | |
37 | |
38 | FT_BEGIN_HEADER |
39 | |
40 | |
41 | |
42 | /*************************************************************************/ |
43 | /* */ |
44 | /* <Section> */ |
45 | /* header_inclusion */ |
46 | /* */ |
47 | /* <Title> */ |
48 | /* FreeType's header inclusion scheme */ |
49 | /* */ |
50 | /* <Abstract> */ |
51 | /* How client applications should include FreeType header files. */ |
52 | /* */ |
53 | /* <Description> */ |
54 | /* To be as flexible as possible (and for historical reasons), */ |
55 | /* FreeType uses a very special inclusion scheme to load header */ |
56 | /* files, for example */ |
57 | /* */ |
58 | /* { */ |
59 | /* #include <ft2build.h> */ |
60 | /* */ |
61 | /* #include FT_FREETYPE_H */ |
62 | /* #include FT_OUTLINE_H */ |
63 | /* } */ |
64 | /* */ |
65 | /* A compiler and its preprocessor only needs an include path to find */ |
66 | /* the file `ft2build.h'; the exact locations and names of the other */ |
67 | /* FreeType header files are hidden by preprocessor macro names, */ |
68 | /* loaded by `ft2build.h'. The API documentation always gives the */ |
69 | /* header macro name needed for a particular function. */ |
70 | /* */ |
71 | /*************************************************************************/ |
72 | |
73 | |
74 | /*************************************************************************/ |
75 | /* */ |
76 | /* <Section> */ |
77 | /* user_allocation */ |
78 | /* */ |
79 | /* <Title> */ |
80 | /* User allocation */ |
81 | /* */ |
82 | /* <Abstract> */ |
83 | /* How client applications should allocate FreeType data structures. */ |
84 | /* */ |
85 | /* <Description> */ |
86 | /* FreeType assumes that structures allocated by the user and passed */ |
87 | /* as arguments are zeroed out except for the actual data. In other */ |
88 | /* words, it is recommended to use `calloc' (or variants of it) */ |
89 | /* instead of `malloc' for allocation. */ |
90 | /* */ |
91 | /*************************************************************************/ |
92 | |
93 | |
94 | |
95 | /*************************************************************************/ |
96 | /*************************************************************************/ |
97 | /* */ |
98 | /* B A S I C T Y P E S */ |
99 | /* */ |
100 | /*************************************************************************/ |
101 | /*************************************************************************/ |
102 | |
103 | |
104 | /*************************************************************************/ |
105 | /* */ |
106 | /* <Section> */ |
107 | /* base_interface */ |
108 | /* */ |
109 | /* <Title> */ |
110 | /* Base Interface */ |
111 | /* */ |
112 | /* <Abstract> */ |
113 | /* The FreeType~2 base font interface. */ |
114 | /* */ |
115 | /* <Description> */ |
116 | /* This section describes the most important public high-level API */ |
117 | /* functions of FreeType~2. */ |
118 | /* */ |
119 | /* <Order> */ |
120 | /* FT_Library */ |
121 | /* FT_Face */ |
122 | /* FT_Size */ |
123 | /* FT_GlyphSlot */ |
124 | /* FT_CharMap */ |
125 | /* FT_Encoding */ |
126 | /* FT_ENC_TAG */ |
127 | /* */ |
128 | /* FT_FaceRec */ |
129 | /* */ |
130 | /* FT_FACE_FLAG_SCALABLE */ |
131 | /* FT_FACE_FLAG_FIXED_SIZES */ |
132 | /* FT_FACE_FLAG_FIXED_WIDTH */ |
133 | /* FT_FACE_FLAG_HORIZONTAL */ |
134 | /* FT_FACE_FLAG_VERTICAL */ |
135 | /* FT_FACE_FLAG_COLOR */ |
136 | /* FT_FACE_FLAG_SFNT */ |
137 | /* FT_FACE_FLAG_CID_KEYED */ |
138 | /* FT_FACE_FLAG_TRICKY */ |
139 | /* FT_FACE_FLAG_KERNING */ |
140 | /* FT_FACE_FLAG_MULTIPLE_MASTERS */ |
141 | /* FT_FACE_FLAG_GLYPH_NAMES */ |
142 | /* FT_FACE_FLAG_EXTERNAL_STREAM */ |
143 | /* FT_FACE_FLAG_HINTER */ |
144 | /* */ |
145 | /* FT_HAS_HORIZONTAL */ |
146 | /* FT_HAS_VERTICAL */ |
147 | /* FT_HAS_KERNING */ |
148 | /* FT_HAS_FIXED_SIZES */ |
149 | /* FT_HAS_GLYPH_NAMES */ |
150 | /* FT_HAS_MULTIPLE_MASTERS */ |
151 | /* FT_HAS_COLOR */ |
152 | /* */ |
153 | /* FT_IS_SFNT */ |
154 | /* FT_IS_SCALABLE */ |
155 | /* FT_IS_FIXED_WIDTH */ |
156 | /* FT_IS_CID_KEYED */ |
157 | /* FT_IS_TRICKY */ |
158 | /* */ |
159 | /* FT_STYLE_FLAG_BOLD */ |
160 | /* FT_STYLE_FLAG_ITALIC */ |
161 | /* */ |
162 | /* FT_SizeRec */ |
163 | /* FT_Size_Metrics */ |
164 | /* */ |
165 | /* FT_GlyphSlotRec */ |
166 | /* FT_Glyph_Metrics */ |
167 | /* FT_SubGlyph */ |
168 | /* */ |
169 | /* FT_Bitmap_Size */ |
170 | /* */ |
171 | /* FT_Init_FreeType */ |
172 | /* FT_Done_FreeType */ |
173 | /* */ |
174 | /* FT_New_Face */ |
175 | /* FT_Done_Face */ |
176 | /* FT_Reference_Face */ |
177 | /* FT_New_Memory_Face */ |
178 | /* FT_Face_Properties */ |
179 | /* FT_Open_Face */ |
180 | /* FT_Open_Args */ |
181 | /* FT_Parameter */ |
182 | /* FT_Attach_File */ |
183 | /* FT_Attach_Stream */ |
184 | /* */ |
185 | /* FT_Set_Char_Size */ |
186 | /* FT_Set_Pixel_Sizes */ |
187 | /* FT_Request_Size */ |
188 | /* FT_Select_Size */ |
189 | /* FT_Size_Request_Type */ |
190 | /* FT_Size_RequestRec */ |
191 | /* FT_Size_Request */ |
192 | /* FT_Set_Transform */ |
193 | /* FT_Load_Glyph */ |
194 | /* FT_Get_Char_Index */ |
195 | /* FT_Get_First_Char */ |
196 | /* FT_Get_Next_Char */ |
197 | /* FT_Get_Name_Index */ |
198 | /* FT_Load_Char */ |
199 | /* */ |
200 | /* FT_OPEN_MEMORY */ |
201 | /* FT_OPEN_STREAM */ |
202 | /* FT_OPEN_PATHNAME */ |
203 | /* FT_OPEN_DRIVER */ |
204 | /* FT_OPEN_PARAMS */ |
205 | /* */ |
206 | /* FT_LOAD_DEFAULT */ |
207 | /* FT_LOAD_RENDER */ |
208 | /* FT_LOAD_MONOCHROME */ |
209 | /* FT_LOAD_LINEAR_DESIGN */ |
210 | /* FT_LOAD_NO_SCALE */ |
211 | /* FT_LOAD_NO_HINTING */ |
212 | /* FT_LOAD_NO_BITMAP */ |
213 | /* FT_LOAD_NO_AUTOHINT */ |
214 | /* FT_LOAD_COLOR */ |
215 | /* */ |
216 | /* FT_LOAD_VERTICAL_LAYOUT */ |
217 | /* FT_LOAD_IGNORE_TRANSFORM */ |
218 | /* FT_LOAD_FORCE_AUTOHINT */ |
219 | /* FT_LOAD_NO_RECURSE */ |
220 | /* FT_LOAD_PEDANTIC */ |
221 | /* */ |
222 | /* FT_LOAD_TARGET_NORMAL */ |
223 | /* FT_LOAD_TARGET_LIGHT */ |
224 | /* FT_LOAD_TARGET_MONO */ |
225 | /* FT_LOAD_TARGET_LCD */ |
226 | /* FT_LOAD_TARGET_LCD_V */ |
227 | /* */ |
228 | /* FT_LOAD_TARGET_MODE */ |
229 | /* */ |
230 | /* FT_Render_Glyph */ |
231 | /* FT_Render_Mode */ |
232 | /* FT_Get_Kerning */ |
233 | /* FT_Kerning_Mode */ |
234 | /* FT_Get_Track_Kerning */ |
235 | /* FT_Get_Glyph_Name */ |
236 | /* FT_Get_Postscript_Name */ |
237 | /* */ |
238 | /* FT_CharMapRec */ |
239 | /* FT_Select_Charmap */ |
240 | /* FT_Set_Charmap */ |
241 | /* FT_Get_Charmap_Index */ |
242 | /* */ |
243 | /* FT_Get_FSType_Flags */ |
244 | /* FT_Get_SubGlyph_Info */ |
245 | /* */ |
246 | /* FT_Face_Internal */ |
247 | /* FT_Size_Internal */ |
248 | /* FT_Slot_Internal */ |
249 | /* */ |
250 | /* FT_FACE_FLAG_XXX */ |
251 | /* FT_STYLE_FLAG_XXX */ |
252 | /* FT_OPEN_XXX */ |
253 | /* FT_LOAD_XXX */ |
254 | /* FT_LOAD_TARGET_XXX */ |
255 | /* FT_SUBGLYPH_FLAG_XXX */ |
256 | /* FT_FSTYPE_XXX */ |
257 | /* */ |
258 | /* FT_HAS_FAST_GLYPHS */ |
259 | /* */ |
260 | /*************************************************************************/ |
261 | |
262 | |
263 | /*************************************************************************/ |
264 | /* */ |
265 | /* <Struct> */ |
266 | /* FT_Glyph_Metrics */ |
267 | /* */ |
268 | /* <Description> */ |
269 | /* A structure to model the metrics of a single glyph. The values */ |
270 | /* are expressed in 26.6 fractional pixel format; if the flag */ |
271 | /* @FT_LOAD_NO_SCALE has been used while loading the glyph, values */ |
272 | /* are expressed in font units instead. */ |
273 | /* */ |
274 | /* <Fields> */ |
275 | /* width :: */ |
276 | /* The glyph's width. */ |
277 | /* */ |
278 | /* height :: */ |
279 | /* The glyph's height. */ |
280 | /* */ |
281 | /* horiBearingX :: */ |
282 | /* Left side bearing for horizontal layout. */ |
283 | /* */ |
284 | /* horiBearingY :: */ |
285 | /* Top side bearing for horizontal layout. */ |
286 | /* */ |
287 | /* horiAdvance :: */ |
288 | /* Advance width for horizontal layout. */ |
289 | /* */ |
290 | /* vertBearingX :: */ |
291 | /* Left side bearing for vertical layout. */ |
292 | /* */ |
293 | /* vertBearingY :: */ |
294 | /* Top side bearing for vertical layout. Larger positive values */ |
295 | /* mean further below the vertical glyph origin. */ |
296 | /* */ |
297 | /* vertAdvance :: */ |
298 | /* Advance height for vertical layout. Positive values mean the */ |
299 | /* glyph has a positive advance downward. */ |
300 | /* */ |
301 | /* <Note> */ |
302 | /* If not disabled with @FT_LOAD_NO_HINTING, the values represent */ |
303 | /* dimensions of the hinted glyph (in case hinting is applicable). */ |
304 | /* */ |
305 | /* Stroking a glyph with an outside border does not increase */ |
306 | /* `horiAdvance' or `vertAdvance'; you have to manually adjust these */ |
307 | /* values to account for the added width and height. */ |
308 | /* */ |
309 | /* FreeType doesn't use the `VORG' table data for CFF fonts because */ |
310 | /* it doesn't have an interface to quickly retrieve the glyph height. */ |
311 | /* The y~coordinate of the vertical origin can be simply computed as */ |
312 | /* `vertBearingY + height' after loading a glyph. */ |
313 | /* */ |
314 | typedef struct FT_Glyph_Metrics_ |
315 | { |
316 | FT_Pos width; |
317 | FT_Pos height; |
318 | |
319 | FT_Pos horiBearingX; |
320 | FT_Pos horiBearingY; |
321 | FT_Pos horiAdvance; |
322 | |
323 | FT_Pos vertBearingX; |
324 | FT_Pos vertBearingY; |
325 | FT_Pos vertAdvance; |
326 | |
327 | } FT_Glyph_Metrics; |
328 | |
329 | |
330 | /*************************************************************************/ |
331 | /* */ |
332 | /* <Struct> */ |
333 | /* FT_Bitmap_Size */ |
334 | /* */ |
335 | /* <Description> */ |
336 | /* This structure models the metrics of a bitmap strike (i.e., a set */ |
337 | /* of glyphs for a given point size and resolution) in a bitmap font. */ |
338 | /* It is used for the `available_sizes' field of @FT_Face. */ |
339 | /* */ |
340 | /* <Fields> */ |
341 | /* height :: The vertical distance, in pixels, between two */ |
342 | /* consecutive baselines. It is always positive. */ |
343 | /* */ |
344 | /* width :: The average width, in pixels, of all glyphs in the */ |
345 | /* strike. */ |
346 | /* */ |
347 | /* size :: The nominal size of the strike in 26.6 fractional */ |
348 | /* points. This field is not very useful. */ |
349 | /* */ |
350 | /* x_ppem :: The horizontal ppem (nominal width) in 26.6 fractional */ |
351 | /* pixels. */ |
352 | /* */ |
353 | /* y_ppem :: The vertical ppem (nominal height) in 26.6 fractional */ |
354 | /* pixels. */ |
355 | /* */ |
356 | /* <Note> */ |
357 | /* Windows FNT: */ |
358 | /* The nominal size given in a FNT font is not reliable. If the */ |
359 | /* driver finds it incorrect, it sets `size' to some calculated */ |
360 | /* values, and `x_ppem' and `y_ppem' to the pixel width and height */ |
361 | /* given in the font, respectively. */ |
362 | /* */ |
363 | /* TrueType embedded bitmaps: */ |
364 | /* `size', `width', and `height' values are not contained in the */ |
365 | /* bitmap strike itself. They are computed from the global font */ |
366 | /* parameters. */ |
367 | /* */ |
368 | typedef struct FT_Bitmap_Size_ |
369 | { |
370 | FT_Short height; |
371 | FT_Short width; |
372 | |
373 | FT_Pos size; |
374 | |
375 | FT_Pos x_ppem; |
376 | FT_Pos y_ppem; |
377 | |
378 | } FT_Bitmap_Size; |
379 | |
380 | |
381 | /*************************************************************************/ |
382 | /*************************************************************************/ |
383 | /* */ |
384 | /* O B J E C T C L A S S E S */ |
385 | /* */ |
386 | /*************************************************************************/ |
387 | /*************************************************************************/ |
388 | |
389 | /*************************************************************************/ |
390 | /* */ |
391 | /* <Type> */ |
392 | /* FT_Library */ |
393 | /* */ |
394 | /* <Description> */ |
395 | /* A handle to a FreeType library instance. Each `library' is */ |
396 | /* completely independent from the others; it is the `root' of a set */ |
397 | /* of objects like fonts, faces, sizes, etc. */ |
398 | /* */ |
399 | /* It also embeds a memory manager (see @FT_Memory), as well as a */ |
400 | /* scan-line converter object (see @FT_Raster). */ |
401 | /* */ |
402 | /* In multi-threaded applications it is easiest to use one */ |
403 | /* `FT_Library' object per thread. In case this is too cumbersome, */ |
404 | /* a single `FT_Library' object across threads is possible also */ |
405 | /* (since FreeType version 2.5.6), as long as a mutex lock is used */ |
406 | /* around @FT_New_Face and @FT_Done_Face. */ |
407 | /* */ |
408 | /* <Note> */ |
409 | /* Library objects are normally created by @FT_Init_FreeType, and */ |
410 | /* destroyed with @FT_Done_FreeType. If you need reference-counting */ |
411 | /* (cf. @FT_Reference_Library), use @FT_New_Library and */ |
412 | /* @FT_Done_Library. */ |
413 | /* */ |
414 | typedef struct FT_LibraryRec_ *FT_Library; |
415 | |
416 | |
417 | /*************************************************************************/ |
418 | /* */ |
419 | /* <Section> */ |
420 | /* module_management */ |
421 | /* */ |
422 | /*************************************************************************/ |
423 | |
424 | /*************************************************************************/ |
425 | /* */ |
426 | /* <Type> */ |
427 | /* FT_Module */ |
428 | /* */ |
429 | /* <Description> */ |
430 | /* A handle to a given FreeType module object. A module can be a */ |
431 | /* font driver, a renderer, or anything else that provides services */ |
432 | /* to the former. */ |
433 | /* */ |
434 | typedef struct FT_ModuleRec_* FT_Module; |
435 | |
436 | |
437 | /*************************************************************************/ |
438 | /* */ |
439 | /* <Type> */ |
440 | /* FT_Driver */ |
441 | /* */ |
442 | /* <Description> */ |
443 | /* A handle to a given FreeType font driver object. A font driver */ |
444 | /* is a module capable of creating faces from font files. */ |
445 | /* */ |
446 | typedef struct FT_DriverRec_* FT_Driver; |
447 | |
448 | |
449 | /*************************************************************************/ |
450 | /* */ |
451 | /* <Type> */ |
452 | /* FT_Renderer */ |
453 | /* */ |
454 | /* <Description> */ |
455 | /* A handle to a given FreeType renderer. A renderer is a module in */ |
456 | /* charge of converting a glyph's outline image to a bitmap. It */ |
457 | /* supports a single glyph image format, and one or more target */ |
458 | /* surface depths. */ |
459 | /* */ |
460 | typedef struct FT_RendererRec_* FT_Renderer; |
461 | |
462 | |
463 | /*************************************************************************/ |
464 | /* */ |
465 | /* <Section> */ |
466 | /* base_interface */ |
467 | /* */ |
468 | /*************************************************************************/ |
469 | |
470 | /*************************************************************************/ |
471 | /* */ |
472 | /* <Type> */ |
473 | /* FT_Face */ |
474 | /* */ |
475 | /* <Description> */ |
476 | /* A handle to a typographic face object. A face object models a */ |
477 | /* given typeface, in a given style. */ |
478 | /* */ |
479 | /* <Note> */ |
480 | /* A face object also owns a single @FT_GlyphSlot object, as well */ |
481 | /* as one or more @FT_Size objects. */ |
482 | /* */ |
483 | /* Use @FT_New_Face or @FT_Open_Face to create a new face object from */ |
484 | /* a given filepath or a custom input stream. */ |
485 | /* */ |
486 | /* Use @FT_Done_Face to destroy it (along with its slot and sizes). */ |
487 | /* */ |
488 | /* An `FT_Face' object can only be safely used from one thread at a */ |
489 | /* time. Similarly, creation and destruction of `FT_Face' with the */ |
490 | /* same @FT_Library object can only be done from one thread at a */ |
491 | /* time. On the other hand, functions like @FT_Load_Glyph and its */ |
492 | /* siblings are thread-safe and do not need the lock to be held as */ |
493 | /* long as the same `FT_Face' object is not used from multiple */ |
494 | /* threads at the same time. */ |
495 | /* */ |
496 | /* <Also> */ |
497 | /* See @FT_FaceRec for the publicly accessible fields of a given face */ |
498 | /* object. */ |
499 | /* */ |
500 | typedef struct FT_FaceRec_* FT_Face; |
501 | |
502 | |
503 | /*************************************************************************/ |
504 | /* */ |
505 | /* <Type> */ |
506 | /* FT_Size */ |
507 | /* */ |
508 | /* <Description> */ |
509 | /* A handle to an object that models a face scaled to a given */ |
510 | /* character size. */ |
511 | /* */ |
512 | /* <Note> */ |
513 | /* An @FT_Face has one _active_ @FT_Size object that is used by */ |
514 | /* functions like @FT_Load_Glyph to determine the scaling */ |
515 | /* transformation that in turn is used to load and hint glyphs and */ |
516 | /* metrics. */ |
517 | /* */ |
518 | /* You can use @FT_Set_Char_Size, @FT_Set_Pixel_Sizes, */ |
519 | /* @FT_Request_Size or even @FT_Select_Size to change the content */ |
520 | /* (i.e., the scaling values) of the active @FT_Size. */ |
521 | /* */ |
522 | /* You can use @FT_New_Size to create additional size objects for a */ |
523 | /* given @FT_Face, but they won't be used by other functions until */ |
524 | /* you activate it through @FT_Activate_Size. Only one size can be */ |
525 | /* activated at any given time per face. */ |
526 | /* */ |
527 | /* <Also> */ |
528 | /* See @FT_SizeRec for the publicly accessible fields of a given size */ |
529 | /* object. */ |
530 | /* */ |
531 | typedef struct FT_SizeRec_* FT_Size; |
532 | |
533 | |
534 | /*************************************************************************/ |
535 | /* */ |
536 | /* <Type> */ |
537 | /* FT_GlyphSlot */ |
538 | /* */ |
539 | /* <Description> */ |
540 | /* A handle to a given `glyph slot'. A slot is a container that can */ |
541 | /* hold any of the glyphs contained in its parent face. */ |
542 | /* */ |
543 | /* In other words, each time you call @FT_Load_Glyph or */ |
544 | /* @FT_Load_Char, the slot's content is erased by the new glyph data, */ |
545 | /* i.e., the glyph's metrics, its image (bitmap or outline), and */ |
546 | /* other control information. */ |
547 | /* */ |
548 | /* <Also> */ |
549 | /* See @FT_GlyphSlotRec for the publicly accessible glyph fields. */ |
550 | /* */ |
551 | typedef struct FT_GlyphSlotRec_* FT_GlyphSlot; |
552 | |
553 | |
554 | /*************************************************************************/ |
555 | /* */ |
556 | /* <Type> */ |
557 | /* FT_CharMap */ |
558 | /* */ |
559 | /* <Description> */ |
560 | /* A handle to a character map (usually abbreviated to `charmap'). A */ |
561 | /* charmap is used to translate character codes in a given encoding */ |
562 | /* into glyph indexes for its parent's face. Some font formats may */ |
563 | /* provide several charmaps per font. */ |
564 | /* */ |
565 | /* Each face object owns zero or more charmaps, but only one of them */ |
566 | /* can be `active', providing the data used by @FT_Get_Char_Index or */ |
567 | /* @FT_Load_Char. */ |
568 | /* */ |
569 | /* The list of available charmaps in a face is available through the */ |
570 | /* `face->num_charmaps' and `face->charmaps' fields of @FT_FaceRec. */ |
571 | /* */ |
572 | /* The currently active charmap is available as `face->charmap'. */ |
573 | /* You should call @FT_Set_Charmap to change it. */ |
574 | /* */ |
575 | /* <Note> */ |
576 | /* When a new face is created (either through @FT_New_Face or */ |
577 | /* @FT_Open_Face), the library looks for a Unicode charmap within */ |
578 | /* the list and automatically activates it. If there is no Unicode */ |
579 | /* charmap, FreeType doesn't set an `active' charmap. */ |
580 | /* */ |
581 | /* <Also> */ |
582 | /* See @FT_CharMapRec for the publicly accessible fields of a given */ |
583 | /* character map. */ |
584 | /* */ |
585 | typedef struct FT_CharMapRec_* FT_CharMap; |
586 | |
587 | |
588 | /*************************************************************************/ |
589 | /* */ |
590 | /* <Macro> */ |
591 | /* FT_ENC_TAG */ |
592 | /* */ |
593 | /* <Description> */ |
594 | /* This macro converts four-letter tags into an unsigned long. It is */ |
595 | /* used to define `encoding' identifiers (see @FT_Encoding). */ |
596 | /* */ |
597 | /* <Note> */ |
598 | /* Since many 16-bit compilers don't like 32-bit enumerations, you */ |
599 | /* should redefine this macro in case of problems to something like */ |
600 | /* this: */ |
601 | /* */ |
602 | /* { */ |
603 | /* #define FT_ENC_TAG( value, a, b, c, d ) value */ |
604 | /* } */ |
605 | /* */ |
606 | /* to get a simple enumeration without assigning special numbers. */ |
607 | /* */ |
608 | |
609 | #ifndef FT_ENC_TAG |
610 | #define FT_ENC_TAG( value, a, b, c, d ) \ |
611 | value = ( ( (FT_UInt32)(a) << 24 ) | \ |
612 | ( (FT_UInt32)(b) << 16 ) | \ |
613 | ( (FT_UInt32)(c) << 8 ) | \ |
614 | (FT_UInt32)(d) ) |
615 | |
616 | #endif /* FT_ENC_TAG */ |
617 | |
618 | |
619 | /*************************************************************************/ |
620 | /* */ |
621 | /* <Enum> */ |
622 | /* FT_Encoding */ |
623 | /* */ |
624 | /* <Description> */ |
625 | /* An enumeration to specify character sets supported by charmaps. */ |
626 | /* Used in the @FT_Select_Charmap API function. */ |
627 | /* */ |
628 | /* <Note> */ |
629 | /* Despite the name, this enumeration lists specific character */ |
630 | /* repertories (i.e., charsets), and not text encoding methods (e.g., */ |
631 | /* UTF-8, UTF-16, etc.). */ |
632 | /* */ |
633 | /* Other encodings might be defined in the future. */ |
634 | /* */ |
635 | /* <Values> */ |
636 | /* FT_ENCODING_NONE :: */ |
637 | /* The encoding value~0 is reserved. */ |
638 | /* */ |
639 | /* FT_ENCODING_UNICODE :: */ |
640 | /* The Unicode character set. This value covers all versions of */ |
641 | /* the Unicode repertoire, including ASCII and Latin-1. Most fonts */ |
642 | /* include a Unicode charmap, but not all of them. */ |
643 | /* */ |
644 | /* For example, if you want to access Unicode value U+1F028 (and */ |
645 | /* the font contains it), use value 0x1F028 as the input value for */ |
646 | /* @FT_Get_Char_Index. */ |
647 | /* */ |
648 | /* FT_ENCODING_MS_SYMBOL :: */ |
649 | /* Microsoft Symbol encoding, used to encode mathematical symbols */ |
650 | /* and wingdings. For more information, see */ |
651 | /* `http://www.microsoft.com/typography/otspec/recom.htm', */ |
652 | /* `http://www.kostis.net/charsets/symbol.htm', and */ |
653 | /* `http://www.kostis.net/charsets/wingding.htm'. */ |
654 | /* */ |
655 | /* This encoding uses character codes from the PUA (Private Unicode */ |
656 | /* Area) in the range U+F020-U+F0FF. */ |
657 | /* */ |
658 | /* FT_ENCODING_SJIS :: */ |
659 | /* Shift JIS encoding for Japanese. More info at */ |
660 | /* `http://en.wikipedia.org/wiki/Shift_JIS'. See note on */ |
661 | /* multi-byte encodings below. */ |
662 | /* */ |
663 | /* FT_ENCODING_PRC :: */ |
664 | /* Corresponds to encoding systems mainly for Simplified Chinese as */ |
665 | /* used in People's Republic of China (PRC). The encoding layout */ |
666 | /* is based on GB~2312 and its supersets GBK and GB~18030. */ |
667 | /* */ |
668 | /* FT_ENCODING_BIG5 :: */ |
669 | /* Corresponds to an encoding system for Traditional Chinese as */ |
670 | /* used in Taiwan and Hong Kong. */ |
671 | /* */ |
672 | /* FT_ENCODING_WANSUNG :: */ |
673 | /* Corresponds to the Korean encoding system known as Extended */ |
674 | /* Wansung (MS Windows code page 949). */ |
675 | /* For more information see */ |
676 | /* `http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WindowsBestFit/bestfit949.txt'. */ |
677 | /* */ |
678 | /* FT_ENCODING_JOHAB :: */ |
679 | /* The Korean standard character set (KS~C 5601-1992), which */ |
680 | /* corresponds to MS Windows code page 1361. This character set */ |
681 | /* includes all possible Hangul character combinations. */ |
682 | /* */ |
683 | /* FT_ENCODING_ADOBE_LATIN_1 :: */ |
684 | /* Corresponds to a Latin-1 encoding as defined in a Type~1 */ |
685 | /* PostScript font. It is limited to 256 character codes. */ |
686 | /* */ |
687 | /* FT_ENCODING_ADOBE_STANDARD :: */ |
688 | /* Adobe Standard encoding, as found in Type~1, CFF, and */ |
689 | /* OpenType/CFF fonts. It is limited to 256 character codes. */ |
690 | /* */ |
691 | /* FT_ENCODING_ADOBE_EXPERT :: */ |
692 | /* Adobe Expert encoding, as found in Type~1, CFF, and OpenType/CFF */ |
693 | /* fonts. It is limited to 256 character codes. */ |
694 | /* */ |
695 | /* FT_ENCODING_ADOBE_CUSTOM :: */ |
696 | /* Corresponds to a custom encoding, as found in Type~1, CFF, and */ |
697 | /* OpenType/CFF fonts. It is limited to 256 character codes. */ |
698 | /* */ |
699 | /* FT_ENCODING_APPLE_ROMAN :: */ |
700 | /* Apple roman encoding. Many TrueType and OpenType fonts contain */ |
701 | /* a charmap for this 8-bit encoding, since older versions of Mac */ |
702 | /* OS are able to use it. */ |
703 | /* */ |
704 | /* FT_ENCODING_OLD_LATIN_2 :: */ |
705 | /* This value is deprecated and was neither used nor reported by */ |
706 | /* FreeType. Don't use or test for it. */ |
707 | /* */ |
708 | /* FT_ENCODING_MS_SJIS :: */ |
709 | /* Same as FT_ENCODING_SJIS. Deprecated. */ |
710 | /* */ |
711 | /* FT_ENCODING_MS_GB2312 :: */ |
712 | /* Same as FT_ENCODING_PRC. Deprecated. */ |
713 | /* */ |
714 | /* FT_ENCODING_MS_BIG5 :: */ |
715 | /* Same as FT_ENCODING_BIG5. Deprecated. */ |
716 | /* */ |
717 | /* FT_ENCODING_MS_WANSUNG :: */ |
718 | /* Same as FT_ENCODING_WANSUNG. Deprecated. */ |
719 | /* */ |
720 | /* FT_ENCODING_MS_JOHAB :: */ |
721 | /* Same as FT_ENCODING_JOHAB. Deprecated. */ |
722 | /* */ |
723 | /* <Note> */ |
724 | /* By default, FreeType automatically synthesizes a Unicode charmap */ |
725 | /* for PostScript fonts, using their glyph name dictionaries. */ |
726 | /* However, it also reports the encodings defined explicitly in the */ |
727 | /* font file, for the cases when they are needed, with the Adobe */ |
728 | /* values as well. */ |
729 | /* */ |
730 | /* FT_ENCODING_NONE is set by the BDF and PCF drivers if the charmap */ |
731 | /* is neither Unicode nor ISO-8859-1 (otherwise it is set to */ |
732 | /* FT_ENCODING_UNICODE). Use @FT_Get_BDF_Charset_ID to find out */ |
733 | /* which encoding is really present. If, for example, the */ |
734 | /* `cs_registry' field is `KOI8' and the `cs_encoding' field is `R', */ |
735 | /* the font is encoded in KOI8-R. */ |
736 | /* */ |
737 | /* FT_ENCODING_NONE is always set (with a single exception) by the */ |
738 | /* winfonts driver. Use @FT_Get_WinFNT_Header and examine the */ |
739 | /* `charset' field of the @FT_WinFNT_HeaderRec structure to find out */ |
740 | /* which encoding is really present. For example, */ |
741 | /* @FT_WinFNT_ID_CP1251 (204) means Windows code page 1251 (for */ |
742 | /* Russian). */ |
743 | /* */ |
744 | /* FT_ENCODING_NONE is set if `platform_id' is @TT_PLATFORM_MACINTOSH */ |
745 | /* and `encoding_id' is not `TT_MAC_ID_ROMAN' (otherwise it is set to */ |
746 | /* FT_ENCODING_APPLE_ROMAN). */ |
747 | /* */ |
748 | /* If `platform_id' is @TT_PLATFORM_MACINTOSH, use the function */ |
749 | /* @FT_Get_CMap_Language_ID to query the Mac language ID that may */ |
750 | /* be needed to be able to distinguish Apple encoding variants. See */ |
751 | /* */ |
752 | /* http://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/Readme.txt */ |
753 | /* */ |
754 | /* to get an idea how to do that. Basically, if the language ID */ |
755 | /* is~0, don't use it, otherwise subtract 1 from the language ID. */ |
756 | /* Then examine `encoding_id'. If, for example, `encoding_id' is */ |
757 | /* `TT_MAC_ID_ROMAN' and the language ID (minus~1) is */ |
758 | /* `TT_MAC_LANGID_GREEK', it is the Greek encoding, not Roman. */ |
759 | /* `TT_MAC_ID_ARABIC' with `TT_MAC_LANGID_FARSI' means the Farsi */ |
760 | /* variant the Arabic encoding. */ |
761 | /* */ |
762 | typedef enum FT_Encoding_ |
763 | { |
764 | FT_ENC_TAG( FT_ENCODING_NONE, 0, 0, 0, 0 ), |
765 | |
766 | FT_ENC_TAG( FT_ENCODING_MS_SYMBOL, 's', 'y', 'm', 'b' ), |
767 | FT_ENC_TAG( FT_ENCODING_UNICODE, 'u', 'n', 'i', 'c' ), |
768 | |
769 | FT_ENC_TAG( FT_ENCODING_SJIS, 's', 'j', 'i', 's' ), |
770 | FT_ENC_TAG( FT_ENCODING_PRC, 'g', 'b', ' ', ' ' ), |
771 | FT_ENC_TAG( FT_ENCODING_BIG5, 'b', 'i', 'g', '5' ), |
772 | FT_ENC_TAG( FT_ENCODING_WANSUNG, 'w', 'a', 'n', 's' ), |
773 | FT_ENC_TAG( FT_ENCODING_JOHAB, 'j', 'o', 'h', 'a' ), |
774 | |
775 | /* for backward compatibility */ |
776 | FT_ENCODING_GB2312 = FT_ENCODING_PRC, |
777 | FT_ENCODING_MS_SJIS = FT_ENCODING_SJIS, |
778 | FT_ENCODING_MS_GB2312 = FT_ENCODING_PRC, |
779 | FT_ENCODING_MS_BIG5 = FT_ENCODING_BIG5, |
780 | FT_ENCODING_MS_WANSUNG = FT_ENCODING_WANSUNG, |
781 | FT_ENCODING_MS_JOHAB = FT_ENCODING_JOHAB, |
782 | |
783 | FT_ENC_TAG( FT_ENCODING_ADOBE_STANDARD, 'A', 'D', 'O', 'B' ), |
784 | FT_ENC_TAG( FT_ENCODING_ADOBE_EXPERT, 'A', 'D', 'B', 'E' ), |
785 | FT_ENC_TAG( FT_ENCODING_ADOBE_CUSTOM, 'A', 'D', 'B', 'C' ), |
786 | FT_ENC_TAG( FT_ENCODING_ADOBE_LATIN_1, 'l', 'a', 't', '1' ), |
787 | |
788 | FT_ENC_TAG( FT_ENCODING_OLD_LATIN_2, 'l', 'a', 't', '2' ), |
789 | |
790 | FT_ENC_TAG( FT_ENCODING_APPLE_ROMAN, 'a', 'r', 'm', 'n' ) |
791 | |
792 | } FT_Encoding; |
793 | |
794 | |
795 | /* these constants are deprecated; use the corresponding `FT_Encoding' */ |
796 | /* values instead */ |
797 | #define ft_encoding_none FT_ENCODING_NONE |
798 | #define ft_encoding_unicode FT_ENCODING_UNICODE |
799 | #define ft_encoding_symbol FT_ENCODING_MS_SYMBOL |
800 | #define ft_encoding_latin_1 FT_ENCODING_ADOBE_LATIN_1 |
801 | #define ft_encoding_latin_2 FT_ENCODING_OLD_LATIN_2 |
802 | #define ft_encoding_sjis FT_ENCODING_SJIS |
803 | #define ft_encoding_gb2312 FT_ENCODING_PRC |
804 | #define ft_encoding_big5 FT_ENCODING_BIG5 |
805 | #define ft_encoding_wansung FT_ENCODING_WANSUNG |
806 | #define ft_encoding_johab FT_ENCODING_JOHAB |
807 | |
808 | #define ft_encoding_adobe_standard FT_ENCODING_ADOBE_STANDARD |
809 | #define ft_encoding_adobe_expert FT_ENCODING_ADOBE_EXPERT |
810 | #define ft_encoding_adobe_custom FT_ENCODING_ADOBE_CUSTOM |
811 | #define ft_encoding_apple_roman FT_ENCODING_APPLE_ROMAN |
812 | |
813 | |
814 | /*************************************************************************/ |
815 | /* */ |
816 | /* <Struct> */ |
817 | /* FT_CharMapRec */ |
818 | /* */ |
819 | /* <Description> */ |
820 | /* The base charmap structure. */ |
821 | /* */ |
822 | /* <Fields> */ |
823 | /* face :: A handle to the parent face object. */ |
824 | /* */ |
825 | /* encoding :: An @FT_Encoding tag identifying the charmap. Use */ |
826 | /* this with @FT_Select_Charmap. */ |
827 | /* */ |
828 | /* platform_id :: An ID number describing the platform for the */ |
829 | /* following encoding ID. This comes directly from */ |
830 | /* the TrueType specification and gets emulated for */ |
831 | /* other formats. */ |
832 | /* */ |
833 | /* encoding_id :: A platform specific encoding number. This also */ |
834 | /* comes from the TrueType specification and gets */ |
835 | /* emulated similarly. */ |
836 | /* */ |
837 | typedef struct FT_CharMapRec_ |
838 | { |
839 | FT_Face face; |
840 | FT_Encoding encoding; |
841 | FT_UShort platform_id; |
842 | FT_UShort encoding_id; |
843 | |
844 | } FT_CharMapRec; |
845 | |
846 | |
847 | /*************************************************************************/ |
848 | /*************************************************************************/ |
849 | /* */ |
850 | /* B A S E O B J E C T C L A S S E S */ |
851 | /* */ |
852 | /*************************************************************************/ |
853 | /*************************************************************************/ |
854 | |
855 | |
856 | /*************************************************************************/ |
857 | /* */ |
858 | /* <Type> */ |
859 | /* FT_Face_Internal */ |
860 | /* */ |
861 | /* <Description> */ |
862 | /* An opaque handle to an `FT_Face_InternalRec' structure that models */ |
863 | /* the private data of a given @FT_Face object. */ |
864 | /* */ |
865 | /* This structure might change between releases of FreeType~2 and is */ |
866 | /* not generally available to client applications. */ |
867 | /* */ |
868 | typedef struct FT_Face_InternalRec_* FT_Face_Internal; |
869 | |
870 | |
871 | /*************************************************************************/ |
872 | /* */ |
873 | /* <Struct> */ |
874 | /* FT_FaceRec */ |
875 | /* */ |
876 | /* <Description> */ |
877 | /* FreeType root face class structure. A face object models a */ |
878 | /* typeface in a font file. */ |
879 | /* */ |
880 | /* <Fields> */ |
881 | /* num_faces :: The number of faces in the font file. Some */ |
882 | /* font formats can have multiple faces in */ |
883 | /* a single font file. */ |
884 | /* */ |
885 | /* face_index :: This field holds two different values. */ |
886 | /* Bits 0-15 are the index of the face in the */ |
887 | /* font file (starting with value~0). They */ |
888 | /* are set to~0 if there is only one face in */ |
889 | /* the font file. */ |
890 | /* */ |
891 | /* Bits 16-30 are relevant to GX and OpenType */ |
892 | /* variation fonts only, holding the named */ |
893 | /* instance index for the current face index */ |
894 | /* (starting with value~1; value~0 indicates */ |
895 | /* font access without a named instance). For */ |
896 | /* non-variation fonts, bits 16-30 are */ |
897 | /* ignored. If we have the third named */ |
898 | /* instance of face~4, say, `face_index' is */ |
899 | /* set to 0x00030004. */ |
900 | /* */ |
901 | /* Bit 31 is always zero (this is, */ |
902 | /* `face_index' is always a positive value). */ |
903 | /* */ |
904 | /* face_flags :: A set of bit flags that give important */ |
905 | /* information about the face; see */ |
906 | /* @FT_FACE_FLAG_XXX for the details. */ |
907 | /* */ |
908 | /* style_flags :: The lower 16~bits contain a set of bit */ |
909 | /* flags indicating the style of the face; see */ |
910 | /* @FT_STYLE_FLAG_XXX for the details. Bits */ |
911 | /* 16-30 hold the number of named instances */ |
912 | /* available for the current face if we have a */ |
913 | /* GX or OpenType variation (sub)font. Bit 31 */ |
914 | /* is always zero (this is, `style_flags' is */ |
915 | /* always a positive value). Note that a */ |
916 | /* variation font has always at least one */ |
917 | /* named instance, namely the default */ |
918 | /* instance. */ |
919 | /* */ |
920 | /* num_glyphs :: The number of glyphs in the face. If the */ |
921 | /* face is scalable and has sbits (see */ |
922 | /* `num_fixed_sizes'), it is set to the number */ |
923 | /* of outline glyphs. */ |
924 | /* */ |
925 | /* For CID-keyed fonts (not in an SFNT */ |
926 | /* wrapper) this value gives the highest CID */ |
927 | /* used in the font. */ |
928 | /* */ |
929 | /* family_name :: The face's family name. This is an ASCII */ |
930 | /* string, usually in English, that describes */ |
931 | /* the typeface's family (like `Times New */ |
932 | /* Roman', `Bodoni', `Garamond', etc). This */ |
933 | /* is a least common denominator used to list */ |
934 | /* fonts. Some formats (TrueType & OpenType) */ |
935 | /* provide localized and Unicode versions of */ |
936 | /* this string. Applications should use the */ |
937 | /* format specific interface to access them. */ |
938 | /* Can be NULL (e.g., in fonts embedded in a */ |
939 | /* PDF file). */ |
940 | /* */ |
941 | /* In case the font doesn't provide a specific */ |
942 | /* family name entry, FreeType tries to */ |
943 | /* synthesize one, deriving it from other name */ |
944 | /* entries. */ |
945 | /* */ |
946 | /* style_name :: The face's style name. This is an ASCII */ |
947 | /* string, usually in English, that describes */ |
948 | /* the typeface's style (like `Italic', */ |
949 | /* `Bold', `Condensed', etc). Not all font */ |
950 | /* formats provide a style name, so this field */ |
951 | /* is optional, and can be set to NULL. As */ |
952 | /* for `family_name', some formats provide */ |
953 | /* localized and Unicode versions of this */ |
954 | /* string. Applications should use the format */ |
955 | /* specific interface to access them. */ |
956 | /* */ |
957 | /* num_fixed_sizes :: The number of bitmap strikes in the face. */ |
958 | /* Even if the face is scalable, there might */ |
959 | /* still be bitmap strikes, which are called */ |
960 | /* `sbits' in that case. */ |
961 | /* */ |
962 | /* available_sizes :: An array of @FT_Bitmap_Size for all bitmap */ |
963 | /* strikes in the face. It is set to NULL if */ |
964 | /* there is no bitmap strike. */ |
965 | /* */ |
966 | /* Note that FreeType tries to sanitize the */ |
967 | /* strike data since they are sometimes sloppy */ |
968 | /* or incorrect, but this can easily fail. */ |
969 | /* */ |
970 | /* num_charmaps :: The number of charmaps in the face. */ |
971 | /* */ |
972 | /* charmaps :: An array of the charmaps of the face. */ |
973 | /* */ |
974 | /* generic :: A field reserved for client uses. See the */ |
975 | /* @FT_Generic type description. */ |
976 | /* */ |
977 | /* bbox :: The font bounding box. Coordinates are */ |
978 | /* expressed in font units (see */ |
979 | /* `units_per_EM'). The box is large enough */ |
980 | /* to contain any glyph from the font. Thus, */ |
981 | /* `bbox.yMax' can be seen as the `maximum */ |
982 | /* ascender', and `bbox.yMin' as the `minimum */ |
983 | /* descender'. Only relevant for scalable */ |
984 | /* formats. */ |
985 | /* */ |
986 | /* Note that the bounding box might be off by */ |
987 | /* (at least) one pixel for hinted fonts. See */ |
988 | /* @FT_Size_Metrics for further discussion. */ |
989 | /* */ |
990 | /* units_per_EM :: The number of font units per EM square for */ |
991 | /* this face. This is typically 2048 for */ |
992 | /* TrueType fonts, and 1000 for Type~1 fonts. */ |
993 | /* Only relevant for scalable formats. */ |
994 | /* */ |
995 | /* ascender :: The typographic ascender of the face, */ |
996 | /* expressed in font units. For font formats */ |
997 | /* not having this information, it is set to */ |
998 | /* `bbox.yMax'. Only relevant for scalable */ |
999 | /* formats. */ |
1000 | /* */ |
1001 | /* descender :: The typographic descender of the face, */ |
1002 | /* expressed in font units. For font formats */ |
1003 | /* not having this information, it is set to */ |
1004 | /* `bbox.yMin'. Note that this field is */ |
1005 | /* negative for values below the baseline. */ |
1006 | /* Only relevant for scalable formats. */ |
1007 | /* */ |
1008 | /* height :: This value is the vertical distance */ |
1009 | /* between two consecutive baselines, */ |
1010 | /* expressed in font units. It is always */ |
1011 | /* positive. Only relevant for scalable */ |
1012 | /* formats. */ |
1013 | /* */ |
1014 | /* If you want the global glyph height, use */ |
1015 | /* `ascender - descender'. */ |
1016 | /* */ |
1017 | /* max_advance_width :: The maximum advance width, in font units, */ |
1018 | /* for all glyphs in this face. This can be */ |
1019 | /* used to make word wrapping computations */ |
1020 | /* faster. Only relevant for scalable */ |
1021 | /* formats. */ |
1022 | /* */ |
1023 | /* max_advance_height :: The maximum advance height, in font units, */ |
1024 | /* for all glyphs in this face. This is only */ |
1025 | /* relevant for vertical layouts, and is set */ |
1026 | /* to `height' for fonts that do not provide */ |
1027 | /* vertical metrics. Only relevant for */ |
1028 | /* scalable formats. */ |
1029 | /* */ |
1030 | /* underline_position :: The position, in font units, of the */ |
1031 | /* underline line for this face. It is the */ |
1032 | /* center of the underlining stem. Only */ |
1033 | /* relevant for scalable formats. */ |
1034 | /* */ |
1035 | /* underline_thickness :: The thickness, in font units, of the */ |
1036 | /* underline for this face. Only relevant for */ |
1037 | /* scalable formats. */ |
1038 | /* */ |
1039 | /* glyph :: The face's associated glyph slot(s). */ |
1040 | /* */ |
1041 | /* size :: The current active size for this face. */ |
1042 | /* */ |
1043 | /* charmap :: The current active charmap for this face. */ |
1044 | /* */ |
1045 | /* <Note> */ |
1046 | /* Fields may be changed after a call to @FT_Attach_File or */ |
1047 | /* @FT_Attach_Stream. */ |
1048 | /* */ |
1049 | /* For an OpenType variation font, the values of the following fields */ |
1050 | /* can change after a call to @FT_Set_Var_Design_Coordinates (and */ |
1051 | /* friends) if the font contains an `MVAR' table: `ascender', */ |
1052 | /* `descender', `height', `underline_position', and */ |
1053 | /* `underline_thickness'. */ |
1054 | /* */ |
1055 | typedef struct FT_FaceRec_ |
1056 | { |
1057 | FT_Long num_faces; |
1058 | FT_Long face_index; |
1059 | |
1060 | FT_Long face_flags; |
1061 | FT_Long style_flags; |
1062 | |
1063 | FT_Long num_glyphs; |
1064 | |
1065 | FT_String* family_name; |
1066 | FT_String* style_name; |
1067 | |
1068 | FT_Int num_fixed_sizes; |
1069 | FT_Bitmap_Size* available_sizes; |
1070 | |
1071 | FT_Int num_charmaps; |
1072 | FT_CharMap* charmaps; |
1073 | |
1074 | FT_Generic generic; |
1075 | |
1076 | /*# The following member variables (down to `underline_thickness') */ |
1077 | /*# are only relevant to scalable outlines; cf. @FT_Bitmap_Size */ |
1078 | /*# for bitmap fonts. */ |
1079 | FT_BBox bbox; |
1080 | |
1081 | FT_UShort units_per_EM; |
1082 | FT_Short ascender; |
1083 | FT_Short descender; |
1084 | FT_Short height; |
1085 | |
1086 | FT_Short max_advance_width; |
1087 | FT_Short max_advance_height; |
1088 | |
1089 | FT_Short underline_position; |
1090 | FT_Short underline_thickness; |
1091 | |
1092 | FT_GlyphSlot glyph; |
1093 | FT_Size size; |
1094 | FT_CharMap charmap; |
1095 | |
1096 | /*@private begin */ |
1097 | |
1098 | FT_Driver driver; |
1099 | FT_Memory memory; |
1100 | FT_Stream stream; |
1101 | |
1102 | FT_ListRec sizes_list; |
1103 | |
1104 | FT_Generic autohint; /* face-specific auto-hinter data */ |
1105 | void* extensions; /* unused */ |
1106 | |
1107 | FT_Face_Internal internal; |
1108 | |
1109 | /*@private end */ |
1110 | |
1111 | } FT_FaceRec; |
1112 | |
1113 | |
1114 | /*************************************************************************/ |
1115 | /* */ |
1116 | /* <Enum> */ |
1117 | /* FT_FACE_FLAG_XXX */ |
1118 | /* */ |
1119 | /* <Description> */ |
1120 | /* A list of bit flags used in the `face_flags' field of the */ |
1121 | /* @FT_FaceRec structure. They inform client applications of */ |
1122 | /* properties of the corresponding face. */ |
1123 | /* */ |
1124 | /* <Values> */ |
1125 | /* FT_FACE_FLAG_SCALABLE :: */ |
1126 | /* The face contains outline glyphs. Note that a face can contain */ |
1127 | /* bitmap strikes also, i.e., a face can have both this flag and */ |
1128 | /* @FT_FACE_FLAG_FIXED_SIZES set. */ |
1129 | /* */ |
1130 | /* FT_FACE_FLAG_FIXED_SIZES :: */ |
1131 | /* The face contains bitmap strikes. See also the */ |
1132 | /* `num_fixed_sizes' and `available_sizes' fields of @FT_FaceRec. */ |
1133 | /* */ |
1134 | /* FT_FACE_FLAG_FIXED_WIDTH :: */ |
1135 | /* The face contains fixed-width characters (like Courier, Lucida, */ |
1136 | /* MonoType, etc.). */ |
1137 | /* */ |
1138 | /* FT_FACE_FLAG_SFNT :: */ |
1139 | /* The face uses the SFNT storage scheme. For now, this means */ |
1140 | /* TrueType and OpenType. */ |
1141 | /* */ |
1142 | /* FT_FACE_FLAG_HORIZONTAL :: */ |
1143 | /* The face contains horizontal glyph metrics. This should be set */ |
1144 | /* for all common formats. */ |
1145 | /* */ |
1146 | /* FT_FACE_FLAG_VERTICAL :: */ |
1147 | /* The face contains vertical glyph metrics. This is only */ |
1148 | /* available in some formats, not all of them. */ |
1149 | /* */ |
1150 | /* FT_FACE_FLAG_KERNING :: */ |
1151 | /* The face contains kerning information. If set, the kerning */ |
1152 | /* distance can be retrieved using the function @FT_Get_Kerning. */ |
1153 | /* Otherwise the function always return the vector (0,0). Note */ |
1154 | /* that FreeType doesn't handle kerning data from the SFNT `GPOS' */ |
1155 | /* table (as present in many OpenType fonts). */ |
1156 | /* */ |
1157 | /* FT_FACE_FLAG_FAST_GLYPHS :: */ |
1158 | /* THIS FLAG IS DEPRECATED. DO NOT USE OR TEST IT. */ |
1159 | /* */ |
1160 | /* FT_FACE_FLAG_MULTIPLE_MASTERS :: */ |
1161 | /* The face contains multiple masters and is capable of */ |
1162 | /* interpolating between them. Supported formats are Adobe MM, */ |
1163 | /* TrueType GX, and OpenType variation fonts. */ |
1164 | /* */ |
1165 | /* See the multiple-masters specific API for details. */ |
1166 | /* */ |
1167 | /* FT_FACE_FLAG_GLYPH_NAMES :: */ |
1168 | /* The face contains glyph names, which can be retrieved using */ |
1169 | /* @FT_Get_Glyph_Name. Note that some TrueType fonts contain */ |
1170 | /* broken glyph name tables. Use the function */ |
1171 | /* @FT_Has_PS_Glyph_Names when needed. */ |
1172 | /* */ |
1173 | /* FT_FACE_FLAG_EXTERNAL_STREAM :: */ |
1174 | /* Used internally by FreeType to indicate that a face's stream was */ |
1175 | /* provided by the client application and should not be destroyed */ |
1176 | /* when @FT_Done_Face is called. Don't read or test this flag. */ |
1177 | /* */ |
1178 | /* FT_FACE_FLAG_HINTER :: */ |
1179 | /* The font driver has a hinting machine of its own. For example, */ |
1180 | /* with TrueType fonts, it makes sense to use data from the SFNT */ |
1181 | /* `gasp' table only if the native TrueType hinting engine (with */ |
1182 | /* the bytecode interpreter) is available and active. */ |
1183 | /* */ |
1184 | /* FT_FACE_FLAG_CID_KEYED :: */ |
1185 | /* The face is CID-keyed. In that case, the face is not accessed */ |
1186 | /* by glyph indices but by CID values. For subsetted CID-keyed */ |
1187 | /* fonts this has the consequence that not all index values are a */ |
1188 | /* valid argument to @FT_Load_Glyph. Only the CID values for which */ |
1189 | /* corresponding glyphs in the subsetted font exist make */ |
1190 | /* `FT_Load_Glyph' return successfully; in all other cases you get */ |
1191 | /* an `FT_Err_Invalid_Argument' error. */ |
1192 | /* */ |
1193 | /* Note that CID-keyed fonts that are in an SFNT wrapper (this is, */ |
1194 | /* all OpenType/CFF fonts) don't have this flag set since the */ |
1195 | /* glyphs are accessed in the normal way (using contiguous */ |
1196 | /* indices); the `CID-ness' isn't visible to the application. */ |
1197 | /* */ |
1198 | /* FT_FACE_FLAG_TRICKY :: */ |
1199 | /* The face is `tricky', this is, it always needs the font format's */ |
1200 | /* native hinting engine to get a reasonable result. A typical */ |
1201 | /* example is the old Chinese font `mingli.ttf' (but not */ |
1202 | /* `mingliu.ttc') that uses TrueType bytecode instructions to move */ |
1203 | /* and scale all of its subglyphs. */ |
1204 | /* */ |
1205 | /* It is not possible to auto-hint such fonts using */ |
1206 | /* @FT_LOAD_FORCE_AUTOHINT; it will also ignore */ |
1207 | /* @FT_LOAD_NO_HINTING. You have to set both @FT_LOAD_NO_HINTING */ |
1208 | /* and @FT_LOAD_NO_AUTOHINT to really disable hinting; however, you */ |
1209 | /* probably never want this except for demonstration purposes. */ |
1210 | /* */ |
1211 | /* Currently, there are about a dozen TrueType fonts in the list of */ |
1212 | /* tricky fonts; they are hard-coded in file `ttobjs.c'. */ |
1213 | /* */ |
1214 | /* FT_FACE_FLAG_COLOR :: */ |
1215 | /* The face has color glyph tables. To access color glyphs use */ |
1216 | /* @FT_LOAD_COLOR. */ |
1217 | /* */ |
1218 | #define FT_FACE_FLAG_SCALABLE ( 1L << 0 ) |
1219 | #define FT_FACE_FLAG_FIXED_SIZES ( 1L << 1 ) |
1220 | #define FT_FACE_FLAG_FIXED_WIDTH ( 1L << 2 ) |
1221 | #define FT_FACE_FLAG_SFNT ( 1L << 3 ) |
1222 | #define FT_FACE_FLAG_HORIZONTAL ( 1L << 4 ) |
1223 | #define FT_FACE_FLAG_VERTICAL ( 1L << 5 ) |
1224 | #define FT_FACE_FLAG_KERNING ( 1L << 6 ) |
1225 | #define FT_FACE_FLAG_FAST_GLYPHS ( 1L << 7 ) |
1226 | #define FT_FACE_FLAG_MULTIPLE_MASTERS ( 1L << 8 ) |
1227 | #define FT_FACE_FLAG_GLYPH_NAMES ( 1L << 9 ) |
1228 | #define FT_FACE_FLAG_EXTERNAL_STREAM ( 1L << 10 ) |
1229 | #define FT_FACE_FLAG_HINTER ( 1L << 11 ) |
1230 | #define FT_FACE_FLAG_CID_KEYED ( 1L << 12 ) |
1231 | #define FT_FACE_FLAG_TRICKY ( 1L << 13 ) |
1232 | #define FT_FACE_FLAG_COLOR ( 1L << 14 ) |
1233 | |
1234 | |
1235 | /************************************************************************* |
1236 | * |
1237 | * @macro: |
1238 | * FT_HAS_HORIZONTAL( face ) |
1239 | * |
1240 | * @description: |
1241 | * A macro that returns true whenever a face object contains |
1242 | * horizontal metrics (this is true for all font formats though). |
1243 | * |
1244 | * @also: |
1245 | * @FT_HAS_VERTICAL can be used to check for vertical metrics. |
1246 | * |
1247 | */ |
1248 | #define FT_HAS_HORIZONTAL( face ) \ |
1249 | ( (face)->face_flags & FT_FACE_FLAG_HORIZONTAL ) |
1250 | |
1251 | |
1252 | /************************************************************************* |
1253 | * |
1254 | * @macro: |
1255 | * FT_HAS_VERTICAL( face ) |
1256 | * |
1257 | * @description: |
1258 | * A macro that returns true whenever a face object contains real |
1259 | * vertical metrics (and not only synthesized ones). |
1260 | * |
1261 | */ |
1262 | #define FT_HAS_VERTICAL( face ) \ |
1263 | ( (face)->face_flags & FT_FACE_FLAG_VERTICAL ) |
1264 | |
1265 | |
1266 | /************************************************************************* |
1267 | * |
1268 | * @macro: |
1269 | * FT_HAS_KERNING( face ) |
1270 | * |
1271 | * @description: |
1272 | * A macro that returns true whenever a face object contains kerning |
1273 | * data that can be accessed with @FT_Get_Kerning. |
1274 | * |
1275 | */ |
1276 | #define FT_HAS_KERNING( face ) \ |
1277 | ( (face)->face_flags & FT_FACE_FLAG_KERNING ) |
1278 | |
1279 | |
1280 | /************************************************************************* |
1281 | * |
1282 | * @macro: |
1283 | * FT_IS_SCALABLE( face ) |
1284 | * |
1285 | * @description: |
1286 | * A macro that returns true whenever a face object contains a scalable |
1287 | * font face (true for TrueType, Type~1, Type~42, CID, OpenType/CFF, |
1288 | * and PFR font formats). |
1289 | * |
1290 | */ |
1291 | #define FT_IS_SCALABLE( face ) \ |
1292 | ( (face)->face_flags & FT_FACE_FLAG_SCALABLE ) |
1293 | |
1294 | |
1295 | /************************************************************************* |
1296 | * |
1297 | * @macro: |
1298 | * FT_IS_SFNT( face ) |
1299 | * |
1300 | * @description: |
1301 | * A macro that returns true whenever a face object contains a font |
1302 | * whose format is based on the SFNT storage scheme. This usually |
1303 | * means: TrueType fonts, OpenType fonts, as well as SFNT-based embedded |
1304 | * bitmap fonts. |
1305 | * |
1306 | * If this macro is true, all functions defined in @FT_SFNT_NAMES_H and |
1307 | * @FT_TRUETYPE_TABLES_H are available. |
1308 | * |
1309 | */ |
1310 | #define FT_IS_SFNT( face ) \ |
1311 | ( (face)->face_flags & FT_FACE_FLAG_SFNT ) |
1312 | |
1313 | |
1314 | /************************************************************************* |
1315 | * |
1316 | * @macro: |
1317 | * FT_IS_FIXED_WIDTH( face ) |
1318 | * |
1319 | * @description: |
1320 | * A macro that returns true whenever a face object contains a font face |
1321 | * that contains fixed-width (or `monospace', `fixed-pitch', etc.) |
1322 | * glyphs. |
1323 | * |
1324 | */ |
1325 | #define FT_IS_FIXED_WIDTH( face ) \ |
1326 | ( (face)->face_flags & FT_FACE_FLAG_FIXED_WIDTH ) |
1327 | |
1328 | |
1329 | /************************************************************************* |
1330 | * |
1331 | * @macro: |
1332 | * FT_HAS_FIXED_SIZES( face ) |
1333 | * |
1334 | * @description: |
1335 | * A macro that returns true whenever a face object contains some |
1336 | * embedded bitmaps. See the `available_sizes' field of the |
1337 | * @FT_FaceRec structure. |
1338 | * |
1339 | */ |
1340 | #define FT_HAS_FIXED_SIZES( face ) \ |
1341 | ( (face)->face_flags & FT_FACE_FLAG_FIXED_SIZES ) |
1342 | |
1343 | |
1344 | /************************************************************************* |
1345 | * |
1346 | * @macro: |
1347 | * FT_HAS_FAST_GLYPHS( face ) |
1348 | * |
1349 | * @description: |
1350 | * Deprecated. |
1351 | * |
1352 | */ |
1353 | #define FT_HAS_FAST_GLYPHS( face ) 0 |
1354 | |
1355 | |
1356 | /************************************************************************* |
1357 | * |
1358 | * @macro: |
1359 | * FT_HAS_GLYPH_NAMES( face ) |
1360 | * |
1361 | * @description: |
1362 | * A macro that returns true whenever a face object contains some glyph |
1363 | * names that can be accessed through @FT_Get_Glyph_Name. |
1364 | * |
1365 | */ |
1366 | #define FT_HAS_GLYPH_NAMES( face ) \ |
1367 | ( (face)->face_flags & FT_FACE_FLAG_GLYPH_NAMES ) |
1368 | |
1369 | |
1370 | /************************************************************************* |
1371 | * |
1372 | * @macro: |
1373 | * FT_HAS_MULTIPLE_MASTERS( face ) |
1374 | * |
1375 | * @description: |
1376 | * A macro that returns true whenever a face object contains some |
1377 | * multiple masters. The functions provided by @FT_MULTIPLE_MASTERS_H |
1378 | * are then available to choose the exact design you want. |
1379 | * |
1380 | */ |
1381 | #define FT_HAS_MULTIPLE_MASTERS( face ) \ |
1382 | ( (face)->face_flags & FT_FACE_FLAG_MULTIPLE_MASTERS ) |
1383 | |
1384 | |
1385 | /************************************************************************* |
1386 | * |
1387 | * @macro: |
1388 | * FT_IS_NAMED_INSTANCE( face ) |
1389 | * |
1390 | * @description: |
1391 | * A macro that returns true whenever a face object is a named instance |
1392 | * of a GX or OpenType variation font. |
1393 | * |
1394 | */ |
1395 | #define FT_IS_NAMED_INSTANCE( face ) \ |
1396 | ( (face)->face_index & 0x7FFF0000L ) |
1397 | |
1398 | |
1399 | /************************************************************************* |
1400 | * |
1401 | * @macro: |
1402 | * FT_IS_CID_KEYED( face ) |
1403 | * |
1404 | * @description: |
1405 | * A macro that returns true whenever a face object contains a CID-keyed |
1406 | * font. See the discussion of @FT_FACE_FLAG_CID_KEYED for more |
1407 | * details. |
1408 | * |
1409 | * If this macro is true, all functions defined in @FT_CID_H are |
1410 | * available. |
1411 | * |
1412 | */ |
1413 | #define FT_IS_CID_KEYED( face ) \ |
1414 | ( (face)->face_flags & FT_FACE_FLAG_CID_KEYED ) |
1415 | |
1416 | |
1417 | /************************************************************************* |
1418 | * |
1419 | * @macro: |
1420 | * FT_IS_TRICKY( face ) |
1421 | * |
1422 | * @description: |
1423 | * A macro that returns true whenever a face represents a `tricky' font. |
1424 | * See the discussion of @FT_FACE_FLAG_TRICKY for more details. |
1425 | * |
1426 | */ |
1427 | #define FT_IS_TRICKY( face ) \ |
1428 | ( (face)->face_flags & FT_FACE_FLAG_TRICKY ) |
1429 | |
1430 | |
1431 | /************************************************************************* |
1432 | * |
1433 | * @macro: |
1434 | * FT_HAS_COLOR( face ) |
1435 | * |
1436 | * @description: |
1437 | * A macro that returns true whenever a face object contains |
1438 | * tables for color glyphs. |
1439 | * |
1440 | */ |
1441 | #define FT_HAS_COLOR( face ) \ |
1442 | ( (face)->face_flags & FT_FACE_FLAG_COLOR ) |
1443 | |
1444 | |
1445 | /*************************************************************************/ |
1446 | /* */ |
1447 | /* <Const> */ |
1448 | /* FT_STYLE_FLAG_XXX */ |
1449 | /* */ |
1450 | /* <Description> */ |
1451 | /* A list of bit flags to indicate the style of a given face. These */ |
1452 | /* are used in the `style_flags' field of @FT_FaceRec. */ |
1453 | /* */ |
1454 | /* <Values> */ |
1455 | /* FT_STYLE_FLAG_ITALIC :: */ |
1456 | /* The face style is italic or oblique. */ |
1457 | /* */ |
1458 | /* FT_STYLE_FLAG_BOLD :: */ |
1459 | /* The face is bold. */ |
1460 | /* */ |
1461 | /* <Note> */ |
1462 | /* The style information as provided by FreeType is very basic. More */ |
1463 | /* details are beyond the scope and should be done on a higher level */ |
1464 | /* (for example, by analyzing various fields of the `OS/2' table in */ |
1465 | /* SFNT based fonts). */ |
1466 | /* */ |
1467 | #define FT_STYLE_FLAG_ITALIC ( 1 << 0 ) |
1468 | #define FT_STYLE_FLAG_BOLD ( 1 << 1 ) |
1469 | |
1470 | |
1471 | /*************************************************************************/ |
1472 | /* */ |
1473 | /* <Type> */ |
1474 | /* FT_Size_Internal */ |
1475 | /* */ |
1476 | /* <Description> */ |
1477 | /* An opaque handle to an `FT_Size_InternalRec' structure, used to */ |
1478 | /* model private data of a given @FT_Size object. */ |
1479 | /* */ |
1480 | typedef struct FT_Size_InternalRec_* FT_Size_Internal; |
1481 | |
1482 | |
1483 | /*************************************************************************/ |
1484 | /* */ |
1485 | /* <Struct> */ |
1486 | /* FT_Size_Metrics */ |
1487 | /* */ |
1488 | /* <Description> */ |
1489 | /* The size metrics structure gives the metrics of a size object. */ |
1490 | /* */ |
1491 | /* <Fields> */ |
1492 | /* x_ppem :: The width of the scaled EM square in pixels, hence */ |
1493 | /* the term `ppem' (pixels per EM). It is also */ |
1494 | /* referred to as `nominal width'. */ |
1495 | /* */ |
1496 | /* y_ppem :: The height of the scaled EM square in pixels, */ |
1497 | /* hence the term `ppem' (pixels per EM). It is also */ |
1498 | /* referred to as `nominal height'. */ |
1499 | /* */ |
1500 | /* x_scale :: A 16.16 fractional scaling value to convert */ |
1501 | /* horizontal metrics from font units to 26.6 */ |
1502 | /* fractional pixels. Only relevant for scalable */ |
1503 | /* font formats. */ |
1504 | /* */ |
1505 | /* y_scale :: A 16.16 fractional scaling value to convert */ |
1506 | /* vertical metrics from font units to 26.6 */ |
1507 | /* fractional pixels. Only relevant for scalable */ |
1508 | /* font formats. */ |
1509 | /* */ |
1510 | /* ascender :: The ascender in 26.6 fractional pixels, rounded up */ |
1511 | /* to an integer value. See @FT_FaceRec for the */ |
1512 | /* details. */ |
1513 | /* */ |
1514 | /* descender :: The descender in 26.6 fractional pixels, rounded */ |
1515 | /* down to an integer value. See @FT_FaceRec for the */ |
1516 | /* details. */ |
1517 | /* */ |
1518 | /* height :: The height in 26.6 fractional pixels, rounded to */ |
1519 | /* an integer value. See @FT_FaceRec for the */ |
1520 | /* details. */ |
1521 | /* */ |
1522 | /* max_advance :: The maximum advance width in 26.6 fractional */ |
1523 | /* pixels, rounded to an integer value. See */ |
1524 | /* @FT_FaceRec for the details. */ |
1525 | /* */ |
1526 | /* <Note> */ |
1527 | /* The scaling values, if relevant, are determined first during a */ |
1528 | /* size changing operation. The remaining fields are then set by the */ |
1529 | /* driver. For scalable formats, they are usually set to scaled */ |
1530 | /* values of the corresponding fields in @FT_FaceRec. Some values */ |
1531 | /* like ascender or descender are rounded for historical reasons; */ |
1532 | /* more precise values (for outline fonts) can be derived by scaling */ |
1533 | /* the corresponding @FT_FaceRec values manually, with code similar */ |
1534 | /* to the following. */ |
1535 | /* */ |
1536 | /* { */ |
1537 | /* scaled_ascender = FT_MulFix( face->root.ascender, */ |
1538 | /* size_metrics->y_scale ); */ |
1539 | /* } */ |
1540 | /* */ |
1541 | /* Note that due to glyph hinting and the selected rendering mode */ |
1542 | /* these values are usually not exact; consequently, they must be */ |
1543 | /* treated as unreliable with an error margin of at least one pixel! */ |
1544 | /* */ |
1545 | /* Indeed, the only way to get the exact metrics is to render _all_ */ |
1546 | /* glyphs. As this would be a definite performance hit, it is up to */ |
1547 | /* client applications to perform such computations. */ |
1548 | /* */ |
1549 | /* The `FT_Size_Metrics' structure is valid for bitmap fonts also. */ |
1550 | /* */ |
1551 | typedef struct FT_Size_Metrics_ |
1552 | { |
1553 | FT_UShort x_ppem; /* horizontal pixels per EM */ |
1554 | FT_UShort y_ppem; /* vertical pixels per EM */ |
1555 | |
1556 | FT_Fixed x_scale; /* scaling values used to convert font */ |
1557 | FT_Fixed y_scale; /* units to 26.6 fractional pixels */ |
1558 | |
1559 | FT_Pos ascender; /* ascender in 26.6 frac. pixels */ |
1560 | FT_Pos descender; /* descender in 26.6 frac. pixels */ |
1561 | FT_Pos height; /* text height in 26.6 frac. pixels */ |
1562 | FT_Pos max_advance; /* max horizontal advance, in 26.6 pixels */ |
1563 | |
1564 | } FT_Size_Metrics; |
1565 | |
1566 | |
1567 | /*************************************************************************/ |
1568 | /* */ |
1569 | /* <Struct> */ |
1570 | /* FT_SizeRec */ |
1571 | /* */ |
1572 | /* <Description> */ |
1573 | /* FreeType root size class structure. A size object models a face */ |
1574 | /* object at a given size. */ |
1575 | /* */ |
1576 | /* <Fields> */ |
1577 | /* face :: Handle to the parent face object. */ |
1578 | /* */ |
1579 | /* generic :: A typeless pointer, unused by the FreeType library or */ |
1580 | /* any of its drivers. It can be used by client */ |
1581 | /* applications to link their own data to each size */ |
1582 | /* object. */ |
1583 | /* */ |
1584 | /* metrics :: Metrics for this size object. This field is read-only. */ |
1585 | /* */ |
1586 | typedef struct FT_SizeRec_ |
1587 | { |
1588 | FT_Face face; /* parent face object */ |
1589 | FT_Generic generic; /* generic pointer for client uses */ |
1590 | FT_Size_Metrics metrics; /* size metrics */ |
1591 | FT_Size_Internal internal; |
1592 | |
1593 | } FT_SizeRec; |
1594 | |
1595 | |
1596 | /*************************************************************************/ |
1597 | /* */ |
1598 | /* <Struct> */ |
1599 | /* FT_SubGlyph */ |
1600 | /* */ |
1601 | /* <Description> */ |
1602 | /* The subglyph structure is an internal object used to describe */ |
1603 | /* subglyphs (for example, in the case of composites). */ |
1604 | /* */ |
1605 | /* <Note> */ |
1606 | /* The subglyph implementation is not part of the high-level API, */ |
1607 | /* hence the forward structure declaration. */ |
1608 | /* */ |
1609 | /* You can however retrieve subglyph information with */ |
1610 | /* @FT_Get_SubGlyph_Info. */ |
1611 | /* */ |
1612 | typedef struct FT_SubGlyphRec_* FT_SubGlyph; |
1613 | |
1614 | |
1615 | /*************************************************************************/ |
1616 | /* */ |
1617 | /* <Type> */ |
1618 | /* FT_Slot_Internal */ |
1619 | /* */ |
1620 | /* <Description> */ |
1621 | /* An opaque handle to an `FT_Slot_InternalRec' structure, used to */ |
1622 | /* model private data of a given @FT_GlyphSlot object. */ |
1623 | /* */ |
1624 | typedef struct FT_Slot_InternalRec_* FT_Slot_Internal; |
1625 | |
1626 | |
1627 | /*************************************************************************/ |
1628 | /* */ |
1629 | /* <Struct> */ |
1630 | /* FT_GlyphSlotRec */ |
1631 | /* */ |
1632 | /* <Description> */ |
1633 | /* FreeType root glyph slot class structure. A glyph slot is a */ |
1634 | /* container where individual glyphs can be loaded, be they in */ |
1635 | /* outline or bitmap format. */ |
1636 | /* */ |
1637 | /* <Fields> */ |
1638 | /* library :: A handle to the FreeType library instance */ |
1639 | /* this slot belongs to. */ |
1640 | /* */ |
1641 | /* face :: A handle to the parent face object. */ |
1642 | /* */ |
1643 | /* next :: In some cases (like some font tools), several */ |
1644 | /* glyph slots per face object can be a good */ |
1645 | /* thing. As this is rare, the glyph slots are */ |
1646 | /* listed through a direct, single-linked list */ |
1647 | /* using its `next' field. */ |
1648 | /* */ |
1649 | /* generic :: A typeless pointer unused by the FreeType */ |
1650 | /* library or any of its drivers. It can be */ |
1651 | /* used by client applications to link their own */ |
1652 | /* data to each glyph slot object. */ |
1653 | /* */ |
1654 | /* metrics :: The metrics of the last loaded glyph in the */ |
1655 | /* slot. The returned values depend on the last */ |
1656 | /* load flags (see the @FT_Load_Glyph API */ |
1657 | /* function) and can be expressed either in 26.6 */ |
1658 | /* fractional pixels or font units. */ |
1659 | /* */ |
1660 | /* Note that even when the glyph image is */ |
1661 | /* transformed, the metrics are not. */ |
1662 | /* */ |
1663 | /* linearHoriAdvance :: The advance width of the unhinted glyph. */ |
1664 | /* Its value is expressed in 16.16 fractional */ |
1665 | /* pixels, unless @FT_LOAD_LINEAR_DESIGN is set */ |
1666 | /* when loading the glyph. This field can be */ |
1667 | /* important to perform correct WYSIWYG layout. */ |
1668 | /* Only relevant for outline glyphs. */ |
1669 | /* */ |
1670 | /* linearVertAdvance :: The advance height of the unhinted glyph. */ |
1671 | /* Its value is expressed in 16.16 fractional */ |
1672 | /* pixels, unless @FT_LOAD_LINEAR_DESIGN is set */ |
1673 | /* when loading the glyph. This field can be */ |
1674 | /* important to perform correct WYSIWYG layout. */ |
1675 | /* Only relevant for outline glyphs. */ |
1676 | /* */ |
1677 | /* advance :: This shorthand is, depending on */ |
1678 | /* @FT_LOAD_IGNORE_TRANSFORM, the transformed */ |
1679 | /* (hinted) advance width for the glyph, in 26.6 */ |
1680 | /* fractional pixel format. As specified with */ |
1681 | /* @FT_LOAD_VERTICAL_LAYOUT, it uses either the */ |
1682 | /* `horiAdvance' or the `vertAdvance' value of */ |
1683 | /* `metrics' field. */ |
1684 | /* */ |
1685 | /* format :: This field indicates the format of the image */ |
1686 | /* contained in the glyph slot. Typically */ |
1687 | /* @FT_GLYPH_FORMAT_BITMAP, */ |
1688 | /* @FT_GLYPH_FORMAT_OUTLINE, or */ |
1689 | /* @FT_GLYPH_FORMAT_COMPOSITE, but other values */ |
1690 | /* are possible. */ |
1691 | /* */ |
1692 | /* bitmap :: This field is used as a bitmap descriptor */ |
1693 | /* when the slot format is */ |
1694 | /* @FT_GLYPH_FORMAT_BITMAP. Note that the */ |
1695 | /* address and content of the bitmap buffer can */ |
1696 | /* change between calls of @FT_Load_Glyph and a */ |
1697 | /* few other functions. */ |
1698 | /* */ |
1699 | /* bitmap_left :: The bitmap's left bearing expressed in */ |
1700 | /* integer pixels. Only valid if the format is */ |
1701 | /* @FT_GLYPH_FORMAT_BITMAP, this is, if the */ |
1702 | /* glyph slot contains a bitmap. */ |
1703 | /* */ |
1704 | /* bitmap_top :: The bitmap's top bearing expressed in integer */ |
1705 | /* pixels. This is the distance from the */ |
1706 | /* baseline to the top-most glyph scanline, */ |
1707 | /* upwards y~coordinates being *positive*. */ |
1708 | /* */ |
1709 | /* outline :: The outline descriptor for the current glyph */ |
1710 | /* image if its format is */ |
1711 | /* @FT_GLYPH_FORMAT_OUTLINE. Once a glyph is */ |
1712 | /* loaded, `outline' can be transformed, */ |
1713 | /* distorted, emboldened, etc. However, it must */ |
1714 | /* not be freed. */ |
1715 | /* */ |
1716 | /* num_subglyphs :: The number of subglyphs in a composite glyph. */ |
1717 | /* This field is only valid for the composite */ |
1718 | /* glyph format that should normally only be */ |
1719 | /* loaded with the @FT_LOAD_NO_RECURSE flag. */ |
1720 | /* */ |
1721 | /* subglyphs :: An array of subglyph descriptors for */ |
1722 | /* composite glyphs. There are `num_subglyphs' */ |
1723 | /* elements in there. Currently internal to */ |
1724 | /* FreeType. */ |
1725 | /* */ |
1726 | /* control_data :: Certain font drivers can also return the */ |
1727 | /* control data for a given glyph image (e.g. */ |
1728 | /* TrueType bytecode, Type~1 charstrings, etc.). */ |
1729 | /* This field is a pointer to such data; it is */ |
1730 | /* currently internal to FreeType. */ |
1731 | /* */ |
1732 | /* control_len :: This is the length in bytes of the control */ |
1733 | /* data. Currently internal to FreeType. */ |
1734 | /* */ |
1735 | /* other :: Reserved. */ |
1736 | /* */ |
1737 | /* lsb_delta :: The difference between hinted and unhinted */ |
1738 | /* left side bearing while auto-hinting is */ |
1739 | /* active. Zero otherwise. */ |
1740 | /* */ |
1741 | /* rsb_delta :: The difference between hinted and unhinted */ |
1742 | /* right side bearing while auto-hinting is */ |
1743 | /* active. Zero otherwise. */ |
1744 | /* */ |
1745 | /* <Note> */ |
1746 | /* If @FT_Load_Glyph is called with default flags (see */ |
1747 | /* @FT_LOAD_DEFAULT) the glyph image is loaded in the glyph slot in */ |
1748 | /* its native format (e.g., an outline glyph for TrueType and Type~1 */ |
1749 | /* formats). */ |
1750 | /* */ |
1751 | /* This image can later be converted into a bitmap by calling */ |
1752 | /* @FT_Render_Glyph. This function searches the current renderer for */ |
1753 | /* the native image's format, then invokes it. */ |
1754 | /* */ |
1755 | /* The renderer is in charge of transforming the native image through */ |
1756 | /* the slot's face transformation fields, then converting it into a */ |
1757 | /* bitmap that is returned in `slot->bitmap'. */ |
1758 | /* */ |
1759 | /* Note that `slot->bitmap_left' and `slot->bitmap_top' are also used */ |
1760 | /* to specify the position of the bitmap relative to the current pen */ |
1761 | /* position (e.g., coordinates (0,0) on the baseline). Of course, */ |
1762 | /* `slot->format' is also changed to @FT_GLYPH_FORMAT_BITMAP. */ |
1763 | /* */ |
1764 | /* Here is a small pseudo code fragment that shows how to use */ |
1765 | /* `lsb_delta' and `rsb_delta' to do fractional positioning of */ |
1766 | /* glyphs: */ |
1767 | /* */ |
1768 | /* { */ |
1769 | /* FT_GlyphSlot slot = face->glyph; */ |
1770 | /* FT_Pos origin_x = 0; */ |
1771 | /* */ |
1772 | /* */ |
1773 | /* for all glyphs do */ |
1774 | /* <load glyph with `FT_Load_Glyph'> */ |
1775 | /* */ |
1776 | /* FT_Outline_Translate( slot->outline, origin_x & 63, 0 ); */ |
1777 | /* */ |
1778 | /* <save glyph image, or render glyph, or ...> */ |
1779 | /* */ |
1780 | /* <compute kern between current and next glyph */ |
1781 | /* and add it to `origin_x'> */ |
1782 | /* */ |
1783 | /* origin_x += slot->advance.x; */ |
1784 | /* origin_x += slot->rsb_delta - slot->lsb_delta; */ |
1785 | /* endfor */ |
1786 | /* } */ |
1787 | /* */ |
1788 | /* Here is another small pseudo code fragment that shows how to use */ |
1789 | /* `lsb_delta' and `rsb_delta' to improve integer positioning of */ |
1790 | /* glyphs: */ |
1791 | /* */ |
1792 | /* { */ |
1793 | /* FT_GlyphSlot slot = face->glyph; */ |
1794 | /* FT_Pos origin_x = 0; */ |
1795 | /* FT_Pos prev_rsb_delta = 0; */ |
1796 | /* */ |
1797 | /* */ |
1798 | /* for all glyphs do */ |
1799 | /* <compute kern between current and previous glyph */ |
1800 | /* and add it to `origin_x'> */ |
1801 | /* */ |
1802 | /* <load glyph with `FT_Load_Glyph'> */ |
1803 | /* */ |
1804 | /* if ( prev_rsb_delta - slot->lsb_delta > 32 ) */ |
1805 | /* origin_x -= 64; */ |
1806 | /* else if ( prev_rsb_delta - slot->lsb_delta < -31 ) */ |
1807 | /* origin_x += 64; */ |
1808 | /* */ |
1809 | /* prev_rsb_delta = slot->rsb_delta; */ |
1810 | /* */ |
1811 | /* <save glyph image, or render glyph, or ...> */ |
1812 | /* */ |
1813 | /* origin_x += slot->advance.x; */ |
1814 | /* endfor */ |
1815 | /* } */ |
1816 | /* */ |
1817 | /* If you use strong auto-hinting, you *must* apply these delta */ |
1818 | /* values! Otherwise you will experience far too large inter-glyph */ |
1819 | /* spacing at small rendering sizes in most cases. Note that it */ |
1820 | /* doesn't harm to use the above code for other hinting modes also, */ |
1821 | /* since the delta values are zero then. */ |
1822 | /* */ |
1823 | typedef struct FT_GlyphSlotRec_ |
1824 | { |
1825 | FT_Library library; |
1826 | FT_Face face; |
1827 | FT_GlyphSlot next; |
1828 | FT_UInt reserved; /* retained for binary compatibility */ |
1829 | FT_Generic generic; |
1830 | |
1831 | FT_Glyph_Metrics metrics; |
1832 | FT_Fixed linearHoriAdvance; |
1833 | FT_Fixed linearVertAdvance; |
1834 | FT_Vector advance; |
1835 | |
1836 | FT_Glyph_Format format; |
1837 | |
1838 | FT_Bitmap bitmap; |
1839 | FT_Int bitmap_left; |
1840 | FT_Int bitmap_top; |
1841 | |
1842 | FT_Outline outline; |
1843 | |
1844 | FT_UInt num_subglyphs; |
1845 | FT_SubGlyph subglyphs; |
1846 | |
1847 | void* control_data; |
1848 | long control_len; |
1849 | |
1850 | FT_Pos lsb_delta; |
1851 | FT_Pos rsb_delta; |
1852 | |
1853 | void* other; |
1854 | |
1855 | FT_Slot_Internal internal; |
1856 | |
1857 | } FT_GlyphSlotRec; |
1858 | |
1859 | |
1860 | /*************************************************************************/ |
1861 | /*************************************************************************/ |
1862 | /* */ |
1863 | /* F U N C T I O N S */ |
1864 | /* */ |
1865 | /*************************************************************************/ |
1866 | /*************************************************************************/ |
1867 | |
1868 | |
1869 | /*************************************************************************/ |
1870 | /* */ |
1871 | /* <Function> */ |
1872 | /* FT_Init_FreeType */ |
1873 | /* */ |
1874 | /* <Description> */ |
1875 | /* Initialize a new FreeType library object. The set of modules */ |
1876 | /* that are registered by this function is determined at build time. */ |
1877 | /* */ |
1878 | /* <Output> */ |
1879 | /* alibrary :: A handle to a new library object. */ |
1880 | /* */ |
1881 | /* <Return> */ |
1882 | /* FreeType error code. 0~means success. */ |
1883 | /* */ |
1884 | /* <Note> */ |
1885 | /* In case you want to provide your own memory allocating routines, */ |
1886 | /* use @FT_New_Library instead, followed by a call to */ |
1887 | /* @FT_Add_Default_Modules (or a series of calls to @FT_Add_Module) */ |
1888 | /* and @FT_Set_Default_Properties. */ |
1889 | /* */ |
1890 | /* See the documentation of @FT_Library and @FT_Face for */ |
1891 | /* multi-threading issues. */ |
1892 | /* */ |
1893 | /* If you need reference-counting (cf. @FT_Reference_Library), use */ |
1894 | /* @FT_New_Library and @FT_Done_Library. */ |
1895 | /* */ |
1896 | /* If compilation option FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES is */ |
1897 | /* set, this function reads the `FREETYPE_PROPERTIES' environment */ |
1898 | /* variable to control driver properties. See sections @auto_hinter, */ |
1899 | /* @cff_driver, @pcf_driver, and @tt_driver for more. */ |
1900 | /* */ |
1901 | FT_EXPORT( FT_Error ) |
1902 | FT_Init_FreeType( FT_Library *alibrary ); |
1903 | |
1904 | |
1905 | /*************************************************************************/ |
1906 | /* */ |
1907 | /* <Function> */ |
1908 | /* FT_Done_FreeType */ |
1909 | /* */ |
1910 | /* <Description> */ |
1911 | /* Destroy a given FreeType library object and all of its children, */ |
1912 | /* including resources, drivers, faces, sizes, etc. */ |
1913 | /* */ |
1914 | /* <Input> */ |
1915 | /* library :: A handle to the target library object. */ |
1916 | /* */ |
1917 | /* <Return> */ |
1918 | /* FreeType error code. 0~means success. */ |
1919 | /* */ |
1920 | FT_EXPORT( FT_Error ) |
1921 | FT_Done_FreeType( FT_Library library ); |
1922 | |
1923 | |
1924 | /*************************************************************************/ |
1925 | /* */ |
1926 | /* <Enum> */ |
1927 | /* FT_OPEN_XXX */ |
1928 | /* */ |
1929 | /* <Description> */ |
1930 | /* A list of bit field constants used within the `flags' field of the */ |
1931 | /* @FT_Open_Args structure. */ |
1932 | /* */ |
1933 | /* <Values> */ |
1934 | /* FT_OPEN_MEMORY :: This is a memory-based stream. */ |
1935 | /* */ |
1936 | /* FT_OPEN_STREAM :: Copy the stream from the `stream' field. */ |
1937 | /* */ |
1938 | /* FT_OPEN_PATHNAME :: Create a new input stream from a C~path */ |
1939 | /* name. */ |
1940 | /* */ |
1941 | /* FT_OPEN_DRIVER :: Use the `driver' field. */ |
1942 | /* */ |
1943 | /* FT_OPEN_PARAMS :: Use the `num_params' and `params' fields. */ |
1944 | /* */ |
1945 | /* <Note> */ |
1946 | /* The `FT_OPEN_MEMORY', `FT_OPEN_STREAM', and `FT_OPEN_PATHNAME' */ |
1947 | /* flags are mutually exclusive. */ |
1948 | /* */ |
1949 | #define FT_OPEN_MEMORY 0x1 |
1950 | #define FT_OPEN_STREAM 0x2 |
1951 | #define FT_OPEN_PATHNAME 0x4 |
1952 | #define FT_OPEN_DRIVER 0x8 |
1953 | #define FT_OPEN_PARAMS 0x10 |
1954 | |
1955 | |
1956 | /* these constants are deprecated; use the corresponding `FT_OPEN_XXX' */ |
1957 | /* values instead */ |
1958 | #define ft_open_memory FT_OPEN_MEMORY |
1959 | #define ft_open_stream FT_OPEN_STREAM |
1960 | #define ft_open_pathname FT_OPEN_PATHNAME |
1961 | #define ft_open_driver FT_OPEN_DRIVER |
1962 | #define ft_open_params FT_OPEN_PARAMS |
1963 | |
1964 | |
1965 | /*************************************************************************/ |
1966 | /* */ |
1967 | /* <Struct> */ |
1968 | /* FT_Parameter */ |
1969 | /* */ |
1970 | /* <Description> */ |
1971 | /* A simple structure to pass more or less generic parameters to */ |
1972 | /* @FT_Open_Face and @FT_Face_Properties. */ |
1973 | /* */ |
1974 | /* <Fields> */ |
1975 | /* tag :: A four-byte identification tag. */ |
1976 | /* */ |
1977 | /* data :: A pointer to the parameter data. */ |
1978 | /* */ |
1979 | /* <Note> */ |
1980 | /* The ID and function of parameters are driver-specific. See the */ |
1981 | /* various FT_PARAM_TAG_XXX flags for more information. */ |
1982 | /* */ |
1983 | typedef struct FT_Parameter_ |
1984 | { |
1985 | FT_ULong tag; |
1986 | FT_Pointer data; |
1987 | |
1988 | } FT_Parameter; |
1989 | |
1990 | |
1991 | /*************************************************************************/ |
1992 | /* */ |
1993 | /* <Struct> */ |
1994 | /* FT_Open_Args */ |
1995 | /* */ |
1996 | /* <Description> */ |
1997 | /* A structure to indicate how to open a new font file or stream. A */ |
1998 | /* pointer to such a structure can be used as a parameter for the */ |
1999 | /* functions @FT_Open_Face and @FT_Attach_Stream. */ |
2000 | /* */ |
2001 | /* <Fields> */ |
2002 | /* flags :: A set of bit flags indicating how to use the */ |
2003 | /* structure. */ |
2004 | /* */ |
2005 | /* memory_base :: The first byte of the file in memory. */ |
2006 | /* */ |
2007 | /* memory_size :: The size in bytes of the file in memory. */ |
2008 | /* */ |
2009 | /* pathname :: A pointer to an 8-bit file pathname. */ |
2010 | /* */ |
2011 | /* stream :: A handle to a source stream object. */ |
2012 | /* */ |
2013 | /* driver :: This field is exclusively used by @FT_Open_Face; */ |
2014 | /* it simply specifies the font driver to use for */ |
2015 | /* opening the face. If set to NULL, FreeType tries */ |
2016 | /* to load the face with each one of the drivers in */ |
2017 | /* its list. */ |
2018 | /* */ |
2019 | /* num_params :: The number of extra parameters. */ |
2020 | /* */ |
2021 | /* params :: Extra parameters passed to the font driver when */ |
2022 | /* opening a new face. */ |
2023 | /* */ |
2024 | /* <Note> */ |
2025 | /* The stream type is determined by the contents of `flags' that */ |
2026 | /* are tested in the following order by @FT_Open_Face: */ |
2027 | /* */ |
2028 | /* If the @FT_OPEN_MEMORY bit is set, assume that this is a */ |
2029 | /* memory file of `memory_size' bytes, located at `memory_address'. */ |
2030 | /* The data are not copied, and the client is responsible for */ |
2031 | /* releasing and destroying them _after_ the corresponding call to */ |
2032 | /* @FT_Done_Face. */ |
2033 | /* */ |
2034 | /* Otherwise, if the @FT_OPEN_STREAM bit is set, assume that a */ |
2035 | /* custom input stream `stream' is used. */ |
2036 | /* */ |
2037 | /* Otherwise, if the @FT_OPEN_PATHNAME bit is set, assume that this */ |
2038 | /* is a normal file and use `pathname' to open it. */ |
2039 | /* */ |
2040 | /* If the @FT_OPEN_DRIVER bit is set, @FT_Open_Face only tries to */ |
2041 | /* open the file with the driver whose handler is in `driver'. */ |
2042 | /* */ |
2043 | /* If the @FT_OPEN_PARAMS bit is set, the parameters given by */ |
2044 | /* `num_params' and `params' is used. They are ignored otherwise. */ |
2045 | /* */ |
2046 | /* Ideally, both the `pathname' and `params' fields should be tagged */ |
2047 | /* as `const'; this is missing for API backward compatibility. In */ |
2048 | /* other words, applications should treat them as read-only. */ |
2049 | /* */ |
2050 | typedef struct FT_Open_Args_ |
2051 | { |
2052 | FT_UInt flags; |
2053 | const FT_Byte* memory_base; |
2054 | FT_Long memory_size; |
2055 | FT_String* pathname; |
2056 | FT_Stream stream; |
2057 | FT_Module driver; |
2058 | FT_Int num_params; |
2059 | FT_Parameter* params; |
2060 | |
2061 | } FT_Open_Args; |
2062 | |
2063 | |
2064 | /*************************************************************************/ |
2065 | /* */ |
2066 | /* <Function> */ |
2067 | /* FT_New_Face */ |
2068 | /* */ |
2069 | /* <Description> */ |
2070 | /* Call @FT_Open_Face to open a font by its pathname. */ |
2071 | /* */ |
2072 | /* <InOut> */ |
2073 | /* library :: A handle to the library resource. */ |
2074 | /* */ |
2075 | /* <Input> */ |
2076 | /* pathname :: A path to the font file. */ |
2077 | /* */ |
2078 | /* face_index :: See @FT_Open_Face for a detailed description of this */ |
2079 | /* parameter. */ |
2080 | /* */ |
2081 | /* <Output> */ |
2082 | /* aface :: A handle to a new face object. If `face_index' is */ |
2083 | /* greater than or equal to zero, it must be non-NULL. */ |
2084 | /* */ |
2085 | /* <Return> */ |
2086 | /* FreeType error code. 0~means success. */ |
2087 | /* */ |
2088 | /* <Note> */ |
2089 | /* Use @FT_Done_Face to destroy the created @FT_Face object (along */ |
2090 | /* with its slot and sizes). */ |
2091 | /* */ |
2092 | FT_EXPORT( FT_Error ) |
2093 | FT_New_Face( FT_Library library, |
2094 | const char* filepathname, |
2095 | FT_Long face_index, |
2096 | FT_Face *aface ); |
2097 | |
2098 | |
2099 | /*************************************************************************/ |
2100 | /* */ |
2101 | /* <Function> */ |
2102 | /* FT_New_Memory_Face */ |
2103 | /* */ |
2104 | /* <Description> */ |
2105 | /* Call @FT_Open_Face to open a font that has been loaded into */ |
2106 | /* memory. */ |
2107 | /* */ |
2108 | /* <InOut> */ |
2109 | /* library :: A handle to the library resource. */ |
2110 | /* */ |
2111 | /* <Input> */ |
2112 | /* file_base :: A pointer to the beginning of the font data. */ |
2113 | /* */ |
2114 | /* file_size :: The size of the memory chunk used by the font data. */ |
2115 | /* */ |
2116 | /* face_index :: See @FT_Open_Face for a detailed description of this */ |
2117 | /* parameter. */ |
2118 | /* */ |
2119 | /* <Output> */ |
2120 | /* aface :: A handle to a new face object. If `face_index' is */ |
2121 | /* greater than or equal to zero, it must be non-NULL. */ |
2122 | /* */ |
2123 | /* <Return> */ |
2124 | /* FreeType error code. 0~means success. */ |
2125 | /* */ |
2126 | /* <Note> */ |
2127 | /* You must not deallocate the memory before calling @FT_Done_Face. */ |
2128 | /* */ |
2129 | FT_EXPORT( FT_Error ) |
2130 | FT_New_Memory_Face( FT_Library library, |
2131 | const FT_Byte* file_base, |
2132 | FT_Long file_size, |
2133 | FT_Long face_index, |
2134 | FT_Face *aface ); |
2135 | |
2136 | |
2137 | /*************************************************************************/ |
2138 | /* */ |
2139 | /* <Function> */ |
2140 | /* FT_Open_Face */ |
2141 | /* */ |
2142 | /* <Description> */ |
2143 | /* Create a face object from a given resource described by */ |
2144 | /* @FT_Open_Args. */ |
2145 | /* */ |
2146 | /* <InOut> */ |
2147 | /* library :: A handle to the library resource. */ |
2148 | /* */ |
2149 | /* <Input> */ |
2150 | /* args :: A pointer to an `FT_Open_Args' structure that must */ |
2151 | /* be filled by the caller. */ |
2152 | /* */ |
2153 | /* face_index :: This field holds two different values. Bits 0-15 */ |
2154 | /* are the index of the face in the font file (starting */ |
2155 | /* with value~0). Set it to~0 if there is only one */ |
2156 | /* face in the font file. */ |
2157 | /* */ |
2158 | /* Bits 16-30 are relevant to GX and OpenType variation */ |
2159 | /* fonts only, specifying the named instance index for */ |
2160 | /* the current face index (starting with value~1; */ |
2161 | /* value~0 makes FreeType ignore named instances). For */ |
2162 | /* non-variation fonts, bits 16-30 are ignored. */ |
2163 | /* Assuming that you want to access the third named */ |
2164 | /* instance in face~4, `face_index' should be set to */ |
2165 | /* 0x00030004. If you want to access face~4 without */ |
2166 | /* variation handling, simply set `face_index' to */ |
2167 | /* value~4. */ |
2168 | /* */ |
2169 | /* `FT_Open_Face' and its siblings can be used to */ |
2170 | /* quickly check whether the font format of a given */ |
2171 | /* font resource is supported by FreeType. In general, */ |
2172 | /* if the `face_index' argument is negative, the */ |
2173 | /* function's return value is~0 if the font format is */ |
2174 | /* recognized, or non-zero otherwise. The function */ |
2175 | /* allocates a more or less empty face handle in */ |
2176 | /* `*aface' (if `aface' isn't NULL); the only two */ |
2177 | /* useful fields in this special case are */ |
2178 | /* `face->num_faces' and `face->style_flags'. For any */ |
2179 | /* negative value of `face_index', `face->num_faces' */ |
2180 | /* gives the number of faces within the font file. For */ |
2181 | /* the negative value `-(N+1)' (with `N' a non-negative */ |
2182 | /* 16-bit value), bits 16-30 in `face->style_flags' */ |
2183 | /* give the number of named instances in face `N' if we */ |
2184 | /* have a variation font (or zero otherwise). After */ |
2185 | /* examination, the returned @FT_Face structure should */ |
2186 | /* be deallocated with a call to @FT_Done_Face. */ |
2187 | /* */ |
2188 | /* <Output> */ |
2189 | /* aface :: A handle to a new face object. If `face_index' is */ |
2190 | /* greater than or equal to zero, it must be non-NULL. */ |
2191 | /* */ |
2192 | /* <Return> */ |
2193 | /* FreeType error code. 0~means success. */ |
2194 | /* */ |
2195 | /* <Note> */ |
2196 | /* Unlike FreeType 1.x, this function automatically creates a glyph */ |
2197 | /* slot for the face object that can be accessed directly through */ |
2198 | /* `face->glyph'. */ |
2199 | /* */ |
2200 | /* Each new face object created with this function also owns a */ |
2201 | /* default @FT_Size object, accessible as `face->size'. */ |
2202 | /* */ |
2203 | /* One @FT_Library instance can have multiple face objects, this is, */ |
2204 | /* @FT_Open_Face and its siblings can be called multiple times using */ |
2205 | /* the same `library' argument. */ |
2206 | /* */ |
2207 | /* See the discussion of reference counters in the description of */ |
2208 | /* @FT_Reference_Face. */ |
2209 | /* */ |
2210 | /* To loop over all faces, use code similar to the following snippet */ |
2211 | /* (omitting the error handling). */ |
2212 | /* */ |
2213 | /* { */ |
2214 | /* ... */ |
2215 | /* FT_Face face; */ |
2216 | /* FT_Long i, num_faces; */ |
2217 | /* */ |
2218 | /* */ |
2219 | /* error = FT_Open_Face( library, args, -1, &face ); */ |
2220 | /* if ( error ) { ... } */ |
2221 | /* */ |
2222 | /* num_faces = face->num_faces; */ |
2223 | /* FT_Done_Face( face ); */ |
2224 | /* */ |
2225 | /* for ( i = 0; i < num_faces; i++ ) */ |
2226 | /* { */ |
2227 | /* ... */ |
2228 | /* error = FT_Open_Face( library, args, i, &face ); */ |
2229 | /* ... */ |
2230 | /* FT_Done_Face( face ); */ |
2231 | /* ... */ |
2232 | /* } */ |
2233 | /* } */ |
2234 | /* */ |
2235 | /* To loop over all valid values for `face_index', use something */ |
2236 | /* similar to the following snippet, again without error handling. */ |
2237 | /* The code accesses all faces immediately (thus only a single call */ |
2238 | /* of `FT_Open_Face' within the do-loop), with and without named */ |
2239 | /* instances. */ |
2240 | /* */ |
2241 | /* { */ |
2242 | /* ... */ |
2243 | /* FT_Face face; */ |
2244 | /* */ |
2245 | /* FT_Long num_faces = 0; */ |
2246 | /* FT_Long num_instances = 0; */ |
2247 | /* */ |
2248 | /* FT_Long face_idx = 0; */ |
2249 | /* FT_Long instance_idx = 0; */ |
2250 | /* */ |
2251 | /* */ |
2252 | /* do */ |
2253 | /* { */ |
2254 | /* FT_Long id = ( instance_idx << 16 ) + face_idx; */ |
2255 | /* */ |
2256 | /* */ |
2257 | /* error = FT_Open_Face( library, args, id, &face ); */ |
2258 | /* if ( error ) { ... } */ |
2259 | /* */ |
2260 | /* num_faces = face->num_faces; */ |
2261 | /* num_instances = face->style_flags >> 16; */ |
2262 | /* */ |
2263 | /* ... */ |
2264 | /* */ |
2265 | /* FT_Done_Face( face ); */ |
2266 | /* */ |
2267 | /* if ( instance_idx < num_instances ) */ |
2268 | /* instance_idx++; */ |
2269 | /* else */ |
2270 | /* { */ |
2271 | /* face_idx++; */ |
2272 | /* instance_idx = 0; */ |
2273 | /* } */ |
2274 | /* */ |
2275 | /* } while ( face_idx < num_faces ) */ |
2276 | /* } */ |
2277 | /* */ |
2278 | FT_EXPORT( FT_Error ) |
2279 | FT_Open_Face( FT_Library library, |
2280 | const FT_Open_Args* args, |
2281 | FT_Long face_index, |
2282 | FT_Face *aface ); |
2283 | |
2284 | |
2285 | /*************************************************************************/ |
2286 | /* */ |
2287 | /* <Function> */ |
2288 | /* FT_Attach_File */ |
2289 | /* */ |
2290 | /* <Description> */ |
2291 | /* Call @FT_Attach_Stream to attach a file. */ |
2292 | /* */ |
2293 | /* <InOut> */ |
2294 | /* face :: The target face object. */ |
2295 | /* */ |
2296 | /* <Input> */ |
2297 | /* filepathname :: The pathname. */ |
2298 | /* */ |
2299 | /* <Return> */ |
2300 | /* FreeType error code. 0~means success. */ |
2301 | /* */ |
2302 | FT_EXPORT( FT_Error ) |
2303 | FT_Attach_File( FT_Face face, |
2304 | const char* filepathname ); |
2305 | |
2306 | |
2307 | /*************************************************************************/ |
2308 | /* */ |
2309 | /* <Function> */ |
2310 | /* FT_Attach_Stream */ |
2311 | /* */ |
2312 | /* <Description> */ |
2313 | /* `Attach' data to a face object. Normally, this is used to read */ |
2314 | /* additional information for the face object. For example, you can */ |
2315 | /* attach an AFM file that comes with a Type~1 font to get the */ |
2316 | /* kerning values and other metrics. */ |
2317 | /* */ |
2318 | /* <InOut> */ |
2319 | /* face :: The target face object. */ |
2320 | /* */ |
2321 | /* <Input> */ |
2322 | /* parameters :: A pointer to @FT_Open_Args that must be filled by */ |
2323 | /* the caller. */ |
2324 | /* */ |
2325 | /* <Return> */ |
2326 | /* FreeType error code. 0~means success. */ |
2327 | /* */ |
2328 | /* <Note> */ |
2329 | /* The meaning of the `attach' (i.e., what really happens when the */ |
2330 | /* new file is read) is not fixed by FreeType itself. It really */ |
2331 | /* depends on the font format (and thus the font driver). */ |
2332 | /* */ |
2333 | /* Client applications are expected to know what they are doing */ |
2334 | /* when invoking this function. Most drivers simply do not implement */ |
2335 | /* file or stream attachments. */ |
2336 | /* */ |
2337 | FT_EXPORT( FT_Error ) |
2338 | FT_Attach_Stream( FT_Face face, |
2339 | FT_Open_Args* parameters ); |
2340 | |
2341 | |
2342 | /*************************************************************************/ |
2343 | /* */ |
2344 | /* <Function> */ |
2345 | /* FT_Reference_Face */ |
2346 | /* */ |
2347 | /* <Description> */ |
2348 | /* A counter gets initialized to~1 at the time an @FT_Face structure */ |
2349 | /* is created. This function increments the counter. @FT_Done_Face */ |
2350 | /* then only destroys a face if the counter is~1, otherwise it simply */ |
2351 | /* decrements the counter. */ |
2352 | /* */ |
2353 | /* This function helps in managing life-cycles of structures that */ |
2354 | /* reference @FT_Face objects. */ |
2355 | /* */ |
2356 | /* <Input> */ |
2357 | /* face :: A handle to a target face object. */ |
2358 | /* */ |
2359 | /* <Return> */ |
2360 | /* FreeType error code. 0~means success. */ |
2361 | /* */ |
2362 | /* <Since> */ |
2363 | /* 2.4.2 */ |
2364 | /* */ |
2365 | FT_EXPORT( FT_Error ) |
2366 | FT_Reference_Face( FT_Face face ); |
2367 | |
2368 | |
2369 | /*************************************************************************/ |
2370 | /* */ |
2371 | /* <Function> */ |
2372 | /* FT_Done_Face */ |
2373 | /* */ |
2374 | /* <Description> */ |
2375 | /* Discard a given face object, as well as all of its child slots and */ |
2376 | /* sizes. */ |
2377 | /* */ |
2378 | /* <Input> */ |
2379 | /* face :: A handle to a target face object. */ |
2380 | /* */ |
2381 | /* <Return> */ |
2382 | /* FreeType error code. 0~means success. */ |
2383 | /* */ |
2384 | /* <Note> */ |
2385 | /* See the discussion of reference counters in the description of */ |
2386 | /* @FT_Reference_Face. */ |
2387 | /* */ |
2388 | FT_EXPORT( FT_Error ) |
2389 | FT_Done_Face( FT_Face face ); |
2390 | |
2391 | |
2392 | /*************************************************************************/ |
2393 | /* */ |
2394 | /* <Function> */ |
2395 | /* FT_Select_Size */ |
2396 | /* */ |
2397 | /* <Description> */ |
2398 | /* Select a bitmap strike. To be more precise, this function sets */ |
2399 | /* the scaling factors of the active @FT_Size object in a face so */ |
2400 | /* that bitmaps from this particular strike are taken by */ |
2401 | /* @FT_Load_Glyph and friends. */ |
2402 | /* */ |
2403 | /* <InOut> */ |
2404 | /* face :: A handle to a target face object. */ |
2405 | /* */ |
2406 | /* <Input> */ |
2407 | /* strike_index :: The index of the bitmap strike in the */ |
2408 | /* `available_sizes' field of @FT_FaceRec structure. */ |
2409 | /* */ |
2410 | /* <Return> */ |
2411 | /* FreeType error code. 0~means success. */ |
2412 | /* */ |
2413 | /* <Note> */ |
2414 | /* For bitmaps embedded in outline fonts it is common that only a */ |
2415 | /* subset of the available glyphs at a given ppem value is available. */ |
2416 | /* FreeType silently uses outlines if there is no bitmap for a given */ |
2417 | /* glyph index. */ |
2418 | /* */ |
2419 | /* For GX and OpenType variation fonts, a bitmap strike makes sense */ |
2420 | /* only if the default instance is active (this is, no glyph */ |
2421 | /* variation takes place); otherwise, FreeType simply ignores bitmap */ |
2422 | /* strikes. The same is true for all named instances that are */ |
2423 | /* different from the default instance. */ |
2424 | /* */ |
2425 | /* Don't use this function if you are using the FreeType cache API. */ |
2426 | /* */ |
2427 | FT_EXPORT( FT_Error ) |
2428 | FT_Select_Size( FT_Face face, |
2429 | FT_Int strike_index ); |
2430 | |
2431 | |
2432 | /*************************************************************************/ |
2433 | /* */ |
2434 | /* <Enum> */ |
2435 | /* FT_Size_Request_Type */ |
2436 | /* */ |
2437 | /* <Description> */ |
2438 | /* An enumeration type that lists the supported size request types, */ |
2439 | /* i.e., what input size (in font units) maps to the requested output */ |
2440 | /* size (in pixels, as computed from the arguments of */ |
2441 | /* @FT_Size_Request). */ |
2442 | /* */ |
2443 | /* <Values> */ |
2444 | /* FT_SIZE_REQUEST_TYPE_NOMINAL :: */ |
2445 | /* The nominal size. The `units_per_EM' field of @FT_FaceRec is */ |
2446 | /* used to determine both scaling values. */ |
2447 | /* */ |
2448 | /* This is the standard scaling found in most applications. In */ |
2449 | /* particular, use this size request type for TrueType fonts if */ |
2450 | /* they provide optical scaling or something similar. Note, */ |
2451 | /* however, that `units_per_EM' is a rather abstract value which */ |
2452 | /* bears no relation to the actual size of the glyphs in a font. */ |
2453 | /* */ |
2454 | /* FT_SIZE_REQUEST_TYPE_REAL_DIM :: */ |
2455 | /* The real dimension. The sum of the `ascender' and (minus of) */ |
2456 | /* the `descender' fields of @FT_FaceRec is used to determine both */ |
2457 | /* scaling values. */ |
2458 | /* */ |
2459 | /* FT_SIZE_REQUEST_TYPE_BBOX :: */ |
2460 | /* The font bounding box. The width and height of the `bbox' field */ |
2461 | /* of @FT_FaceRec are used to determine the horizontal and vertical */ |
2462 | /* scaling value, respectively. */ |
2463 | /* */ |
2464 | /* FT_SIZE_REQUEST_TYPE_CELL :: */ |
2465 | /* The `max_advance_width' field of @FT_FaceRec is used to */ |
2466 | /* determine the horizontal scaling value; the vertical scaling */ |
2467 | /* value is determined the same way as */ |
2468 | /* @FT_SIZE_REQUEST_TYPE_REAL_DIM does. Finally, both scaling */ |
2469 | /* values are set to the smaller one. This type is useful if you */ |
2470 | /* want to specify the font size for, say, a window of a given */ |
2471 | /* dimension and 80x24 cells. */ |
2472 | /* */ |
2473 | /* FT_SIZE_REQUEST_TYPE_SCALES :: */ |
2474 | /* Specify the scaling values directly. */ |
2475 | /* */ |
2476 | /* <Note> */ |
2477 | /* The above descriptions only apply to scalable formats. For bitmap */ |
2478 | /* formats, the behaviour is up to the driver. */ |
2479 | /* */ |
2480 | /* See the note section of @FT_Size_Metrics if you wonder how size */ |
2481 | /* requesting relates to scaling values. */ |
2482 | /* */ |
2483 | typedef enum FT_Size_Request_Type_ |
2484 | { |
2485 | FT_SIZE_REQUEST_TYPE_NOMINAL, |
2486 | FT_SIZE_REQUEST_TYPE_REAL_DIM, |
2487 | FT_SIZE_REQUEST_TYPE_BBOX, |
2488 | FT_SIZE_REQUEST_TYPE_CELL, |
2489 | FT_SIZE_REQUEST_TYPE_SCALES, |
2490 | |
2491 | FT_SIZE_REQUEST_TYPE_MAX |
2492 | |
2493 | } FT_Size_Request_Type; |
2494 | |
2495 | |
2496 | /*************************************************************************/ |
2497 | /* */ |
2498 | /* <Struct> */ |
2499 | /* FT_Size_RequestRec */ |
2500 | /* */ |
2501 | /* <Description> */ |
2502 | /* A structure to model a size request. */ |
2503 | /* */ |
2504 | /* <Fields> */ |
2505 | /* type :: See @FT_Size_Request_Type. */ |
2506 | /* */ |
2507 | /* width :: The desired width, given as a 26.6 fractional */ |
2508 | /* point value (with 72pt = 1in). */ |
2509 | /* */ |
2510 | /* height :: The desired height, given as a 26.6 fractional */ |
2511 | /* point value (with 72pt = 1in). */ |
2512 | /* */ |
2513 | /* horiResolution :: The horizontal resolution (dpi, i.e., pixels per */ |
2514 | /* inch). If set to zero, `width' is treated as a */ |
2515 | /* 26.6 fractional *pixel* value, which gets */ |
2516 | /* internally rounded to an integer. */ |
2517 | /* */ |
2518 | /* vertResolution :: The vertical resolution (dpi, i.e., pixels per */ |
2519 | /* inch). If set to zero, `height' is treated as a */ |
2520 | /* 26.6 fractional *pixel* value, which gets */ |
2521 | /* internally rounded to an integer. */ |
2522 | /* */ |
2523 | /* <Note> */ |
2524 | /* If `width' is zero, the horizontal scaling value is set equal */ |
2525 | /* to the vertical scaling value, and vice versa. */ |
2526 | /* */ |
2527 | /* If `type' is FT_SIZE_REQUEST_TYPE_SCALES, `width' and `height' are */ |
2528 | /* interpreted directly as 16.16 fractional scaling values, without */ |
2529 | /* any further modification, and both `horiResolution' and */ |
2530 | /* `vertResolution' are ignored. */ |
2531 | /* */ |
2532 | typedef struct FT_Size_RequestRec_ |
2533 | { |
2534 | FT_Size_Request_Type type; |
2535 | FT_Long width; |
2536 | FT_Long height; |
2537 | FT_UInt horiResolution; |
2538 | FT_UInt vertResolution; |
2539 | |
2540 | } FT_Size_RequestRec; |
2541 | |
2542 | |
2543 | /*************************************************************************/ |
2544 | /* */ |
2545 | /* <Struct> */ |
2546 | /* FT_Size_Request */ |
2547 | /* */ |
2548 | /* <Description> */ |
2549 | /* A handle to a size request structure. */ |
2550 | /* */ |
2551 | typedef struct FT_Size_RequestRec_ *FT_Size_Request; |
2552 | |
2553 | |
2554 | /*************************************************************************/ |
2555 | /* */ |
2556 | /* <Function> */ |
2557 | /* FT_Request_Size */ |
2558 | /* */ |
2559 | /* <Description> */ |
2560 | /* Resize the scale of the active @FT_Size object in a face. */ |
2561 | /* */ |
2562 | /* <InOut> */ |
2563 | /* face :: A handle to a target face object. */ |
2564 | /* */ |
2565 | /* <Input> */ |
2566 | /* req :: A pointer to a @FT_Size_RequestRec. */ |
2567 | /* */ |
2568 | /* <Return> */ |
2569 | /* FreeType error code. 0~means success. */ |
2570 | /* */ |
2571 | /* <Note> */ |
2572 | /* Although drivers may select the bitmap strike matching the */ |
2573 | /* request, you should not rely on this if you intend to select a */ |
2574 | /* particular bitmap strike. Use @FT_Select_Size instead in that */ |
2575 | /* case. */ |
2576 | /* */ |
2577 | /* The relation between the requested size and the resulting glyph */ |
2578 | /* size is dependent entirely on how the size is defined in the */ |
2579 | /* source face. The font designer chooses the final size of each */ |
2580 | /* glyph relative to this size. For more information refer to */ |
2581 | /* `https://www.freetype.org/freetype2/docs/glyphs/glyphs-2.html'. */ |
2582 | /* */ |
2583 | /* Contrary to @FT_Set_Char_Size, this function doesn't have special */ |
2584 | /* code to normalize zero-valued widths, heights, or resolutions */ |
2585 | /* (which lead to errors in most cases). */ |
2586 | /* */ |
2587 | /* Don't use this function if you are using the FreeType cache API. */ |
2588 | /* */ |
2589 | FT_EXPORT( FT_Error ) |
2590 | FT_Request_Size( FT_Face face, |
2591 | FT_Size_Request req ); |
2592 | |
2593 | |
2594 | /*************************************************************************/ |
2595 | /* */ |
2596 | /* <Function> */ |
2597 | /* FT_Set_Char_Size */ |
2598 | /* */ |
2599 | /* <Description> */ |
2600 | /* Call @FT_Request_Size to request the nominal size (in points). */ |
2601 | /* */ |
2602 | /* <InOut> */ |
2603 | /* face :: A handle to a target face object. */ |
2604 | /* */ |
2605 | /* <Input> */ |
2606 | /* char_width :: The nominal width, in 26.6 fractional points. */ |
2607 | /* */ |
2608 | /* char_height :: The nominal height, in 26.6 fractional points. */ |
2609 | /* */ |
2610 | /* horz_resolution :: The horizontal resolution in dpi. */ |
2611 | /* */ |
2612 | /* vert_resolution :: The vertical resolution in dpi. */ |
2613 | /* */ |
2614 | /* <Return> */ |
2615 | /* FreeType error code. 0~means success. */ |
2616 | /* */ |
2617 | /* <Note> */ |
2618 | /* While this function allows fractional points as input values, the */ |
2619 | /* resulting ppem value for the given resolution is always rounded to */ |
2620 | /* the nearest integer. */ |
2621 | /* */ |
2622 | /* If either the character width or height is zero, it is set equal */ |
2623 | /* to the other value. */ |
2624 | /* */ |
2625 | /* If either the horizontal or vertical resolution is zero, it is set */ |
2626 | /* equal to the other value. */ |
2627 | /* */ |
2628 | /* A character width or height smaller than 1pt is set to 1pt; if */ |
2629 | /* both resolution values are zero, they are set to 72dpi. */ |
2630 | /* */ |
2631 | /* Don't use this function if you are using the FreeType cache API. */ |
2632 | /* */ |
2633 | FT_EXPORT( FT_Error ) |
2634 | FT_Set_Char_Size( FT_Face face, |
2635 | FT_F26Dot6 char_width, |
2636 | FT_F26Dot6 char_height, |
2637 | FT_UInt horz_resolution, |
2638 | FT_UInt vert_resolution ); |
2639 | |
2640 | |
2641 | /*************************************************************************/ |
2642 | /* */ |
2643 | /* <Function> */ |
2644 | /* FT_Set_Pixel_Sizes */ |
2645 | /* */ |
2646 | /* <Description> */ |
2647 | /* Call @FT_Request_Size to request the nominal size (in pixels). */ |
2648 | /* */ |
2649 | /* <InOut> */ |
2650 | /* face :: A handle to the target face object. */ |
2651 | /* */ |
2652 | /* <Input> */ |
2653 | /* pixel_width :: The nominal width, in pixels. */ |
2654 | /* */ |
2655 | /* pixel_height :: The nominal height, in pixels. */ |
2656 | /* */ |
2657 | /* <Return> */ |
2658 | /* FreeType error code. 0~means success. */ |
2659 | /* */ |
2660 | /* <Note> */ |
2661 | /* You should not rely on the resulting glyphs matching or being */ |
2662 | /* constrained to this pixel size. Refer to @FT_Request_Size to */ |
2663 | /* understand how requested sizes relate to actual sizes. */ |
2664 | /* */ |
2665 | /* Don't use this function if you are using the FreeType cache API. */ |
2666 | /* */ |
2667 | FT_EXPORT( FT_Error ) |
2668 | FT_Set_Pixel_Sizes( FT_Face face, |
2669 | FT_UInt pixel_width, |
2670 | FT_UInt pixel_height ); |
2671 | |
2672 | |
2673 | /*************************************************************************/ |
2674 | /* */ |
2675 | /* <Function> */ |
2676 | /* FT_Load_Glyph */ |
2677 | /* */ |
2678 | /* <Description> */ |
2679 | /* Load a glyph into the glyph slot of a face object. */ |
2680 | /* */ |
2681 | /* <InOut> */ |
2682 | /* face :: A handle to the target face object where the glyph */ |
2683 | /* is loaded. */ |
2684 | /* */ |
2685 | /* <Input> */ |
2686 | /* glyph_index :: The index of the glyph in the font file. For */ |
2687 | /* CID-keyed fonts (either in PS or in CFF format) */ |
2688 | /* this argument specifies the CID value. */ |
2689 | /* */ |
2690 | /* load_flags :: A flag indicating what to load for this glyph. The */ |
2691 | /* @FT_LOAD_XXX constants can be used to control the */ |
2692 | /* glyph loading process (e.g., whether the outline */ |
2693 | /* should be scaled, whether to load bitmaps or not, */ |
2694 | /* whether to hint the outline, etc). */ |
2695 | /* */ |
2696 | /* <Return> */ |
2697 | /* FreeType error code. 0~means success. */ |
2698 | /* */ |
2699 | /* <Note> */ |
2700 | /* The loaded glyph may be transformed. See @FT_Set_Transform for */ |
2701 | /* the details. */ |
2702 | /* */ |
2703 | /* For subsetted CID-keyed fonts, `FT_Err_Invalid_Argument' is */ |
2704 | /* returned for invalid CID values (this is, for CID values that */ |
2705 | /* don't have a corresponding glyph in the font). See the discussion */ |
2706 | /* of the @FT_FACE_FLAG_CID_KEYED flag for more details. */ |
2707 | /* */ |
2708 | /* If you receive `FT_Err_Glyph_Too_Big', try getting the glyph */ |
2709 | /* outline at EM size, then scale it manually and fill it as a */ |
2710 | /* graphics operation. */ |
2711 | /* */ |
2712 | FT_EXPORT( FT_Error ) |
2713 | FT_Load_Glyph( FT_Face face, |
2714 | FT_UInt glyph_index, |
2715 | FT_Int32 load_flags ); |
2716 | |
2717 | |
2718 | /*************************************************************************/ |
2719 | /* */ |
2720 | /* <Function> */ |
2721 | /* FT_Load_Char */ |
2722 | /* */ |
2723 | /* <Description> */ |
2724 | /* Load a glyph into the glyph slot of a face object, accessed by its */ |
2725 | /* character code. */ |
2726 | /* */ |
2727 | /* <InOut> */ |
2728 | /* face :: A handle to a target face object where the glyph */ |
2729 | /* is loaded. */ |
2730 | /* */ |
2731 | /* <Input> */ |
2732 | /* char_code :: The glyph's character code, according to the */ |
2733 | /* current charmap used in the face. */ |
2734 | /* */ |
2735 | /* load_flags :: A flag indicating what to load for this glyph. The */ |
2736 | /* @FT_LOAD_XXX constants can be used to control the */ |
2737 | /* glyph loading process (e.g., whether the outline */ |
2738 | /* should be scaled, whether to load bitmaps or not, */ |
2739 | /* whether to hint the outline, etc). */ |
2740 | /* */ |
2741 | /* <Return> */ |
2742 | /* FreeType error code. 0~means success. */ |
2743 | /* */ |
2744 | /* <Note> */ |
2745 | /* This function simply calls @FT_Get_Char_Index and @FT_Load_Glyph. */ |
2746 | /* */ |
2747 | /* Many fonts contain glyphs that can't be loaded by this function */ |
2748 | /* since its glyph indices are not listed in any of the font's */ |
2749 | /* charmaps. */ |
2750 | /* */ |
2751 | FT_EXPORT( FT_Error ) |
2752 | FT_Load_Char( FT_Face face, |
2753 | FT_ULong char_code, |
2754 | FT_Int32 load_flags ); |
2755 | |
2756 | |
2757 | /************************************************************************* |
2758 | * |
2759 | * @enum: |
2760 | * FT_LOAD_XXX |
2761 | * |
2762 | * @description: |
2763 | * A list of bit field constants for @FT_Load_Glyph to indicate what |
2764 | * kind of operations to perform during glyph loading. |
2765 | * |
2766 | * @values: |
2767 | * FT_LOAD_DEFAULT :: |
2768 | * Corresponding to~0, this value is used as the default glyph load |
2769 | * operation. In this case, the following happens: |
2770 | * |
2771 | * 1. FreeType looks for a bitmap for the glyph corresponding to the |
2772 | * face's current size. If one is found, the function returns. |
2773 | * The bitmap data can be accessed from the glyph slot (see note |
2774 | * below). |
2775 | * |
2776 | * 2. If no embedded bitmap is searched for or found, FreeType looks |
2777 | * for a scalable outline. If one is found, it is loaded from |
2778 | * the font file, scaled to device pixels, then `hinted' to the |
2779 | * pixel grid in order to optimize it. The outline data can be |
2780 | * accessed from the glyph slot (see note below). |
2781 | * |
2782 | * Note that by default the glyph loader doesn't render outlines into |
2783 | * bitmaps. The following flags are used to modify this default |
2784 | * behaviour to more specific and useful cases. |
2785 | * |
2786 | * FT_LOAD_NO_SCALE :: |
2787 | * Don't scale the loaded outline glyph but keep it in font units. |
2788 | * |
2789 | * This flag implies @FT_LOAD_NO_HINTING and @FT_LOAD_NO_BITMAP, and |
2790 | * unsets @FT_LOAD_RENDER. |
2791 | * |
2792 | * If the font is `tricky' (see @FT_FACE_FLAG_TRICKY for more), using |
2793 | * FT_LOAD_NO_SCALE usually yields meaningless outlines because the |
2794 | * subglyphs must be scaled and positioned with hinting instructions. |
2795 | * This can be solved by loading the font without FT_LOAD_NO_SCALE and |
2796 | * setting the character size to `font->units_per_EM'. |
2797 | * |
2798 | * FT_LOAD_NO_HINTING :: |
2799 | * Disable hinting. This generally generates `blurrier' bitmap glyphs |
2800 | * when the glyph are rendered in any of the anti-aliased modes. See |
2801 | * also the note below. |
2802 | * |
2803 | * This flag is implied by @FT_LOAD_NO_SCALE. |
2804 | * |
2805 | * FT_LOAD_RENDER :: |
2806 | * Call @FT_Render_Glyph after the glyph is loaded. By default, the |
2807 | * glyph is rendered in @FT_RENDER_MODE_NORMAL mode. This can be |
2808 | * overridden by @FT_LOAD_TARGET_XXX or @FT_LOAD_MONOCHROME. |
2809 | * |
2810 | * This flag is unset by @FT_LOAD_NO_SCALE. |
2811 | * |
2812 | * FT_LOAD_NO_BITMAP :: |
2813 | * Ignore bitmap strikes when loading. Bitmap-only fonts ignore this |
2814 | * flag. |
2815 | * |
2816 | * @FT_LOAD_NO_SCALE always sets this flag. |
2817 | * |
2818 | * FT_LOAD_VERTICAL_LAYOUT :: |
2819 | * Load the glyph for vertical text layout. In particular, the |
2820 | * `advance' value in the @FT_GlyphSlotRec structure is set to the |
2821 | * `vertAdvance' value of the `metrics' field. |
2822 | * |
2823 | * In case @FT_HAS_VERTICAL doesn't return true, you shouldn't use |
2824 | * this flag currently. Reason is that in this case vertical metrics |
2825 | * get synthesized, and those values are not always consistent across |
2826 | * various font formats. |
2827 | * |
2828 | * FT_LOAD_FORCE_AUTOHINT :: |
2829 | * Prefer the auto-hinter over the font's native hinter. See also |
2830 | * the note below. |
2831 | * |
2832 | * FT_LOAD_PEDANTIC :: |
2833 | * Make the font driver perform pedantic verifications during glyph |
2834 | * loading. This is mostly used to detect broken glyphs in fonts. |
2835 | * By default, FreeType tries to handle broken fonts also. |
2836 | * |
2837 | * In particular, errors from the TrueType bytecode engine are not |
2838 | * passed to the application if this flag is not set; this might |
2839 | * result in partially hinted or distorted glyphs in case a glyph's |
2840 | * bytecode is buggy. |
2841 | * |
2842 | * FT_LOAD_NO_RECURSE :: |
2843 | * Don't load composite glyphs recursively. Instead, the font |
2844 | * driver should set the `num_subglyph' and `subglyphs' values of |
2845 | * the glyph slot accordingly, and set `glyph->format' to |
2846 | * @FT_GLYPH_FORMAT_COMPOSITE. The description of subglyphs can |
2847 | * then be accessed with @FT_Get_SubGlyph_Info. |
2848 | * |
2849 | * This flag implies @FT_LOAD_NO_SCALE and @FT_LOAD_IGNORE_TRANSFORM. |
2850 | * |
2851 | * FT_LOAD_IGNORE_TRANSFORM :: |
2852 | * Ignore the transform matrix set by @FT_Set_Transform. |
2853 | * |
2854 | * FT_LOAD_MONOCHROME :: |
2855 | * This flag is used with @FT_LOAD_RENDER to indicate that you want to |
2856 | * render an outline glyph to a 1-bit monochrome bitmap glyph, with |
2857 | * 8~pixels packed into each byte of the bitmap data. |
2858 | * |
2859 | * Note that this has no effect on the hinting algorithm used. You |
2860 | * should rather use @FT_LOAD_TARGET_MONO so that the |
2861 | * monochrome-optimized hinting algorithm is used. |
2862 | * |
2863 | * FT_LOAD_LINEAR_DESIGN :: |
2864 | * Keep `linearHoriAdvance' and `linearVertAdvance' fields of |
2865 | * @FT_GlyphSlotRec in font units. See @FT_GlyphSlotRec for |
2866 | * details. |
2867 | * |
2868 | * FT_LOAD_NO_AUTOHINT :: |
2869 | * Disable the auto-hinter. See also the note below. |
2870 | * |
2871 | * FT_LOAD_COLOR :: |
2872 | * Load embedded color bitmap images. The resulting color bitmaps, |
2873 | * if available, will have the @FT_PIXEL_MODE_BGRA format. If the |
2874 | * flag is not set and color bitmaps are found, they are converted |
2875 | * to 256-level gray bitmaps transparently, using the |
2876 | * @FT_PIXEL_MODE_GRAY format. |
2877 | * |
2878 | * FT_LOAD_COMPUTE_METRICS :: |
2879 | * Compute glyph metrics from the glyph data, without the use of |
2880 | * bundled metrics tables (for example, the `hdmx' table in TrueType |
2881 | * fonts). This flag is mainly used by font validating or font |
2882 | * editing applications, which need to ignore, verify, or edit those |
2883 | * tables. |
2884 | * |
2885 | * Currently, this flag is only implemented for TrueType fonts. |
2886 | * |
2887 | * FT_LOAD_BITMAP_METRICS_ONLY :: |
2888 | * Request loading of the metrics and bitmap image information of a |
2889 | * (possibly embedded) bitmap glyph without allocating or copying |
2890 | * the bitmap image data itself. No effect if the target glyph is |
2891 | * not a bitmap image. |
2892 | * |
2893 | * This flag unsets @FT_LOAD_RENDER. |
2894 | * |
2895 | * FT_LOAD_CROP_BITMAP :: |
2896 | * Ignored. Deprecated. |
2897 | * |
2898 | * FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH :: |
2899 | * Ignored. Deprecated. |
2900 | * |
2901 | * @note: |
2902 | * By default, hinting is enabled and the font's native hinter (see |
2903 | * @FT_FACE_FLAG_HINTER) is preferred over the auto-hinter. You can |
2904 | * disable hinting by setting @FT_LOAD_NO_HINTING or change the |
2905 | * precedence by setting @FT_LOAD_FORCE_AUTOHINT. You can also set |
2906 | * @FT_LOAD_NO_AUTOHINT in case you don't want the auto-hinter to be |
2907 | * used at all. |
2908 | * |
2909 | * See the description of @FT_FACE_FLAG_TRICKY for a special exception |
2910 | * (affecting only a handful of Asian fonts). |
2911 | * |
2912 | * Besides deciding which hinter to use, you can also decide which |
2913 | * hinting algorithm to use. See @FT_LOAD_TARGET_XXX for details. |
2914 | * |
2915 | * Note that the auto-hinter needs a valid Unicode cmap (either a native |
2916 | * one or synthesized by FreeType) for producing correct results. If a |
2917 | * font provides an incorrect mapping (for example, assigning the |
2918 | * character code U+005A, LATIN CAPITAL LETTER Z, to a glyph depicting a |
2919 | * mathematical integral sign), the auto-hinter might produce useless |
2920 | * results. |
2921 | * |
2922 | */ |
2923 | #define FT_LOAD_DEFAULT 0x0 |
2924 | #define FT_LOAD_NO_SCALE ( 1L << 0 ) |
2925 | #define FT_LOAD_NO_HINTING ( 1L << 1 ) |
2926 | #define FT_LOAD_RENDER ( 1L << 2 ) |
2927 | #define FT_LOAD_NO_BITMAP ( 1L << 3 ) |
2928 | #define FT_LOAD_VERTICAL_LAYOUT ( 1L << 4 ) |
2929 | #define FT_LOAD_FORCE_AUTOHINT ( 1L << 5 ) |
2930 | #define FT_LOAD_CROP_BITMAP ( 1L << 6 ) |
2931 | #define FT_LOAD_PEDANTIC ( 1L << 7 ) |
2932 | #define FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ( 1L << 9 ) |
2933 | #define FT_LOAD_NO_RECURSE ( 1L << 10 ) |
2934 | #define FT_LOAD_IGNORE_TRANSFORM ( 1L << 11 ) |
2935 | #define FT_LOAD_MONOCHROME ( 1L << 12 ) |
2936 | #define FT_LOAD_LINEAR_DESIGN ( 1L << 13 ) |
2937 | #define FT_LOAD_NO_AUTOHINT ( 1L << 15 ) |
2938 | /* Bits 16-19 are used by `FT_LOAD_TARGET_' */ |
2939 | #define FT_LOAD_COLOR ( 1L << 20 ) |
2940 | #define FT_LOAD_COMPUTE_METRICS ( 1L << 21 ) |
2941 | #define FT_LOAD_BITMAP_METRICS_ONLY ( 1L << 22 ) |
2942 | |
2943 | /* */ |
2944 | |
2945 | /* used internally only by certain font drivers */ |
2946 | #define FT_LOAD_ADVANCE_ONLY ( 1L << 8 ) |
2947 | #define FT_LOAD_SBITS_ONLY ( 1L << 14 ) |
2948 | |
2949 | |
2950 | /************************************************************************** |
2951 | * |
2952 | * @enum: |
2953 | * FT_LOAD_TARGET_XXX |
2954 | * |
2955 | * @description: |
2956 | * A list of values to select a specific hinting algorithm for the |
2957 | * hinter. You should OR one of these values to your `load_flags' |
2958 | * when calling @FT_Load_Glyph. |
2959 | * |
2960 | * Note that a font's native hinters may ignore the hinting algorithm |
2961 | * you have specified (e.g., the TrueType bytecode interpreter). You |
2962 | * can set @FT_LOAD_FORCE_AUTOHINT to ensure that the auto-hinter is |
2963 | * used. |
2964 | * |
2965 | * @values: |
2966 | * FT_LOAD_TARGET_NORMAL :: |
2967 | * The default hinting algorithm, optimized for standard gray-level |
2968 | * rendering. For monochrome output, use @FT_LOAD_TARGET_MONO |
2969 | * instead. |
2970 | * |
2971 | * FT_LOAD_TARGET_LIGHT :: |
2972 | * A lighter hinting algorithm for gray-level modes. Many generated |
2973 | * glyphs are fuzzier but better resemble their original shape. This |
2974 | * is achieved by snapping glyphs to the pixel grid only vertically |
2975 | * (Y-axis), as is done by FreeType's new CFF engine or Microsoft's |
2976 | * ClearType font renderer. This preserves inter-glyph spacing in |
2977 | * horizontal text. The snapping is done either by the native font |
2978 | * driver, if the driver itself and the font support it, or by the |
2979 | * auto-hinter. |
2980 | * |
2981 | * Advance widths are rounded to integer values; however, using the |
2982 | * `lsb_delta' and `rsb_delta' fields of @FT_GlyphSlotRec, it is |
2983 | * possible to get fractional advance widths for sub-pixel positioning |
2984 | * (which is recommended to use). |
2985 | * |
2986 | * If configuration option AF_CONFIG_OPTION_TT_SIZE_METRICS is active, |
2987 | * TrueType-like metrics are used to make this mode behave similarly |
2988 | * as in unpatched FreeType versions between 2.4.6 and 2.7.1 |
2989 | * (inclusive). |
2990 | * |
2991 | * FT_LOAD_TARGET_MONO :: |
2992 | * Strong hinting algorithm that should only be used for monochrome |
2993 | * output. The result is probably unpleasant if the glyph is rendered |
2994 | * in non-monochrome modes. |
2995 | * |
2996 | * FT_LOAD_TARGET_LCD :: |
2997 | * A variant of @FT_LOAD_TARGET_LIGHT optimized for horizontally |
2998 | * decimated LCD displays. |
2999 | * |
3000 | * FT_LOAD_TARGET_LCD_V :: |
3001 | * A variant of @FT_LOAD_TARGET_NORMAL optimized for vertically |
3002 | * decimated LCD displays. |
3003 | * |
3004 | * @note: |
3005 | * You should use only _one_ of the FT_LOAD_TARGET_XXX values in your |
3006 | * `load_flags'. They can't be ORed. |
3007 | * |
3008 | * If @FT_LOAD_RENDER is also set, the glyph is rendered in the |
3009 | * corresponding mode (i.e., the mode that matches the used algorithm |
3010 | * best). An exception is FT_LOAD_TARGET_MONO since it implies |
3011 | * @FT_LOAD_MONOCHROME. |
3012 | * |
3013 | * You can use a hinting algorithm that doesn't correspond to the same |
3014 | * rendering mode. As an example, it is possible to use the `light' |
3015 | * hinting algorithm and have the results rendered in horizontal LCD |
3016 | * pixel mode, with code like |
3017 | * |
3018 | * { |
3019 | * FT_Load_Glyph( face, glyph_index, |
3020 | * load_flags | FT_LOAD_TARGET_LIGHT ); |
3021 | * |
3022 | * FT_Render_Glyph( face->glyph, FT_RENDER_MODE_LCD ); |
3023 | * } |
3024 | * |
3025 | * In general, you should stick with one rendering mode. For example, |
3026 | * switching between @FT_LOAD_TARGET_NORMAL and @FT_LOAD_TARGET_MONO |
3027 | * enforces a lot of recomputation for TrueType fonts, which is slow. |
3028 | * Another reason is caching: Selecting a different mode usually causes |
3029 | * changes in both the outlines and the rasterized bitmaps; it is thus |
3030 | * necessary to empty the cache after a mode switch to avoid false hits. |
3031 | * |
3032 | */ |
3033 | #define FT_LOAD_TARGET_( x ) ( (FT_Int32)( (x) & 15 ) << 16 ) |
3034 | |
3035 | #define FT_LOAD_TARGET_NORMAL FT_LOAD_TARGET_( FT_RENDER_MODE_NORMAL ) |
3036 | #define FT_LOAD_TARGET_LIGHT FT_LOAD_TARGET_( FT_RENDER_MODE_LIGHT ) |
3037 | #define FT_LOAD_TARGET_MONO FT_LOAD_TARGET_( FT_RENDER_MODE_MONO ) |
3038 | #define FT_LOAD_TARGET_LCD FT_LOAD_TARGET_( FT_RENDER_MODE_LCD ) |
3039 | #define FT_LOAD_TARGET_LCD_V FT_LOAD_TARGET_( FT_RENDER_MODE_LCD_V ) |
3040 | |
3041 | |
3042 | /************************************************************************** |
3043 | * |
3044 | * @macro: |
3045 | * FT_LOAD_TARGET_MODE |
3046 | * |
3047 | * @description: |
3048 | * Return the @FT_Render_Mode corresponding to a given |
3049 | * @FT_LOAD_TARGET_XXX value. |
3050 | * |
3051 | */ |
3052 | #define FT_LOAD_TARGET_MODE( x ) ( (FT_Render_Mode)( ( (x) >> 16 ) & 15 ) ) |
3053 | |
3054 | |
3055 | /*************************************************************************/ |
3056 | /* */ |
3057 | /* <Function> */ |
3058 | /* FT_Set_Transform */ |
3059 | /* */ |
3060 | /* <Description> */ |
3061 | /* Set the transformation that is applied to glyph images when they */ |
3062 | /* are loaded into a glyph slot through @FT_Load_Glyph. */ |
3063 | /* */ |
3064 | /* <InOut> */ |
3065 | /* face :: A handle to the source face object. */ |
3066 | /* */ |
3067 | /* <Input> */ |
3068 | /* matrix :: A pointer to the transformation's 2x2 matrix. Use NULL */ |
3069 | /* for the identity matrix. */ |
3070 | /* delta :: A pointer to the translation vector. Use NULL for the */ |
3071 | /* null vector. */ |
3072 | /* */ |
3073 | /* <Note> */ |
3074 | /* The transformation is only applied to scalable image formats after */ |
3075 | /* the glyph has been loaded. It means that hinting is unaltered by */ |
3076 | /* the transformation and is performed on the character size given in */ |
3077 | /* the last call to @FT_Set_Char_Size or @FT_Set_Pixel_Sizes. */ |
3078 | /* */ |
3079 | /* Note that this also transforms the `face.glyph.advance' field, but */ |
3080 | /* *not* the values in `face.glyph.metrics'. */ |
3081 | /* */ |
3082 | FT_EXPORT( void ) |
3083 | FT_Set_Transform( FT_Face face, |
3084 | FT_Matrix* matrix, |
3085 | FT_Vector* delta ); |
3086 | |
3087 | |
3088 | /*************************************************************************/ |
3089 | /* */ |
3090 | /* <Enum> */ |
3091 | /* FT_Render_Mode */ |
3092 | /* */ |
3093 | /* <Description> */ |
3094 | /* Render modes supported by FreeType~2. Each mode corresponds to a */ |
3095 | /* specific type of scanline conversion performed on the outline. */ |
3096 | /* */ |
3097 | /* For bitmap fonts and embedded bitmaps the `bitmap->pixel_mode' */ |
3098 | /* field in the @FT_GlyphSlotRec structure gives the format of the */ |
3099 | /* returned bitmap. */ |
3100 | /* */ |
3101 | /* All modes except @FT_RENDER_MODE_MONO use 256 levels of opacity, */ |
3102 | /* indicating pixel coverage. Use linear alpha blending and gamma */ |
3103 | /* correction to correctly render non-monochrome glyph bitmaps onto a */ |
3104 | /* surface; see @FT_Render_Glyph. */ |
3105 | /* */ |
3106 | /* <Values> */ |
3107 | /* FT_RENDER_MODE_NORMAL :: */ |
3108 | /* Default render mode; it corresponds to 8-bit anti-aliased */ |
3109 | /* bitmaps. */ |
3110 | /* */ |
3111 | /* FT_RENDER_MODE_LIGHT :: */ |
3112 | /* This is equivalent to @FT_RENDER_MODE_NORMAL. It is only */ |
3113 | /* defined as a separate value because render modes are also used */ |
3114 | /* indirectly to define hinting algorithm selectors. See */ |
3115 | /* @FT_LOAD_TARGET_XXX for details. */ |
3116 | /* */ |
3117 | /* FT_RENDER_MODE_MONO :: */ |
3118 | /* This mode corresponds to 1-bit bitmaps (with 2~levels of */ |
3119 | /* opacity). */ |
3120 | /* */ |
3121 | /* FT_RENDER_MODE_LCD :: */ |
3122 | /* This mode corresponds to horizontal RGB and BGR sub-pixel */ |
3123 | /* displays like LCD screens. It produces 8-bit bitmaps that are */ |
3124 | /* 3~times the width of the original glyph outline in pixels, and */ |
3125 | /* which use the @FT_PIXEL_MODE_LCD mode. */ |
3126 | /* */ |
3127 | /* FT_RENDER_MODE_LCD_V :: */ |
3128 | /* This mode corresponds to vertical RGB and BGR sub-pixel displays */ |
3129 | /* (like PDA screens, rotated LCD displays, etc.). It produces */ |
3130 | /* 8-bit bitmaps that are 3~times the height of the original */ |
3131 | /* glyph outline in pixels and use the @FT_PIXEL_MODE_LCD_V mode. */ |
3132 | /* */ |
3133 | /* <Note> */ |
3134 | /* Should you define FT_CONFIG_OPTION_SUBPIXEL_RENDERING in your */ |
3135 | /* `ftoption.h', which enables patented ClearType-style rendering, */ |
3136 | /* the LCD-optimized glyph bitmaps should be filtered to reduce color */ |
3137 | /* fringes inherent to this technology. You can either set up LCD */ |
3138 | /* filtering with @FT_Library_SetLcdFilter or @FT_Face_Properties, */ |
3139 | /* or do the filtering yourself. The default FreeType LCD rendering */ |
3140 | /* technology does not require filtering. */ |
3141 | /* */ |
3142 | /* The selected render mode only affects vector glyphs of a font. */ |
3143 | /* Embedded bitmaps often have a different pixel mode like */ |
3144 | /* @FT_PIXEL_MODE_MONO. You can use @FT_Bitmap_Convert to transform */ |
3145 | /* them into 8-bit pixmaps. */ |
3146 | /* */ |
3147 | typedef enum FT_Render_Mode_ |
3148 | { |
3149 | FT_RENDER_MODE_NORMAL = 0, |
3150 | FT_RENDER_MODE_LIGHT, |
3151 | FT_RENDER_MODE_MONO, |
3152 | FT_RENDER_MODE_LCD, |
3153 | FT_RENDER_MODE_LCD_V, |
3154 | |
3155 | FT_RENDER_MODE_MAX |
3156 | |
3157 | } FT_Render_Mode; |
3158 | |
3159 | |
3160 | /* these constants are deprecated; use the corresponding */ |
3161 | /* `FT_Render_Mode' values instead */ |
3162 | #define ft_render_mode_normal FT_RENDER_MODE_NORMAL |
3163 | #define ft_render_mode_mono FT_RENDER_MODE_MONO |
3164 | |
3165 | |
3166 | /*************************************************************************/ |
3167 | /* */ |
3168 | /* <Function> */ |
3169 | /* FT_Render_Glyph */ |
3170 | /* */ |
3171 | /* <Description> */ |
3172 | /* Convert a given glyph image to a bitmap. It does so by inspecting */ |
3173 | /* the glyph image format, finding the relevant renderer, and */ |
3174 | /* invoking it. */ |
3175 | /* */ |
3176 | /* <InOut> */ |
3177 | /* slot :: A handle to the glyph slot containing the image to */ |
3178 | /* convert. */ |
3179 | /* */ |
3180 | /* <Input> */ |
3181 | /* render_mode :: The render mode used to render the glyph image into */ |
3182 | /* a bitmap. See @FT_Render_Mode for a list of */ |
3183 | /* possible values. */ |
3184 | /* */ |
3185 | /* <Return> */ |
3186 | /* FreeType error code. 0~means success. */ |
3187 | /* */ |
3188 | /* <Note> */ |
3189 | /* To get meaningful results, font scaling values must be set with */ |
3190 | /* functions like @FT_Set_Char_Size before calling `FT_Render_Glyph'. */ |
3191 | /* */ |
3192 | /* When FreeType outputs a bitmap of a glyph, it really outputs an */ |
3193 | /* alpha coverage map. If a pixel is completely covered by a */ |
3194 | /* filled-in outline, the bitmap contains 0xFF at that pixel, meaning */ |
3195 | /* that 0xFF/0xFF fraction of that pixel is covered, meaning the */ |
3196 | /* pixel is 100% black (or 0% bright). If a pixel is only 50% */ |
3197 | /* covered (value 0x80), the pixel is made 50% black (50% bright or a */ |
3198 | /* middle shade of grey). 0% covered means 0% black (100% bright or */ |
3199 | /* white). */ |
3200 | /* */ |
3201 | /* On high-DPI screens like on smartphones and tablets, the pixels */ |
3202 | /* are so small that their chance of being completely covered and */ |
3203 | /* therefore completely black are fairly good. On the low-DPI */ |
3204 | /* screens, however, the situation is different. The pixels are too */ |
3205 | /* large for most of the details of a glyph and shades of gray are */ |
3206 | /* the norm rather than the exception. */ |
3207 | /* */ |
3208 | /* This is relevant because all our screens have a second problem: */ |
3209 | /* they are not linear. 1~+~1 is not~2. Twice the value does not */ |
3210 | /* result in twice the brightness. When a pixel is only 50% covered, */ |
3211 | /* the coverage map says 50% black, and this translates to a pixel */ |
3212 | /* value of 128 when you use 8~bits per channel (0-255). However, */ |
3213 | /* this does not translate to 50% brightness for that pixel on our */ |
3214 | /* sRGB and gamma~2.2 screens. Due to their non-linearity, they */ |
3215 | /* dwell longer in the darks and only a pixel value of about 186 */ |
3216 | /* results in 50% brightness -- 128 ends up too dark on both bright */ |
3217 | /* and dark backgrounds. The net result is that dark text looks */ |
3218 | /* burnt-out, pixely and blotchy on bright background, bright text */ |
3219 | /* too frail on dark backgrounds, and colored text on colored */ |
3220 | /* background (for example, red on green) seems to have dark halos or */ |
3221 | /* `dirt' around it. The situation is especially ugly for diagonal */ |
3222 | /* stems like in `w' glyph shapes where the quality of FreeType's */ |
3223 | /* anti-aliasing depends on the correct display of grays. On */ |
3224 | /* high-DPI screens where smaller, fully black pixels reign supreme, */ |
3225 | /* this doesn't matter, but on our low-DPI screens with all the gray */ |
3226 | /* shades, it does. 0% and 100% brightness are the same things in */ |
3227 | /* linear and non-linear space, just all the shades in-between */ |
3228 | /* aren't. */ |
3229 | /* */ |
3230 | /* The blending function for placing text over a background is */ |
3231 | /* */ |
3232 | /* { */ |
3233 | /* dst = alpha * src + (1 - alpha) * dst , */ |
3234 | /* } */ |
3235 | /* */ |
3236 | /* which is known as the OVER operator. */ |
3237 | /* */ |
3238 | /* To correctly composite an antialiased pixel of a glyph onto a */ |
3239 | /* surface, */ |
3240 | /* */ |
3241 | /* 1. take the foreground and background colors (e.g., in sRGB space) */ |
3242 | /* and apply gamma to get them in a linear space, */ |
3243 | /* */ |
3244 | /* 2. use OVER to blend the two linear colors using the glyph pixel */ |
3245 | /* as the alpha value (remember, the glyph bitmap is an alpha */ |
3246 | /* coverage bitmap), and */ |
3247 | /* */ |
3248 | /* 3. apply inverse gamma to the blended pixel and write it back to */ |
3249 | /* the image. */ |
3250 | /* */ |
3251 | /* Internal testing at Adobe found that a target inverse gamma of~1.8 */ |
3252 | /* for step~3 gives good results across a wide range of displays with */ |
3253 | /* an sRGB gamma curve or a similar one. */ |
3254 | /* */ |
3255 | /* This process can cost performance. There is an approximation that */ |
3256 | /* does not need to know about the background color; see */ |
3257 | /* https://bel.fi/alankila/lcd/ and */ |
3258 | /* https://bel.fi/alankila/lcd/alpcor.html for details. */ |
3259 | /* */ |
3260 | /* *ATTENTION*: Linear blending is even more important when dealing */ |
3261 | /* with subpixel-rendered glyphs to prevent color-fringing! A */ |
3262 | /* subpixel-rendered glyph must first be filtered with a filter that */ |
3263 | /* gives equal weight to the three color primaries and does not */ |
3264 | /* exceed a sum of 0x100, see section @lcd_filtering. Then the */ |
3265 | /* only difference to gray linear blending is that subpixel-rendered */ |
3266 | /* linear blending is done 3~times per pixel: red foreground subpixel */ |
3267 | /* to red background subpixel and so on for green and blue. */ |
3268 | /* */ |
3269 | FT_EXPORT( FT_Error ) |
3270 | FT_Render_Glyph( FT_GlyphSlot slot, |
3271 | FT_Render_Mode render_mode ); |
3272 | |
3273 | |
3274 | /*************************************************************************/ |
3275 | /* */ |
3276 | /* <Enum> */ |
3277 | /* FT_Kerning_Mode */ |
3278 | /* */ |
3279 | /* <Description> */ |
3280 | /* An enumeration to specify the format of kerning values returned by */ |
3281 | /* @FT_Get_Kerning. */ |
3282 | /* */ |
3283 | /* <Values> */ |
3284 | /* FT_KERNING_DEFAULT :: Return grid-fitted kerning distances in */ |
3285 | /* 26.6 fractional pixels. */ |
3286 | /* */ |
3287 | /* FT_KERNING_UNFITTED :: Return un-grid-fitted kerning distances in */ |
3288 | /* 26.6 fractional pixels. */ |
3289 | /* */ |
3290 | /* FT_KERNING_UNSCALED :: Return the kerning vector in original font */ |
3291 | /* units. */ |
3292 | /* */ |
3293 | /* <Note> */ |
3294 | /* FT_KERNING_DEFAULT returns full pixel values; it also makes */ |
3295 | /* FreeType heuristically scale down kerning distances at small ppem */ |
3296 | /* values so that they don't become too big. */ |
3297 | /* */ |
3298 | /* Both FT_KERNING_DEFAULT and FT_KERNING_UNFITTED use the current */ |
3299 | /* horizontal scaling factor (as set e.g. with @FT_Set_Char_Size) to */ |
3300 | /* convert font units to pixels. */ |
3301 | /* */ |
3302 | typedef enum FT_Kerning_Mode_ |
3303 | { |
3304 | FT_KERNING_DEFAULT = 0, |
3305 | FT_KERNING_UNFITTED, |
3306 | FT_KERNING_UNSCALED |
3307 | |
3308 | } FT_Kerning_Mode; |
3309 | |
3310 | |
3311 | /* these constants are deprecated; use the corresponding */ |
3312 | /* `FT_Kerning_Mode' values instead */ |
3313 | #define ft_kerning_default FT_KERNING_DEFAULT |
3314 | #define ft_kerning_unfitted FT_KERNING_UNFITTED |
3315 | #define ft_kerning_unscaled FT_KERNING_UNSCALED |
3316 | |
3317 | |
3318 | /*************************************************************************/ |
3319 | /* */ |
3320 | /* <Function> */ |
3321 | /* FT_Get_Kerning */ |
3322 | /* */ |
3323 | /* <Description> */ |
3324 | /* Return the kerning vector between two glyphs of the same face. */ |
3325 | /* */ |
3326 | /* <Input> */ |
3327 | /* face :: A handle to a source face object. */ |
3328 | /* */ |
3329 | /* left_glyph :: The index of the left glyph in the kern pair. */ |
3330 | /* */ |
3331 | /* right_glyph :: The index of the right glyph in the kern pair. */ |
3332 | /* */ |
3333 | /* kern_mode :: See @FT_Kerning_Mode for more information. */ |
3334 | /* Determines the scale and dimension of the returned */ |
3335 | /* kerning vector. */ |
3336 | /* */ |
3337 | /* <Output> */ |
3338 | /* akerning :: The kerning vector. This is either in font units, */ |
3339 | /* fractional pixels (26.6 format), or pixels for */ |
3340 | /* scalable formats, and in pixels for fixed-sizes */ |
3341 | /* formats. */ |
3342 | /* */ |
3343 | /* <Return> */ |
3344 | /* FreeType error code. 0~means success. */ |
3345 | /* */ |
3346 | /* <Note> */ |
3347 | /* Only horizontal layouts (left-to-right & right-to-left) are */ |
3348 | /* supported by this method. Other layouts, or more sophisticated */ |
3349 | /* kernings, are out of the scope of this API function -- they can be */ |
3350 | /* implemented through format-specific interfaces. */ |
3351 | /* */ |
3352 | /* Kerning for OpenType fonts implemented in a `GPOS' table is not */ |
3353 | /* supported; use @FT_HAS_KERNING to find out whether a font has data */ |
3354 | /* that can be extracted with `FT_Get_Kerning'. */ |
3355 | /* */ |
3356 | FT_EXPORT( FT_Error ) |
3357 | FT_Get_Kerning( FT_Face face, |
3358 | FT_UInt left_glyph, |
3359 | FT_UInt right_glyph, |
3360 | FT_UInt kern_mode, |
3361 | FT_Vector *akerning ); |
3362 | |
3363 | |
3364 | /*************************************************************************/ |
3365 | /* */ |
3366 | /* <Function> */ |
3367 | /* FT_Get_Track_Kerning */ |
3368 | /* */ |
3369 | /* <Description> */ |
3370 | /* Return the track kerning for a given face object at a given size. */ |
3371 | /* */ |
3372 | /* <Input> */ |
3373 | /* face :: A handle to a source face object. */ |
3374 | /* */ |
3375 | /* point_size :: The point size in 16.16 fractional points. */ |
3376 | /* */ |
3377 | /* degree :: The degree of tightness. Increasingly negative */ |
3378 | /* values represent tighter track kerning, while */ |
3379 | /* increasingly positive values represent looser track */ |
3380 | /* kerning. Value zero means no track kerning. */ |
3381 | /* */ |
3382 | /* <Output> */ |
3383 | /* akerning :: The kerning in 16.16 fractional points, to be */ |
3384 | /* uniformly applied between all glyphs. */ |
3385 | /* */ |
3386 | /* <Return> */ |
3387 | /* FreeType error code. 0~means success. */ |
3388 | /* */ |
3389 | /* <Note> */ |
3390 | /* Currently, only the Type~1 font driver supports track kerning, */ |
3391 | /* using data from AFM files (if attached with @FT_Attach_File or */ |
3392 | /* @FT_Attach_Stream). */ |
3393 | /* */ |
3394 | /* Only very few AFM files come with track kerning data; please refer */ |
3395 | /* to Adobe's AFM specification for more details. */ |
3396 | /* */ |
3397 | FT_EXPORT( FT_Error ) |
3398 | FT_Get_Track_Kerning( FT_Face face, |
3399 | FT_Fixed point_size, |
3400 | FT_Int degree, |
3401 | FT_Fixed* akerning ); |
3402 | |
3403 | |
3404 | /*************************************************************************/ |
3405 | /* */ |
3406 | /* <Function> */ |
3407 | /* FT_Get_Glyph_Name */ |
3408 | /* */ |
3409 | /* <Description> */ |
3410 | /* Retrieve the ASCII name of a given glyph in a face. This only */ |
3411 | /* works for those faces where @FT_HAS_GLYPH_NAMES(face) returns~1. */ |
3412 | /* */ |
3413 | /* <Input> */ |
3414 | /* face :: A handle to a source face object. */ |
3415 | /* */ |
3416 | /* glyph_index :: The glyph index. */ |
3417 | /* */ |
3418 | /* buffer_max :: The maximum number of bytes available in the */ |
3419 | /* buffer. */ |
3420 | /* */ |
3421 | /* <Output> */ |
3422 | /* buffer :: A pointer to a target buffer where the name is */ |
3423 | /* copied to. */ |
3424 | /* */ |
3425 | /* <Return> */ |
3426 | /* FreeType error code. 0~means success. */ |
3427 | /* */ |
3428 | /* <Note> */ |
3429 | /* An error is returned if the face doesn't provide glyph names or if */ |
3430 | /* the glyph index is invalid. In all cases of failure, the first */ |
3431 | /* byte of `buffer' is set to~0 to indicate an empty name. */ |
3432 | /* */ |
3433 | /* The glyph name is truncated to fit within the buffer if it is too */ |
3434 | /* long. The returned string is always zero-terminated. */ |
3435 | /* */ |
3436 | /* Be aware that FreeType reorders glyph indices internally so that */ |
3437 | /* glyph index~0 always corresponds to the `missing glyph' (called */ |
3438 | /* `.notdef'). */ |
3439 | /* */ |
3440 | /* This function always returns an error if the config macro */ |
3441 | /* `FT_CONFIG_OPTION_NO_GLYPH_NAMES' is not defined in `ftoption.h'. */ |
3442 | /* */ |
3443 | FT_EXPORT( FT_Error ) |
3444 | FT_Get_Glyph_Name( FT_Face face, |
3445 | FT_UInt glyph_index, |
3446 | FT_Pointer buffer, |
3447 | FT_UInt buffer_max ); |
3448 | |
3449 | |
3450 | /*************************************************************************/ |
3451 | /* */ |
3452 | /* <Function> */ |
3453 | /* FT_Get_Postscript_Name */ |
3454 | /* */ |
3455 | /* <Description> */ |
3456 | /* Retrieve the ASCII PostScript name of a given face, if available. */ |
3457 | /* This only works with PostScript, TrueType, and OpenType fonts. */ |
3458 | /* */ |
3459 | /* <Input> */ |
3460 | /* face :: A handle to the source face object. */ |
3461 | /* */ |
3462 | /* <Return> */ |
3463 | /* A pointer to the face's PostScript name. NULL if unavailable. */ |
3464 | /* */ |
3465 | /* <Note> */ |
3466 | /* The returned pointer is owned by the face and is destroyed with */ |
3467 | /* it. */ |
3468 | /* */ |
3469 | /* For variation fonts, this string changes if you select a different */ |
3470 | /* instance, and you have to call `FT_Get_PostScript_Name' again to */ |
3471 | /* retrieve it. FreeType follows Adobe TechNote #5902, `Generating */ |
3472 | /* PostScript Names for Fonts Using OpenType Font Variations'. */ |
3473 | /* */ |
3474 | /* http://wwwimages.adobe.com/content/dam/Adobe/en/devnet/font/pdfs/5902.AdobePSNameGeneration.html */ |
3475 | /* */ |
3476 | FT_EXPORT( const char* ) |
3477 | FT_Get_Postscript_Name( FT_Face face ); |
3478 | |
3479 | |
3480 | /*************************************************************************/ |
3481 | /* */ |
3482 | /* <Function> */ |
3483 | /* FT_Select_Charmap */ |
3484 | /* */ |
3485 | /* <Description> */ |
3486 | /* Select a given charmap by its encoding tag (as listed in */ |
3487 | /* `freetype.h'). */ |
3488 | /* */ |
3489 | /* <InOut> */ |
3490 | /* face :: A handle to the source face object. */ |
3491 | /* */ |
3492 | /* <Input> */ |
3493 | /* encoding :: A handle to the selected encoding. */ |
3494 | /* */ |
3495 | /* <Return> */ |
3496 | /* FreeType error code. 0~means success. */ |
3497 | /* */ |
3498 | /* <Note> */ |
3499 | /* This function returns an error if no charmap in the face */ |
3500 | /* corresponds to the encoding queried here. */ |
3501 | /* */ |
3502 | /* Because many fonts contain more than a single cmap for Unicode */ |
3503 | /* encoding, this function has some special code to select the one */ |
3504 | /* that covers Unicode best (`best' in the sense that a UCS-4 cmap is */ |
3505 | /* preferred to a UCS-2 cmap). It is thus preferable to */ |
3506 | /* @FT_Set_Charmap in this case. */ |
3507 | /* */ |
3508 | FT_EXPORT( FT_Error ) |
3509 | FT_Select_Charmap( FT_Face face, |
3510 | FT_Encoding encoding ); |
3511 | |
3512 | |
3513 | /*************************************************************************/ |
3514 | /* */ |
3515 | /* <Function> */ |
3516 | /* FT_Set_Charmap */ |
3517 | /* */ |
3518 | /* <Description> */ |
3519 | /* Select a given charmap for character code to glyph index mapping. */ |
3520 | /* */ |
3521 | /* <InOut> */ |
3522 | /* face :: A handle to the source face object. */ |
3523 | /* */ |
3524 | /* <Input> */ |
3525 | /* charmap :: A handle to the selected charmap. */ |
3526 | /* */ |
3527 | /* <Return> */ |
3528 | /* FreeType error code. 0~means success. */ |
3529 | /* */ |
3530 | /* <Note> */ |
3531 | /* This function returns an error if the charmap is not part of */ |
3532 | /* the face (i.e., if it is not listed in the `face->charmaps' */ |
3533 | /* table). */ |
3534 | /* */ |
3535 | /* It also fails if an OpenType type~14 charmap is selected (which */ |
3536 | /* doesn't map character codes to glyph indices at all). */ |
3537 | /* */ |
3538 | FT_EXPORT( FT_Error ) |
3539 | FT_Set_Charmap( FT_Face face, |
3540 | FT_CharMap charmap ); |
3541 | |
3542 | |
3543 | /************************************************************************* |
3544 | * |
3545 | * @function: |
3546 | * FT_Get_Charmap_Index |
3547 | * |
3548 | * @description: |
3549 | * Retrieve index of a given charmap. |
3550 | * |
3551 | * @input: |
3552 | * charmap :: |
3553 | * A handle to a charmap. |
3554 | * |
3555 | * @return: |
3556 | * The index into the array of character maps within the face to which |
3557 | * `charmap' belongs. If an error occurs, -1 is returned. |
3558 | * |
3559 | */ |
3560 | FT_EXPORT( FT_Int ) |
3561 | FT_Get_Charmap_Index( FT_CharMap charmap ); |
3562 | |
3563 | |
3564 | /*************************************************************************/ |
3565 | /* */ |
3566 | /* <Function> */ |
3567 | /* FT_Get_Char_Index */ |
3568 | /* */ |
3569 | /* <Description> */ |
3570 | /* Return the glyph index of a given character code. This function */ |
3571 | /* uses the currently selected charmap to do the mapping. */ |
3572 | /* */ |
3573 | /* <Input> */ |
3574 | /* face :: A handle to the source face object. */ |
3575 | /* */ |
3576 | /* charcode :: The character code. */ |
3577 | /* */ |
3578 | /* <Return> */ |
3579 | /* The glyph index. 0~means `undefined character code'. */ |
3580 | /* */ |
3581 | /* <Note> */ |
3582 | /* If you use FreeType to manipulate the contents of font files */ |
3583 | /* directly, be aware that the glyph index returned by this function */ |
3584 | /* doesn't always correspond to the internal indices used within the */ |
3585 | /* file. This is done to ensure that value~0 always corresponds to */ |
3586 | /* the `missing glyph'. If the first glyph is not named `.notdef', */ |
3587 | /* then for Type~1 and Type~42 fonts, `.notdef' will be moved into */ |
3588 | /* the glyph ID~0 position, and whatever was there will be moved to */ |
3589 | /* the position `.notdef' had. For Type~1 fonts, if there is no */ |
3590 | /* `.notdef' glyph at all, then one will be created at index~0 and */ |
3591 | /* whatever was there will be moved to the last index -- Type~42 */ |
3592 | /* fonts are considered invalid under this condition. */ |
3593 | /* */ |
3594 | FT_EXPORT( FT_UInt ) |
3595 | FT_Get_Char_Index( FT_Face face, |
3596 | FT_ULong charcode ); |
3597 | |
3598 | |
3599 | /*************************************************************************/ |
3600 | /* */ |
3601 | /* <Function> */ |
3602 | /* FT_Get_First_Char */ |
3603 | /* */ |
3604 | /* <Description> */ |
3605 | /* Return the first character code in the current charmap of a given */ |
3606 | /* face, together with its corresponding glyph index. */ |
3607 | /* */ |
3608 | /* <Input> */ |
3609 | /* face :: A handle to the source face object. */ |
3610 | /* */ |
3611 | /* <Output> */ |
3612 | /* agindex :: Glyph index of first character code. 0~if charmap is */ |
3613 | /* empty. */ |
3614 | /* */ |
3615 | /* <Return> */ |
3616 | /* The charmap's first character code. */ |
3617 | /* */ |
3618 | /* <Note> */ |
3619 | /* You should use this function together with @FT_Get_Next_Char to */ |
3620 | /* parse all character codes available in a given charmap. The code */ |
3621 | /* should look like this: */ |
3622 | /* */ |
3623 | /* { */ |
3624 | /* FT_ULong charcode; */ |
3625 | /* FT_UInt gindex; */ |
3626 | /* */ |
3627 | /* */ |
3628 | /* charcode = FT_Get_First_Char( face, &gindex ); */ |
3629 | /* while ( gindex != 0 ) */ |
3630 | /* { */ |
3631 | /* ... do something with (charcode,gindex) pair ... */ |
3632 | /* */ |
3633 | /* charcode = FT_Get_Next_Char( face, charcode, &gindex ); */ |
3634 | /* } */ |
3635 | /* } */ |
3636 | /* */ |
3637 | /* Be aware that character codes can have values up to 0xFFFFFFFF; */ |
3638 | /* this might happen for non-Unicode or malformed cmaps. However, */ |
3639 | /* even with regular Unicode encoding, so-called `last resort fonts' */ |
3640 | /* (using SFNT cmap format 13, see function @FT_Get_CMap_Format) */ |
3641 | /* normally have entries for all Unicode characters up to 0x1FFFFF, */ |
3642 | /* which can cause *a lot* of iterations. */ |
3643 | /* */ |
3644 | /* Note that `*agindex' is set to~0 if the charmap is empty. The */ |
3645 | /* result itself can be~0 in two cases: if the charmap is empty or */ |
3646 | /* if the value~0 is the first valid character code. */ |
3647 | /* */ |
3648 | FT_EXPORT( FT_ULong ) |
3649 | FT_Get_First_Char( FT_Face face, |
3650 | FT_UInt *agindex ); |
3651 | |
3652 | |
3653 | /*************************************************************************/ |
3654 | /* */ |
3655 | /* <Function> */ |
3656 | /* FT_Get_Next_Char */ |
3657 | /* */ |
3658 | /* <Description> */ |
3659 | /* Return the next character code in the current charmap of a given */ |
3660 | /* face following the value `char_code', as well as the corresponding */ |
3661 | /* glyph index. */ |
3662 | /* */ |
3663 | /* <Input> */ |
3664 | /* face :: A handle to the source face object. */ |
3665 | /* */ |
3666 | /* char_code :: The starting character code. */ |
3667 | /* */ |
3668 | /* <Output> */ |
3669 | /* agindex :: Glyph index of next character code. 0~if charmap */ |
3670 | /* is empty. */ |
3671 | /* */ |
3672 | /* <Return> */ |
3673 | /* The charmap's next character code. */ |
3674 | /* */ |
3675 | /* <Note> */ |
3676 | /* You should use this function with @FT_Get_First_Char to walk */ |
3677 | /* over all character codes available in a given charmap. See the */ |
3678 | /* note for that function for a simple code example. */ |
3679 | /* */ |
3680 | /* Note that `*agindex' is set to~0 when there are no more codes in */ |
3681 | /* the charmap. */ |
3682 | /* */ |
3683 | FT_EXPORT( FT_ULong ) |
3684 | FT_Get_Next_Char( FT_Face face, |
3685 | FT_ULong char_code, |
3686 | FT_UInt *agindex ); |
3687 | |
3688 | |
3689 | /************************************************************************* |
3690 | * |
3691 | * @function: |
3692 | * FT_Face_Properties |
3693 | * |
3694 | * @description: |
3695 | * Set or override certain (library or module-wide) properties on a |
3696 | * face-by-face basis. Useful for finer-grained control and avoiding |
3697 | * locks on shared structures (threads can modify their own faces as |
3698 | * they see fit). |
3699 | * |
3700 | * Contrary to @FT_Property_Set, this function uses @FT_Parameter so |
3701 | * that you can pass multiple properties to the target face in one call. |
3702 | * Note that only a subset of the available properties can be |
3703 | * controlled. |
3704 | * |
3705 | * * Stem darkening (@FT_PARAM_TAG_STEM_DARKENING, corresponding to the |
3706 | * property `no-stem-darkening' provided by the `autofit' and `cff' |
3707 | * modules; see @no-stem-darkening[autofit] and |
3708 | * @no-stem-darkening[cff]). |
3709 | * |
3710 | * * LCD filter weights (@FT_PARAM_TAG_LCD_FILTER_WEIGHTS, corresponding |
3711 | * to function @FT_Library_SetLcdFilterWeights). |
3712 | * |
3713 | * * Seed value for the CFF `random' operator |
3714 | * (@FT_PARAM_TAG_RANDOM_SEED, corresponding to the `random-seed' |
3715 | * property provided by the `cff' module; see @random-seed). |
3716 | * |
3717 | * Pass NULL as `data' in @FT_Parameter for a given tag to reset the |
3718 | * option and use the library or module default again. |
3719 | * |
3720 | * @input: |
3721 | * face :: |
3722 | * A handle to the source face object. |
3723 | * |
3724 | * num_properties :: |
3725 | * The number of properties that follow. |
3726 | * |
3727 | * properties :: |
3728 | * A handle to an @FT_Parameter array with `num_properties' elements. |
3729 | * |
3730 | * @return: |
3731 | * FreeType error code. 0~means success. |
3732 | * |
3733 | * @note: |
3734 | * Here an example that sets three properties. You must define |
3735 | * FT_CONFIG_OPTION_SUBPIXEL_RENDERING to make the LCD filter examples |
3736 | * work. |
3737 | * |
3738 | * { |
3739 | * FT_Parameter property1; |
3740 | * FT_Bool darken_stems = 1; |
3741 | * |
3742 | * FT_Parameter property2; |
3743 | * FT_LcdFiveTapFilter custom_weight = |
3744 | * { 0x11, 0x44, 0x56, 0x44, 0x11 }; |
3745 | * |
3746 | * FT_Parameter property3; |
3747 | * FT_Int32 random_seed = 314159265; |
3748 | * |
3749 | * FT_Parameter properties[3] = { property1, |
3750 | * property2, |
3751 | * property3 }; |
3752 | * |
3753 | * |
3754 | * property1.tag = FT_PARAM_TAG_STEM_DARKENING; |
3755 | * property1.data = &darken_stems; |
3756 | * |
3757 | * property2.tag = FT_PARAM_TAG_LCD_FILTER_WEIGHTS; |
3758 | * property2.data = custom_weight; |
3759 | * |
3760 | * property3.tag = FT_PARAM_TAG_RANDOM_SEED; |
3761 | * property3.data = &random_seed; |
3762 | * |
3763 | * FT_Face_Properties( face, 3, properties ); |
3764 | * } |
3765 | * |
3766 | * The next example resets a single property to its default value. |
3767 | * |
3768 | * { |
3769 | * FT_Parameter property; |
3770 | * |
3771 | * |
3772 | * property.tag = FT_PARAM_TAG_LCD_FILTER_WEIGHTS; |
3773 | * property.data = NULL; |
3774 | * |
3775 | * FT_Face_Properties( face, 1, &property ); |
3776 | * } |
3777 | * |
3778 | */ |
3779 | FT_EXPORT( FT_Error ) |
3780 | FT_Face_Properties( FT_Face face, |
3781 | FT_UInt num_properties, |
3782 | FT_Parameter* properties ); |
3783 | |
3784 | |
3785 | /*************************************************************************/ |
3786 | /* */ |
3787 | /* <Function> */ |
3788 | /* FT_Get_Name_Index */ |
3789 | /* */ |
3790 | /* <Description> */ |
3791 | /* Return the glyph index of a given glyph name. */ |
3792 | /* */ |
3793 | /* <Input> */ |
3794 | /* face :: A handle to the source face object. */ |
3795 | /* */ |
3796 | /* glyph_name :: The glyph name. */ |
3797 | /* */ |
3798 | /* <Return> */ |
3799 | /* The glyph index. 0~means `undefined character code'. */ |
3800 | /* */ |
3801 | FT_EXPORT( FT_UInt ) |
3802 | FT_Get_Name_Index( FT_Face face, |
3803 | FT_String* glyph_name ); |
3804 | |
3805 | |
3806 | /************************************************************************* |
3807 | * |
3808 | * @macro: |
3809 | * FT_SUBGLYPH_FLAG_XXX |
3810 | * |
3811 | * @description: |
3812 | * A list of constants describing subglyphs. Please refer to the |
3813 | * `glyf' table description in the OpenType specification for the |
3814 | * meaning of the various flags (which get synthesized for |
3815 | * non-OpenType subglyphs). |
3816 | * |
3817 | * @values: |
3818 | * FT_SUBGLYPH_FLAG_ARGS_ARE_WORDS :: |
3819 | * FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES :: |
3820 | * FT_SUBGLYPH_FLAG_ROUND_XY_TO_GRID :: |
3821 | * FT_SUBGLYPH_FLAG_SCALE :: |
3822 | * FT_SUBGLYPH_FLAG_XY_SCALE :: |
3823 | * FT_SUBGLYPH_FLAG_2X2 :: |
3824 | * FT_SUBGLYPH_FLAG_USE_MY_METRICS :: |
3825 | * |
3826 | */ |
3827 | #define FT_SUBGLYPH_FLAG_ARGS_ARE_WORDS 1 |
3828 | #define FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES 2 |
3829 | #define FT_SUBGLYPH_FLAG_ROUND_XY_TO_GRID 4 |
3830 | #define FT_SUBGLYPH_FLAG_SCALE 8 |
3831 | #define FT_SUBGLYPH_FLAG_XY_SCALE 0x40 |
3832 | #define FT_SUBGLYPH_FLAG_2X2 0x80 |
3833 | #define FT_SUBGLYPH_FLAG_USE_MY_METRICS 0x200 |
3834 | |
3835 | |
3836 | /************************************************************************* |
3837 | * |
3838 | * @func: |
3839 | * FT_Get_SubGlyph_Info |
3840 | * |
3841 | * @description: |
3842 | * Retrieve a description of a given subglyph. Only use it if |
3843 | * `glyph->format' is @FT_GLYPH_FORMAT_COMPOSITE; an error is |
3844 | * returned otherwise. |
3845 | * |
3846 | * @input: |
3847 | * glyph :: |
3848 | * The source glyph slot. |
3849 | * |
3850 | * sub_index :: |
3851 | * The index of the subglyph. Must be less than |
3852 | * `glyph->num_subglyphs'. |
3853 | * |
3854 | * @output: |
3855 | * p_index :: |
3856 | * The glyph index of the subglyph. |
3857 | * |
3858 | * p_flags :: |
3859 | * The subglyph flags, see @FT_SUBGLYPH_FLAG_XXX. |
3860 | * |
3861 | * p_arg1 :: |
3862 | * The subglyph's first argument (if any). |
3863 | * |
3864 | * p_arg2 :: |
3865 | * The subglyph's second argument (if any). |
3866 | * |
3867 | * p_transform :: |
3868 | * The subglyph transformation (if any). |
3869 | * |
3870 | * @return: |
3871 | * FreeType error code. 0~means success. |
3872 | * |
3873 | * @note: |
3874 | * The values of `*p_arg1', `*p_arg2', and `*p_transform' must be |
3875 | * interpreted depending on the flags returned in `*p_flags'. See the |
3876 | * OpenType specification for details. |
3877 | * |
3878 | */ |
3879 | FT_EXPORT( FT_Error ) |
3880 | FT_Get_SubGlyph_Info( FT_GlyphSlot glyph, |
3881 | FT_UInt sub_index, |
3882 | FT_Int *p_index, |
3883 | FT_UInt *p_flags, |
3884 | FT_Int *p_arg1, |
3885 | FT_Int *p_arg2, |
3886 | FT_Matrix *p_transform ); |
3887 | |
3888 | |
3889 | /*************************************************************************/ |
3890 | /* */ |
3891 | /* <Enum> */ |
3892 | /* FT_FSTYPE_XXX */ |
3893 | /* */ |
3894 | /* <Description> */ |
3895 | /* A list of bit flags used in the `fsType' field of the OS/2 table */ |
3896 | /* in a TrueType or OpenType font and the `FSType' entry in a */ |
3897 | /* PostScript font. These bit flags are returned by */ |
3898 | /* @FT_Get_FSType_Flags; they inform client applications of embedding */ |
3899 | /* and subsetting restrictions associated with a font. */ |
3900 | /* */ |
3901 | /* See */ |
3902 | /* http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/FontPolicies.pdf */ |
3903 | /* for more details. */ |
3904 | /* */ |
3905 | /* <Values> */ |
3906 | /* FT_FSTYPE_INSTALLABLE_EMBEDDING :: */ |
3907 | /* Fonts with no fsType bit set may be embedded and permanently */ |
3908 | /* installed on the remote system by an application. */ |
3909 | /* */ |
3910 | /* FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING :: */ |
3911 | /* Fonts that have only this bit set must not be modified, embedded */ |
3912 | /* or exchanged in any manner without first obtaining permission of */ |
3913 | /* the font software copyright owner. */ |
3914 | /* */ |
3915 | /* FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING :: */ |
3916 | /* The font may be embedded and temporarily loaded on the remote */ |
3917 | /* system. Documents containing Preview & Print fonts must be */ |
3918 | /* opened `read-only'; no edits can be applied to the document. */ |
3919 | /* */ |
3920 | /* FT_FSTYPE_EDITABLE_EMBEDDING :: */ |
3921 | /* The font may be embedded but must only be installed temporarily */ |
3922 | /* on other systems. In contrast to Preview & Print fonts, */ |
3923 | /* documents containing editable fonts may be opened for reading, */ |
3924 | /* editing is permitted, and changes may be saved. */ |
3925 | /* */ |
3926 | /* FT_FSTYPE_NO_SUBSETTING :: */ |
3927 | /* The font may not be subsetted prior to embedding. */ |
3928 | /* */ |
3929 | /* FT_FSTYPE_BITMAP_EMBEDDING_ONLY :: */ |
3930 | /* Only bitmaps contained in the font may be embedded; no outline */ |
3931 | /* data may be embedded. If there are no bitmaps available in the */ |
3932 | /* font, then the font is unembeddable. */ |
3933 | /* */ |
3934 | /* <Note> */ |
3935 | /* The flags are ORed together, thus more than a single value can be */ |
3936 | /* returned. */ |
3937 | /* */ |
3938 | /* While the `fsType' flags can indicate that a font may be embedded, */ |
3939 | /* a license with the font vendor may be separately required to use */ |
3940 | /* the font in this way. */ |
3941 | /* */ |
3942 | #define FT_FSTYPE_INSTALLABLE_EMBEDDING 0x0000 |
3943 | #define FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING 0x0002 |
3944 | #define FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING 0x0004 |
3945 | #define FT_FSTYPE_EDITABLE_EMBEDDING 0x0008 |
3946 | #define FT_FSTYPE_NO_SUBSETTING 0x0100 |
3947 | #define FT_FSTYPE_BITMAP_EMBEDDING_ONLY 0x0200 |
3948 | |
3949 | |
3950 | /*************************************************************************/ |
3951 | /* */ |
3952 | /* <Function> */ |
3953 | /* FT_Get_FSType_Flags */ |
3954 | /* */ |
3955 | /* <Description> */ |
3956 | /* Return the `fsType' flags for a font. */ |
3957 | /* */ |
3958 | /* <Input> */ |
3959 | /* face :: A handle to the source face object. */ |
3960 | /* */ |
3961 | /* <Return> */ |
3962 | /* The `fsType' flags, see @FT_FSTYPE_XXX. */ |
3963 | /* */ |
3964 | /* <Note> */ |
3965 | /* Use this function rather than directly reading the `fs_type' field */ |
3966 | /* in the @PS_FontInfoRec structure, which is only guaranteed to */ |
3967 | /* return the correct results for Type~1 fonts. */ |
3968 | /* */ |
3969 | /* <Since> */ |
3970 | /* 2.3.8 */ |
3971 | /* */ |
3972 | FT_EXPORT( FT_UShort ) |
3973 | FT_Get_FSType_Flags( FT_Face face ); |
3974 | |
3975 | |
3976 | /*************************************************************************/ |
3977 | /* */ |
3978 | /* <Section> */ |
3979 | /* glyph_variants */ |
3980 | /* */ |
3981 | /* <Title> */ |
3982 | /* Unicode Variation Sequences */ |
3983 | /* */ |
3984 | /* <Abstract> */ |
3985 | /* The FreeType~2 interface to Unicode Variation Sequences (UVS), */ |
3986 | /* using the SFNT cmap format~14. */ |
3987 | /* */ |
3988 | /* <Description> */ |
3989 | /* Many characters, especially for CJK scripts, have variant forms. */ |
3990 | /* They are a sort of grey area somewhere between being totally */ |
3991 | /* irrelevant and semantically distinct; for this reason, the Unicode */ |
3992 | /* consortium decided to introduce Variation Sequences (VS), */ |
3993 | /* consisting of a Unicode base character and a variation selector */ |
3994 | /* instead of further extending the already huge number of */ |
3995 | /* characters. */ |
3996 | /* */ |
3997 | /* Unicode maintains two different sets, namely `Standardized */ |
3998 | /* Variation Sequences' and registered `Ideographic Variation */ |
3999 | /* Sequences' (IVS), collected in the `Ideographic Variation */ |
4000 | /* Database' (IVD). */ |
4001 | /* */ |
4002 | /* http://unicode.org/Public/UCD/latest/ucd/StandardizedVariants.txt */ |
4003 | /* http://unicode.org/reports/tr37/ */ |
4004 | /* http://unicode.org/ivd/ */ |
4005 | /* */ |
4006 | /* To date (January 2017), the character with the most ideographic */ |
4007 | /* variations is U+9089, having 32 such IVS. */ |
4008 | /* */ |
4009 | /* Three Mongolian Variation Selectors have the values U+180B-U+180D; */ |
4010 | /* 256 generic Variation Selectors are encoded in the ranges */ |
4011 | /* U+FE00-U+FE0F and U+E0100-U+E01EF. IVS currently use Variation */ |
4012 | /* Selectors from the range U+E0100-U+E01EF only. */ |
4013 | /* */ |
4014 | /* A VS consists of the base character value followed by a single */ |
4015 | /* Variation Selector. For example, to get the first variation of */ |
4016 | /* U+9089, you have to write the character sequence `U+9089 U+E0100'. */ |
4017 | /* */ |
4018 | /* Adobe and MS decided to support both standardized and ideographic */ |
4019 | /* VS with a new cmap subtable (format~14). It is an odd subtable */ |
4020 | /* because it is not a mapping of input code points to glyphs, but */ |
4021 | /* contains lists of all variations supported by the font. */ |
4022 | /* */ |
4023 | /* A variation may be either `default' or `non-default' for a given */ |
4024 | /* font. A default variation is the one you will get for that code */ |
4025 | /* point if you look it up in the standard Unicode cmap. A */ |
4026 | /* non-default variation is a different glyph. */ |
4027 | /* */ |
4028 | /*************************************************************************/ |
4029 | |
4030 | |
4031 | /*************************************************************************/ |
4032 | /* */ |
4033 | /* <Function> */ |
4034 | /* FT_Face_GetCharVariantIndex */ |
4035 | /* */ |
4036 | /* <Description> */ |
4037 | /* Return the glyph index of a given character code as modified by */ |
4038 | /* the variation selector. */ |
4039 | /* */ |
4040 | /* <Input> */ |
4041 | /* face :: */ |
4042 | /* A handle to the source face object. */ |
4043 | /* */ |
4044 | /* charcode :: */ |
4045 | /* The character code point in Unicode. */ |
4046 | /* */ |
4047 | /* variantSelector :: */ |
4048 | /* The Unicode code point of the variation selector. */ |
4049 | /* */ |
4050 | /* <Return> */ |
4051 | /* The glyph index. 0~means either `undefined character code', or */ |
4052 | /* `undefined selector code', or `no variation selector cmap */ |
4053 | /* subtable', or `current CharMap is not Unicode'. */ |
4054 | /* */ |
4055 | /* <Note> */ |
4056 | /* If you use FreeType to manipulate the contents of font files */ |
4057 | /* directly, be aware that the glyph index returned by this function */ |
4058 | /* doesn't always correspond to the internal indices used within */ |
4059 | /* the file. This is done to ensure that value~0 always corresponds */ |
4060 | /* to the `missing glyph'. */ |
4061 | /* */ |
4062 | /* This function is only meaningful if */ |
4063 | /* a) the font has a variation selector cmap sub table, */ |
4064 | /* and */ |
4065 | /* b) the current charmap has a Unicode encoding. */ |
4066 | /* */ |
4067 | /* <Since> */ |
4068 | /* 2.3.6 */ |
4069 | /* */ |
4070 | FT_EXPORT( FT_UInt ) |
4071 | FT_Face_GetCharVariantIndex( FT_Face face, |
4072 | FT_ULong charcode, |
4073 | FT_ULong variantSelector ); |
4074 | |
4075 | |
4076 | /*************************************************************************/ |
4077 | /* */ |
4078 | /* <Function> */ |
4079 | /* FT_Face_GetCharVariantIsDefault */ |
4080 | /* */ |
4081 | /* <Description> */ |
4082 | /* Check whether this variation of this Unicode character is the one */ |
4083 | /* to be found in the `cmap'. */ |
4084 | /* */ |
4085 | /* <Input> */ |
4086 | /* face :: */ |
4087 | /* A handle to the source face object. */ |
4088 | /* */ |
4089 | /* charcode :: */ |
4090 | /* The character codepoint in Unicode. */ |
4091 | /* */ |
4092 | /* variantSelector :: */ |
4093 | /* The Unicode codepoint of the variation selector. */ |
4094 | /* */ |
4095 | /* <Return> */ |
4096 | /* 1~if found in the standard (Unicode) cmap, 0~if found in the */ |
4097 | /* variation selector cmap, or -1 if it is not a variation. */ |
4098 | /* */ |
4099 | /* <Note> */ |
4100 | /* This function is only meaningful if the font has a variation */ |
4101 | /* selector cmap subtable. */ |
4102 | /* */ |
4103 | /* <Since> */ |
4104 | /* 2.3.6 */ |
4105 | /* */ |
4106 | FT_EXPORT( FT_Int ) |
4107 | FT_Face_GetCharVariantIsDefault( FT_Face face, |
4108 | FT_ULong charcode, |
4109 | FT_ULong variantSelector ); |
4110 | |
4111 | |
4112 | /*************************************************************************/ |
4113 | /* */ |
4114 | /* <Function> */ |
4115 | /* FT_Face_GetVariantSelectors */ |
4116 | /* */ |
4117 | /* <Description> */ |
4118 | /* Return a zero-terminated list of Unicode variation selectors found */ |
4119 | /* in the font. */ |
4120 | /* */ |
4121 | /* <Input> */ |
4122 | /* face :: */ |
4123 | /* A handle to the source face object. */ |
4124 | /* */ |
4125 | /* <Return> */ |
4126 | /* A pointer to an array of selector code points, or NULL if there is */ |
4127 | /* no valid variation selector cmap subtable. */ |
4128 | /* */ |
4129 | /* <Note> */ |
4130 | /* The last item in the array is~0; the array is owned by the */ |
4131 | /* @FT_Face object but can be overwritten or released on the next */ |
4132 | /* call to a FreeType function. */ |
4133 | /* */ |
4134 | /* <Since> */ |
4135 | /* 2.3.6 */ |
4136 | /* */ |
4137 | FT_EXPORT( FT_UInt32* ) |
4138 | FT_Face_GetVariantSelectors( FT_Face face ); |
4139 | |
4140 | |
4141 | /*************************************************************************/ |
4142 | /* */ |
4143 | /* <Function> */ |
4144 | /* FT_Face_GetVariantsOfChar */ |
4145 | /* */ |
4146 | /* <Description> */ |
4147 | /* Return a zero-terminated list of Unicode variation selectors found */ |
4148 | /* for the specified character code. */ |
4149 | /* */ |
4150 | /* <Input> */ |
4151 | /* face :: */ |
4152 | /* A handle to the source face object. */ |
4153 | /* */ |
4154 | /* charcode :: */ |
4155 | /* The character codepoint in Unicode. */ |
4156 | /* */ |
4157 | /* <Return> */ |
4158 | /* A pointer to an array of variation selector code points that are */ |
4159 | /* active for the given character, or NULL if the corresponding list */ |
4160 | /* is empty. */ |
4161 | /* */ |
4162 | /* <Note> */ |
4163 | /* The last item in the array is~0; the array is owned by the */ |
4164 | /* @FT_Face object but can be overwritten or released on the next */ |
4165 | /* call to a FreeType function. */ |
4166 | /* */ |
4167 | /* <Since> */ |
4168 | /* 2.3.6 */ |
4169 | /* */ |
4170 | FT_EXPORT( FT_UInt32* ) |
4171 | FT_Face_GetVariantsOfChar( FT_Face face, |
4172 | FT_ULong charcode ); |
4173 | |
4174 | |
4175 | /*************************************************************************/ |
4176 | /* */ |
4177 | /* <Function> */ |
4178 | /* FT_Face_GetCharsOfVariant */ |
4179 | /* */ |
4180 | /* <Description> */ |
4181 | /* Return a zero-terminated list of Unicode character codes found for */ |
4182 | /* the specified variation selector. */ |
4183 | /* */ |
4184 | /* <Input> */ |
4185 | /* face :: */ |
4186 | /* A handle to the source face object. */ |
4187 | /* */ |
4188 | /* variantSelector :: */ |
4189 | /* The variation selector code point in Unicode. */ |
4190 | /* */ |
4191 | /* <Return> */ |
4192 | /* A list of all the code points that are specified by this selector */ |
4193 | /* (both default and non-default codes are returned) or NULL if there */ |
4194 | /* is no valid cmap or the variation selector is invalid. */ |
4195 | /* */ |
4196 | /* <Note> */ |
4197 | /* The last item in the array is~0; the array is owned by the */ |
4198 | /* @FT_Face object but can be overwritten or released on the next */ |
4199 | /* call to a FreeType function. */ |
4200 | /* */ |
4201 | /* <Since> */ |
4202 | /* 2.3.6 */ |
4203 | /* */ |
4204 | FT_EXPORT( FT_UInt32* ) |
4205 | FT_Face_GetCharsOfVariant( FT_Face face, |
4206 | FT_ULong variantSelector ); |
4207 | |
4208 | |
4209 | /*************************************************************************/ |
4210 | /* */ |
4211 | /* <Section> */ |
4212 | /* computations */ |
4213 | /* */ |
4214 | /* <Title> */ |
4215 | /* Computations */ |
4216 | /* */ |
4217 | /* <Abstract> */ |
4218 | /* Crunching fixed numbers and vectors. */ |
4219 | /* */ |
4220 | /* <Description> */ |
4221 | /* This section contains various functions used to perform */ |
4222 | /* computations on 16.16 fixed-float numbers or 2d vectors. */ |
4223 | /* */ |
4224 | /* <Order> */ |
4225 | /* FT_MulDiv */ |
4226 | /* FT_MulFix */ |
4227 | /* FT_DivFix */ |
4228 | /* FT_RoundFix */ |
4229 | /* FT_CeilFix */ |
4230 | /* FT_FloorFix */ |
4231 | /* FT_Vector_Transform */ |
4232 | /* FT_Matrix_Multiply */ |
4233 | /* FT_Matrix_Invert */ |
4234 | /* */ |
4235 | /*************************************************************************/ |
4236 | |
4237 | |
4238 | /*************************************************************************/ |
4239 | /* */ |
4240 | /* <Function> */ |
4241 | /* FT_MulDiv */ |
4242 | /* */ |
4243 | /* <Description> */ |
4244 | /* Compute `(a*b)/c' with maximum accuracy, using a 64-bit */ |
4245 | /* intermediate integer whenever necessary. */ |
4246 | /* */ |
4247 | /* This function isn't necessarily as fast as some processor specific */ |
4248 | /* operations, but is at least completely portable. */ |
4249 | /* */ |
4250 | /* <Input> */ |
4251 | /* a :: The first multiplier. */ |
4252 | /* */ |
4253 | /* b :: The second multiplier. */ |
4254 | /* */ |
4255 | /* c :: The divisor. */ |
4256 | /* */ |
4257 | /* <Return> */ |
4258 | /* The result of `(a*b)/c'. This function never traps when trying to */ |
4259 | /* divide by zero; it simply returns `MaxInt' or `MinInt' depending */ |
4260 | /* on the signs of `a' and `b'. */ |
4261 | /* */ |
4262 | FT_EXPORT( FT_Long ) |
4263 | FT_MulDiv( FT_Long a, |
4264 | FT_Long b, |
4265 | FT_Long c ); |
4266 | |
4267 | |
4268 | /*************************************************************************/ |
4269 | /* */ |
4270 | /* <Function> */ |
4271 | /* FT_MulFix */ |
4272 | /* */ |
4273 | /* <Description> */ |
4274 | /* Compute `(a*b)/0x10000' with maximum accuracy. Its main use is to */ |
4275 | /* multiply a given value by a 16.16 fixed-point factor. */ |
4276 | /* */ |
4277 | /* <Input> */ |
4278 | /* a :: The first multiplier. */ |
4279 | /* */ |
4280 | /* b :: The second multiplier. Use a 16.16 factor here whenever */ |
4281 | /* possible (see note below). */ |
4282 | /* */ |
4283 | /* <Return> */ |
4284 | /* The result of `(a*b)/0x10000'. */ |
4285 | /* */ |
4286 | /* <Note> */ |
4287 | /* This function has been optimized for the case where the absolute */ |
4288 | /* value of `a' is less than 2048, and `b' is a 16.16 scaling factor. */ |
4289 | /* As this happens mainly when scaling from notional units to */ |
4290 | /* fractional pixels in FreeType, it resulted in noticeable speed */ |
4291 | /* improvements between versions 2.x and 1.x. */ |
4292 | /* */ |
4293 | /* As a conclusion, always try to place a 16.16 factor as the */ |
4294 | /* _second_ argument of this function; this can make a great */ |
4295 | /* difference. */ |
4296 | /* */ |
4297 | FT_EXPORT( FT_Long ) |
4298 | FT_MulFix( FT_Long a, |
4299 | FT_Long b ); |
4300 | |
4301 | |
4302 | /*************************************************************************/ |
4303 | /* */ |
4304 | /* <Function> */ |
4305 | /* FT_DivFix */ |
4306 | /* */ |
4307 | /* <Description> */ |
4308 | /* Compute `(a*0x10000)/b' with maximum accuracy. Its main use is to */ |
4309 | /* divide a given value by a 16.16 fixed-point factor. */ |
4310 | /* */ |
4311 | /* <Input> */ |
4312 | /* a :: The numerator. */ |
4313 | /* */ |
4314 | /* b :: The denominator. Use a 16.16 factor here. */ |
4315 | /* */ |
4316 | /* <Return> */ |
4317 | /* The result of `(a*0x10000)/b'. */ |
4318 | /* */ |
4319 | FT_EXPORT( FT_Long ) |
4320 | FT_DivFix( FT_Long a, |
4321 | FT_Long b ); |
4322 | |
4323 | |
4324 | /*************************************************************************/ |
4325 | /* */ |
4326 | /* <Function> */ |
4327 | /* FT_RoundFix */ |
4328 | /* */ |
4329 | /* <Description> */ |
4330 | /* Round a 16.16 fixed number. */ |
4331 | /* */ |
4332 | /* <Input> */ |
4333 | /* a :: The number to be rounded. */ |
4334 | /* */ |
4335 | /* <Return> */ |
4336 | /* `a' rounded to the nearest 16.16 fixed integer, halfway cases away */ |
4337 | /* from zero. */ |
4338 | /* */ |
4339 | /* <Note> */ |
4340 | /* The function uses wrap-around arithmetic. */ |
4341 | /* */ |
4342 | FT_EXPORT( FT_Fixed ) |
4343 | FT_RoundFix( FT_Fixed a ); |
4344 | |
4345 | |
4346 | /*************************************************************************/ |
4347 | /* */ |
4348 | /* <Function> */ |
4349 | /* FT_CeilFix */ |
4350 | /* */ |
4351 | /* <Description> */ |
4352 | /* Compute the smallest following integer of a 16.16 fixed number. */ |
4353 | /* */ |
4354 | /* <Input> */ |
4355 | /* a :: The number for which the ceiling function is to be computed. */ |
4356 | /* */ |
4357 | /* <Return> */ |
4358 | /* `a' rounded towards plus infinity. */ |
4359 | /* */ |
4360 | /* <Note> */ |
4361 | /* The function uses wrap-around arithmetic. */ |
4362 | /* */ |
4363 | FT_EXPORT( FT_Fixed ) |
4364 | FT_CeilFix( FT_Fixed a ); |
4365 | |
4366 | |
4367 | /*************************************************************************/ |
4368 | /* */ |
4369 | /* <Function> */ |
4370 | /* FT_FloorFix */ |
4371 | /* */ |
4372 | /* <Description> */ |
4373 | /* Compute the largest previous integer of a 16.16 fixed number. */ |
4374 | /* */ |
4375 | /* <Input> */ |
4376 | /* a :: The number for which the floor function is to be computed. */ |
4377 | /* */ |
4378 | /* <Return> */ |
4379 | /* `a' rounded towards minus infinity. */ |
4380 | /* */ |
4381 | FT_EXPORT( FT_Fixed ) |
4382 | FT_FloorFix( FT_Fixed a ); |
4383 | |
4384 | |
4385 | /*************************************************************************/ |
4386 | /* */ |
4387 | /* <Function> */ |
4388 | /* FT_Vector_Transform */ |
4389 | /* */ |
4390 | /* <Description> */ |
4391 | /* Transform a single vector through a 2x2 matrix. */ |
4392 | /* */ |
4393 | /* <InOut> */ |
4394 | /* vector :: The target vector to transform. */ |
4395 | /* */ |
4396 | /* <Input> */ |
4397 | /* matrix :: A pointer to the source 2x2 matrix. */ |
4398 | /* */ |
4399 | /* <Note> */ |
4400 | /* The result is undefined if either `vector' or `matrix' is invalid. */ |
4401 | /* */ |
4402 | FT_EXPORT( void ) |
4403 | FT_Vector_Transform( FT_Vector* vec, |
4404 | const FT_Matrix* matrix ); |
4405 | |
4406 | |
4407 | /*************************************************************************/ |
4408 | /* */ |
4409 | /* <Section> */ |
4410 | /* version */ |
4411 | /* */ |
4412 | /* <Title> */ |
4413 | /* FreeType Version */ |
4414 | /* */ |
4415 | /* <Abstract> */ |
4416 | /* Functions and macros related to FreeType versions. */ |
4417 | /* */ |
4418 | /* <Description> */ |
4419 | /* Note that those functions and macros are of limited use because */ |
4420 | /* even a new release of FreeType with only documentation changes */ |
4421 | /* increases the version number. */ |
4422 | /* */ |
4423 | /* <Order> */ |
4424 | /* FT_Library_Version */ |
4425 | /* */ |
4426 | /* FREETYPE_MAJOR */ |
4427 | /* FREETYPE_MINOR */ |
4428 | /* FREETYPE_PATCH */ |
4429 | /* */ |
4430 | /* FT_Face_CheckTrueTypePatents */ |
4431 | /* FT_Face_SetUnpatentedHinting */ |
4432 | /* */ |
4433 | /* FREETYPE_XXX */ |
4434 | /* */ |
4435 | /*************************************************************************/ |
4436 | |
4437 | |
4438 | /************************************************************************* |
4439 | * |
4440 | * @enum: |
4441 | * FREETYPE_XXX |
4442 | * |
4443 | * @description: |
4444 | * These three macros identify the FreeType source code version. |
4445 | * Use @FT_Library_Version to access them at runtime. |
4446 | * |
4447 | * @values: |
4448 | * FREETYPE_MAJOR :: The major version number. |
4449 | * FREETYPE_MINOR :: The minor version number. |
4450 | * FREETYPE_PATCH :: The patch level. |
4451 | * |
4452 | * @note: |
4453 | * The version number of FreeType if built as a dynamic link library |
4454 | * with the `libtool' package is _not_ controlled by these three |
4455 | * macros. |
4456 | * |
4457 | */ |
4458 | #define FREETYPE_MAJOR 2 |
4459 | #define FREETYPE_MINOR 8 |
4460 | #define FREETYPE_PATCH 1 |
4461 | |
4462 | |
4463 | /*************************************************************************/ |
4464 | /* */ |
4465 | /* <Function> */ |
4466 | /* FT_Library_Version */ |
4467 | /* */ |
4468 | /* <Description> */ |
4469 | /* Return the version of the FreeType library being used. This is */ |
4470 | /* useful when dynamically linking to the library, since one cannot */ |
4471 | /* use the macros @FREETYPE_MAJOR, @FREETYPE_MINOR, and */ |
4472 | /* @FREETYPE_PATCH. */ |
4473 | /* */ |
4474 | /* <Input> */ |
4475 | /* library :: A source library handle. */ |
4476 | /* */ |
4477 | /* <Output> */ |
4478 | /* amajor :: The major version number. */ |
4479 | /* */ |
4480 | /* aminor :: The minor version number. */ |
4481 | /* */ |
4482 | /* apatch :: The patch version number. */ |
4483 | /* */ |
4484 | /* <Note> */ |
4485 | /* The reason why this function takes a `library' argument is because */ |
4486 | /* certain programs implement library initialization in a custom way */ |
4487 | /* that doesn't use @FT_Init_FreeType. */ |
4488 | /* */ |
4489 | /* In such cases, the library version might not be available before */ |
4490 | /* the library object has been created. */ |
4491 | /* */ |
4492 | FT_EXPORT( void ) |
4493 | FT_Library_Version( FT_Library library, |
4494 | FT_Int *amajor, |
4495 | FT_Int *aminor, |
4496 | FT_Int *apatch ); |
4497 | |
4498 | |
4499 | /*************************************************************************/ |
4500 | /* */ |
4501 | /* <Function> */ |
4502 | /* FT_Face_CheckTrueTypePatents */ |
4503 | /* */ |
4504 | /* <Description> */ |
4505 | /* Deprecated, does nothing. */ |
4506 | /* */ |
4507 | /* <Input> */ |
4508 | /* face :: A face handle. */ |
4509 | /* */ |
4510 | /* <Return> */ |
4511 | /* Always returns false. */ |
4512 | /* */ |
4513 | /* <Note> */ |
4514 | /* Since May 2010, TrueType hinting is no longer patented. */ |
4515 | /* */ |
4516 | /* <Since> */ |
4517 | /* 2.3.5 */ |
4518 | /* */ |
4519 | FT_EXPORT( FT_Bool ) |
4520 | FT_Face_CheckTrueTypePatents( FT_Face face ); |
4521 | |
4522 | |
4523 | /*************************************************************************/ |
4524 | /* */ |
4525 | /* <Function> */ |
4526 | /* FT_Face_SetUnpatentedHinting */ |
4527 | /* */ |
4528 | /* <Description> */ |
4529 | /* Deprecated, does nothing. */ |
4530 | /* */ |
4531 | /* <Input> */ |
4532 | /* face :: A face handle. */ |
4533 | /* */ |
4534 | /* value :: New boolean setting. */ |
4535 | /* */ |
4536 | /* <Return> */ |
4537 | /* Always returns false. */ |
4538 | /* */ |
4539 | /* <Note> */ |
4540 | /* Since May 2010, TrueType hinting is no longer patented. */ |
4541 | /* */ |
4542 | /* <Since> */ |
4543 | /* 2.3.5 */ |
4544 | /* */ |
4545 | FT_EXPORT( FT_Bool ) |
4546 | FT_Face_SetUnpatentedHinting( FT_Face face, |
4547 | FT_Bool value ); |
4548 | |
4549 | /* */ |
4550 | |
4551 | |
4552 | FT_END_HEADER |
4553 | |
4554 | #endif /* FREETYPE_H_ */ |
4555 | |
4556 | |
4557 | /* END */ |
4558 | |