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