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