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