1 /***************************************************************************/ 2 /* */ 3 /* tttables.h */ 4 /* */ 5 /* Basic SFNT/TrueType tables definitions and interface */ 6 /* (specification only). */ 7 /* */ 8 /* Copyright 1996-2018 by */ 9 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 10 /* */ 11 /* This file is part of the FreeType project, and may only be used, */ 12 /* modified, and distributed under the terms of the FreeType project */ 13 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 14 /* this file you indicate that you have read the license and */ 15 /* understand and accept it fully. */ 16 /* */ 17 /***************************************************************************/ 18 19 20 #ifndef TTTABLES_H_ 21 #define TTTABLES_H_ 22 23 24 #include <ft2build.h> 25 #include FT_FREETYPE_H 26 27 #ifdef FREETYPE_H 28 #error "freetype.h of FreeType 1 has been loaded!" 29 #error "Please fix the directory search order for header files" 30 #error "so that freetype.h of FreeType 2 is found first." 31 #endif 32 33 34 FT_BEGIN_HEADER 35 36 /*************************************************************************/ 37 /* */ 38 /* <Section> */ 39 /* truetype_tables */ 40 /* */ 41 /* <Title> */ 42 /* TrueType Tables */ 43 /* */ 44 /* <Abstract> */ 45 /* TrueType specific table types and functions. */ 46 /* */ 47 /* <Description> */ 48 /* This section contains definitions of some basic tables specific to */ 49 /* TrueType and OpenType as well as some routines used to access and */ 50 /* process them. */ 51 /* */ 52 /* <Order> */ 53 /* TT_Header */ 54 /* TT_HoriHeader */ 55 /* TT_VertHeader */ 56 /* TT_OS2 */ 57 /* TT_Postscript */ 58 /* TT_PCLT */ 59 /* TT_MaxProfile */ 60 /* */ 61 /* FT_Sfnt_Tag */ 62 /* FT_Get_Sfnt_Table */ 63 /* FT_Load_Sfnt_Table */ 64 /* FT_Sfnt_Table_Info */ 65 /* */ 66 /* FT_Get_CMap_Language_ID */ 67 /* FT_Get_CMap_Format */ 68 /* */ 69 /* FT_PARAM_TAG_UNPATENTED_HINTING */ 70 /* */ 71 /*************************************************************************/ 72 73 74 /*************************************************************************/ 75 /* */ 76 /* <Struct> */ 77 /* TT_Header */ 78 /* */ 79 /* <Description> */ 80 /* A structure to model a TrueType font header table. All fields */ 81 /* follow the OpenType specification. */ 82 /* */ 83 typedef struct TT_Header_ 84 { 85 FT_Fixed Table_Version; 86 FT_Fixed Font_Revision; 87 88 FT_Long CheckSum_Adjust; 89 FT_Long Magic_Number; 90 91 FT_UShort Flags; 92 FT_UShort Units_Per_EM; 93 94 FT_Long Created [2]; 95 FT_Long Modified[2]; 96 97 FT_Short xMin; 98 FT_Short yMin; 99 FT_Short xMax; 100 FT_Short yMax; 101 102 FT_UShort Mac_Style; 103 FT_UShort Lowest_Rec_PPEM; 104 105 FT_Short Font_Direction; 106 FT_Short Index_To_Loc_Format; 107 FT_Short Glyph_Data_Format; 108 109 } TT_Header; 110 111 112 /*************************************************************************/ 113 /* */ 114 /* <Struct> */ 115 /* TT_HoriHeader */ 116 /* */ 117 /* <Description> */ 118 /* A structure to model a TrueType horizontal header, the `hhea' */ 119 /* table, as well as the corresponding horizontal metrics table, */ 120 /* `hmtx'. */ 121 /* */ 122 /* <Fields> */ 123 /* Version :: The table version. */ 124 /* */ 125 /* Ascender :: The font's ascender, i.e., the distance */ 126 /* from the baseline to the top-most of all */ 127 /* glyph points found in the font. */ 128 /* */ 129 /* This value is invalid in many fonts, as */ 130 /* it is usually set by the font designer, */ 131 /* and often reflects only a portion of the */ 132 /* glyphs found in the font (maybe ASCII). */ 133 /* */ 134 /* You should use the `sTypoAscender' field */ 135 /* of the `OS/2' table instead if you want */ 136 /* the correct one. */ 137 /* */ 138 /* Descender :: The font's descender, i.e., the distance */ 139 /* from the baseline to the bottom-most of */ 140 /* all glyph points found in the font. It */ 141 /* is negative. */ 142 /* */ 143 /* This value is invalid in many fonts, as */ 144 /* it is usually set by the font designer, */ 145 /* and often reflects only a portion of the */ 146 /* glyphs found in the font (maybe ASCII). */ 147 /* */ 148 /* You should use the `sTypoDescender' */ 149 /* field of the `OS/2' table instead if you */ 150 /* want the correct one. */ 151 /* */ 152 /* Line_Gap :: The font's line gap, i.e., the distance */ 153 /* to add to the ascender and descender to */ 154 /* get the BTB, i.e., the */ 155 /* baseline-to-baseline distance for the */ 156 /* font. */ 157 /* */ 158 /* advance_Width_Max :: This field is the maximum of all advance */ 159 /* widths found in the font. It can be */ 160 /* used to compute the maximum width of an */ 161 /* arbitrary string of text. */ 162 /* */ 163 /* min_Left_Side_Bearing :: The minimum left side bearing of all */ 164 /* glyphs within the font. */ 165 /* */ 166 /* min_Right_Side_Bearing :: The minimum right side bearing of all */ 167 /* glyphs within the font. */ 168 /* */ 169 /* xMax_Extent :: The maximum horizontal extent (i.e., the */ 170 /* `width' of a glyph's bounding box) for */ 171 /* all glyphs in the font. */ 172 /* */ 173 /* caret_Slope_Rise :: The rise coefficient of the cursor's */ 174 /* slope of the cursor (slope=rise/run). */ 175 /* */ 176 /* caret_Slope_Run :: The run coefficient of the cursor's */ 177 /* slope. */ 178 /* */ 179 /* caret_Offset :: The cursor's offset for slanted fonts. */ 180 /* */ 181 /* Reserved :: 8~reserved bytes. */ 182 /* */ 183 /* metric_Data_Format :: Always~0. */ 184 /* */ 185 /* number_Of_HMetrics :: Number of HMetrics entries in the `hmtx' */ 186 /* table -- this value can be smaller than */ 187 /* the total number of glyphs in the font. */ 188 /* */ 189 /* long_metrics :: A pointer into the `hmtx' table. */ 190 /* */ 191 /* short_metrics :: A pointer into the `hmtx' table. */ 192 /* */ 193 /* <Note> */ 194 /* For an OpenType variation font, the values of the following fields */ 195 /* can change after a call to @FT_Set_Var_Design_Coordinates (and */ 196 /* friends) if the font contains an `MVAR' table: `caret_Slope_Rise', */ 197 /* `caret_Slope_Run', and `caret_Offset'. */ 198 /* */ 199 typedef struct TT_HoriHeader_ 200 { 201 FT_Fixed Version; 202 FT_Short Ascender; 203 FT_Short Descender; 204 FT_Short Line_Gap; 205 206 FT_UShort advance_Width_Max; /* advance width maximum */ 207 208 FT_Short min_Left_Side_Bearing; /* minimum left-sb */ 209 FT_Short min_Right_Side_Bearing; /* minimum right-sb */ 210 FT_Short xMax_Extent; /* xmax extents */ 211 FT_Short caret_Slope_Rise; 212 FT_Short caret_Slope_Run; 213 FT_Short caret_Offset; 214 215 FT_Short Reserved[4]; 216 217 FT_Short metric_Data_Format; 218 FT_UShort number_Of_HMetrics; 219 220 /* The following fields are not defined by the OpenType specification */ 221 /* but they are used to connect the metrics header to the relevant */ 222 /* `hmtx' table. */ 223 224 void* long_metrics; 225 void* short_metrics; 226 227 } TT_HoriHeader; 228 229 230 /*************************************************************************/ 231 /* */ 232 /* <Struct> */ 233 /* TT_VertHeader */ 234 /* */ 235 /* <Description> */ 236 /* A structure used to model a TrueType vertical header, the `vhea' */ 237 /* table, as well as the corresponding vertical metrics table, */ 238 /* `vmtx'. */ 239 /* */ 240 /* <Fields> */ 241 /* Version :: The table version. */ 242 /* */ 243 /* Ascender :: The font's ascender, i.e., the distance */ 244 /* from the baseline to the top-most of */ 245 /* all glyph points found in the font. */ 246 /* */ 247 /* This value is invalid in many fonts, as */ 248 /* it is usually set by the font designer, */ 249 /* and often reflects only a portion of */ 250 /* the glyphs found in the font (maybe */ 251 /* ASCII). */ 252 /* */ 253 /* You should use the `sTypoAscender' */ 254 /* field of the `OS/2' table instead if */ 255 /* you want the correct one. */ 256 /* */ 257 /* Descender :: The font's descender, i.e., the */ 258 /* distance from the baseline to the */ 259 /* bottom-most of all glyph points found */ 260 /* in the font. It is negative. */ 261 /* */ 262 /* This value is invalid in many fonts, as */ 263 /* it is usually set by the font designer, */ 264 /* and often reflects only a portion of */ 265 /* the glyphs found in the font (maybe */ 266 /* ASCII). */ 267 /* */ 268 /* You should use the `sTypoDescender' */ 269 /* field of the `OS/2' table instead if */ 270 /* you want the correct one. */ 271 /* */ 272 /* Line_Gap :: The font's line gap, i.e., the distance */ 273 /* to add to the ascender and descender to */ 274 /* get the BTB, i.e., the */ 275 /* baseline-to-baseline distance for the */ 276 /* font. */ 277 /* */ 278 /* advance_Height_Max :: This field is the maximum of all */ 279 /* advance heights found in the font. It */ 280 /* can be used to compute the maximum */ 281 /* height of an arbitrary string of text. */ 282 /* */ 283 /* min_Top_Side_Bearing :: The minimum top side bearing of all */ 284 /* glyphs within the font. */ 285 /* */ 286 /* min_Bottom_Side_Bearing :: The minimum bottom side bearing of all */ 287 /* glyphs within the font. */ 288 /* */ 289 /* yMax_Extent :: The maximum vertical extent (i.e., the */ 290 /* `height' of a glyph's bounding box) for */ 291 /* all glyphs in the font. */ 292 /* */ 293 /* caret_Slope_Rise :: The rise coefficient of the cursor's */ 294 /* slope of the cursor (slope=rise/run). */ 295 /* */ 296 /* caret_Slope_Run :: The run coefficient of the cursor's */ 297 /* slope. */ 298 /* */ 299 /* caret_Offset :: The cursor's offset for slanted fonts. */ 300 /* */ 301 /* Reserved :: 8~reserved bytes. */ 302 /* */ 303 /* metric_Data_Format :: Always~0. */ 304 /* */ 305 /* number_Of_VMetrics :: Number of VMetrics entries in the */ 306 /* `vmtx' table -- this value can be */ 307 /* smaller than the total number of glyphs */ 308 /* in the font. */ 309 /* */ 310 /* long_metrics :: A pointer into the `vmtx' table. */ 311 /* */ 312 /* short_metrics :: A pointer into the `vmtx' table. */ 313 /* */ 314 /* <Note> */ 315 /* For an OpenType variation font, the values of the following fields */ 316 /* can change after a call to @FT_Set_Var_Design_Coordinates (and */ 317 /* friends) if the font contains an `MVAR' table: `Ascender', */ 318 /* `Descender', `Line_Gap', `caret_Slope_Rise', `caret_Slope_Run', */ 319 /* and `caret_Offset'. */ 320 /* */ 321 typedef struct TT_VertHeader_ 322 { 323 FT_Fixed Version; 324 FT_Short Ascender; 325 FT_Short Descender; 326 FT_Short Line_Gap; 327 328 FT_UShort advance_Height_Max; /* advance height maximum */ 329 330 FT_Short min_Top_Side_Bearing; /* minimum top-sb */ 331 FT_Short min_Bottom_Side_Bearing; /* minimum bottom-sb */ 332 FT_Short yMax_Extent; /* ymax extents */ 333 FT_Short caret_Slope_Rise; 334 FT_Short caret_Slope_Run; 335 FT_Short caret_Offset; 336 337 FT_Short Reserved[4]; 338 339 FT_Short metric_Data_Format; 340 FT_UShort number_Of_VMetrics; 341 342 /* The following fields are not defined by the OpenType specification */ 343 /* but they are used to connect the metrics header to the relevant */ 344 /* `vmtx' table. */ 345 346 void* long_metrics; 347 void* short_metrics; 348 349 } TT_VertHeader; 350 351 352 /*************************************************************************/ 353 /* */ 354 /* <Struct> */ 355 /* TT_OS2 */ 356 /* */ 357 /* <Description> */ 358 /* A structure to model a TrueType `OS/2' table. All fields comply */ 359 /* to the OpenType specification. */ 360 /* */ 361 /* Note that we now support old Mac fonts that do not include an */ 362 /* `OS/2' table. In this case, the `version' field is always set to */ 363 /* 0xFFFF. */ 364 /* */ 365 /* <Note> */ 366 /* For an OpenType variation font, the values of the following fields */ 367 /* can change after a call to @FT_Set_Var_Design_Coordinates (and */ 368 /* friends) if the font contains an `MVAR' table: `sCapHeight', */ 369 /* `sTypoAscender', `sTypoDescender', `sTypoLineGap', `sxHeight', */ 370 /* `usWinAscent', `usWinDescent', `yStrikeoutPosition', */ 371 /* `yStrikeoutSize', `ySubscriptXOffset', `ySubScriptXSize', */ 372 /* `ySubscriptYOffset', `ySubscriptYSize', `ySuperscriptXOffset', */ 373 /* `ySuperscriptXSize', `ySuperscriptYOffset', and */ 374 /* `ySuperscriptYSize'. */ 375 /* */ 376 /* Possible values for bits in the `ulUnicodeRangeX' fields are given */ 377 /* by the @TT_UCR_XXX macros. */ 378 /* */ 379 380 typedef struct TT_OS2_ 381 { 382 FT_UShort version; /* 0x0001 - more or 0xFFFF */ 383 FT_Short xAvgCharWidth; 384 FT_UShort usWeightClass; 385 FT_UShort usWidthClass; 386 FT_UShort fsType; 387 FT_Short ySubscriptXSize; 388 FT_Short ySubscriptYSize; 389 FT_Short ySubscriptXOffset; 390 FT_Short ySubscriptYOffset; 391 FT_Short ySuperscriptXSize; 392 FT_Short ySuperscriptYSize; 393 FT_Short ySuperscriptXOffset; 394 FT_Short ySuperscriptYOffset; 395 FT_Short yStrikeoutSize; 396 FT_Short yStrikeoutPosition; 397 FT_Short sFamilyClass; 398 418 419 FT_ULong ulCodePageRange1; /* Bits 0-31 */ 420 FT_ULong ulCodePageRange2; /* Bits 32-63 */ 421 422 /* only version 2 and higher: */ 423 424 FT_Short sxHeight; 425 FT_Short sCapHeight; 426 FT_UShort usDefaultChar; 427 FT_UShort usBreakChar; 428 FT_UShort usMaxContext; 429 430 /* only version 5 and higher: */ 431 432 FT_UShort usLowerOpticalPointSize; /* in twips (1/20th points) */ 433 FT_UShort usUpperOpticalPointSize; /* in twips (1/20th points) */ 434 435 } TT_OS2; 436 437 438 /*************************************************************************/ 439 /* */ 440 /* <Struct> */ 441 /* TT_Postscript */ 442 /* */ 443 /* <Description> */ 444 /* A structure to model a TrueType `post' table. All fields comply */ 445 /* to the OpenType specification. This structure does not reference */ 446 /* a font's PostScript glyph names; use @FT_Get_Glyph_Name to */ 447 /* retrieve them. */ 448 /* */ 449 /* <Note> */ 450 /* For an OpenType variation font, the values of the following fields */ 451 /* can change after a call to @FT_Set_Var_Design_Coordinates (and */ 452 /* friends) if the font contains an `MVAR' table: `underlinePosition' */ 453 /* and `underlineThickness'. */ 454 /* */ 455 typedef struct TT_Postscript_ 456 { 457 FT_Fixed FormatType; 458 FT_Fixed italicAngle; 459 FT_Short underlinePosition; 460 FT_Short underlineThickness; 461 FT_ULong isFixedPitch; 462 FT_ULong minMemType42; 463 FT_ULong maxMemType42; 464 FT_ULong minMemType1; 465 FT_ULong maxMemType1; 466 467 /* Glyph names follow in the `post' table, but we don't */ 468 /* load them by default. */ 469 470 } TT_Postscript; 471 472 473 /*************************************************************************/ 474 /* */ 475 /* <Struct> */ 476 /* TT_PCLT */ 477 /* */ 478 /* <Description> */ 479 /* A structure to model a TrueType `PCLT' table. All fields comply */ 480 /* to the OpenType specification. */ 481 /* */ 482 typedef struct TT_PCLT_ 483 { 484 FT_Fixed Version; 485 FT_ULong FontNumber; 486 FT_UShort Pitch; 487 FT_UShort xHeight; 488 FT_UShort Style; 489 FT_UShort TypeFamily; 490 FT_UShort CapHeight; 491 FT_UShort SymbolSet; 492 FT_Char TypeFace[16]; 493 FT_Char CharacterComplement[8]; 494 FT_Char FileName[6]; 495 FT_Char StrokeWeight; 496 FT_Char WidthType; 497 FT_Byte SerifStyle; 498 FT_Byte Reserved; 499 500 } TT_PCLT; 501 502 503 /*************************************************************************/ 504 /* */ 505 /* <Struct> */ 506 /* TT_MaxProfile */ 507 /* */ 508 /* <Description> */ 509 /* The maximum profile (`maxp') table contains many max values, which */ 510 /* can be used to pre-allocate arrays for speeding up glyph loading */ 511 /* and hinting. */ 512 /* */ 513 /* <Fields> */ 514 /* version :: The version number. */ 515 /* */ 516 /* numGlyphs :: The number of glyphs in this TrueType */ 517 /* font. */ 518 /* */ 519 /* maxPoints :: The maximum number of points in a */ 520 /* non-composite TrueType glyph. See also */ 521 /* `maxCompositePoints'. */ 522 /* */ 523 /* maxContours :: The maximum number of contours in a */ 524 /* non-composite TrueType glyph. See also */ 525 /* `maxCompositeContours'. */ 526 /* */ 527 /* maxCompositePoints :: The maximum number of points in a */ 528 /* composite TrueType glyph. See also */ 529 /* `maxPoints'. */ 530 /* */ 531 /* maxCompositeContours :: The maximum number of contours in a */ 532 /* composite TrueType glyph. See also */ 533 /* `maxContours'. */ 534 /* */ 535 /* maxZones :: The maximum number of zones used for */ 536 /* glyph hinting. */ 537 /* */ 538 /* maxTwilightPoints :: The maximum number of points in the */ 539 /* twilight zone used for glyph hinting. */ 540 /* */ 541 /* maxStorage :: The maximum number of elements in the */ 542 /* storage area used for glyph hinting. */ 543 /* */ 544 /* maxFunctionDefs :: The maximum number of function */ 545 /* definitions in the TrueType bytecode for */ 546 /* this font. */ 547 /* */ 548 /* maxInstructionDefs :: The maximum number of instruction */ 549 /* definitions in the TrueType bytecode for */ 550 /* this font. */ 551 /* */ 552 /* maxStackElements :: The maximum number of stack elements used */ 553 /* during bytecode interpretation. */ 554 /* */ 555 /* maxSizeOfInstructions :: The maximum number of TrueType opcodes */ 556 /* used for glyph hinting. */ 557 /* */ 558 /* maxComponentElements :: The maximum number of simple (i.e., non- */ 559 /* composite) glyphs in a composite glyph. */ 560 /* */ 561 /* maxComponentDepth :: The maximum nesting depth of composite */ 562 /* glyphs. */ 563 /* */ 564 /* <Note> */ 565 /* This structure is only used during font loading. */ 566 /* */ 567 typedef struct TT_MaxProfile_ 568 { 569 FT_Fixed version; 570 FT_UShort numGlyphs; 571 FT_UShort maxPoints; 572 FT_UShort maxContours; 573 FT_UShort maxCompositePoints; 574 FT_UShort maxCompositeContours; 575 FT_UShort maxZones; 576 FT_UShort maxTwilightPoints; 577 FT_UShort maxStorage; 578 FT_UShort maxFunctionDefs; 579 FT_UShort maxInstructionDefs; 580 FT_UShort maxStackElements; 581 FT_UShort maxSizeOfInstructions; 582 FT_UShort maxComponentElements; 583 FT_UShort maxComponentDepth; 584 585 } TT_MaxProfile; 586 587 588 /*************************************************************************/ 589 /* */ 590 /* <Enum> */ 591 /* FT_Sfnt_Tag */ 592 /* */ 593 /* <Description> */ 594 /* An enumeration to specify indices of SFNT tables loaded and parsed */ 595 /* by FreeType during initialization of an SFNT font. Used in the */ 596 /* @FT_Get_Sfnt_Table API function. */ 597 /* */ 598 /* <Values> */ 599 /* FT_SFNT_HEAD :: To access the font's @TT_Header structure. */ 600 /* */ 601 /* FT_SFNT_MAXP :: To access the font's @TT_MaxProfile structure. */ 602 /* */ 603 /* FT_SFNT_OS2 :: To access the font's @TT_OS2 structure. */ 604 /* */ 605 /* FT_SFNT_HHEA :: To access the font's @TT_HoriHeader structure. */ 606 /* */ 607 /* FT_SFNT_VHEA :: To access the font's @TT_VertHeader structure. */ 608 /* */ 609 /* FT_SFNT_POST :: To access the font's @TT_Postscript structure. */ 610 /* */ 611 /* FT_SFNT_PCLT :: To access the font's @TT_PCLT structure. */ 612 /* */ 613 typedef enum FT_Sfnt_Tag_ 614 { 615 FT_SFNT_HEAD, 616 FT_SFNT_MAXP, 617 FT_SFNT_OS2, 618 FT_SFNT_HHEA, 619 FT_SFNT_VHEA, 620 FT_SFNT_POST, 621 FT_SFNT_PCLT, 622 623 FT_SFNT_MAX 624 625 } FT_Sfnt_Tag; 626 627 /* these constants are deprecated; use the corresponding `FT_Sfnt_Tag' */ 628 /* values instead */ 629 #define ft_sfnt_head FT_SFNT_HEAD 630 #define ft_sfnt_maxp FT_SFNT_MAXP 631 #define ft_sfnt_os2 FT_SFNT_OS2 632 #define ft_sfnt_hhea FT_SFNT_HHEA 633 #define ft_sfnt_vhea FT_SFNT_VHEA 634 #define ft_sfnt_post FT_SFNT_POST 635 #define ft_sfnt_pclt FT_SFNT_PCLT 636 637 638 /*************************************************************************/ 639 /* */ 640 /* <Function> */ 641 /* FT_Get_Sfnt_Table */ 642 /* */ 643 /* <Description> */ 644 /* Return a pointer to a given SFNT table stored within a face. */ 645 /* */ 646 /* <Input> */ 647 /* face :: A handle to the source. */ 648 /* */ 649 /* tag :: The index of the SFNT table. */ 650 /* */ 651 /* <Return> */ 652 /* A type-less pointer to the table. This will be NULL in case of */ 653 /* error, or if the corresponding table was not found *OR* loaded */ 654 /* from the file. */ 655 /* */ 656 /* Use a typecast according to `tag' to access the structure */ 657 /* elements. */ 658 /* */ 659 /* <Note> */ 660 /* The table is owned by the face object and disappears with it. */ 661 /* */ 662 /* This function is only useful to access SFNT tables that are loaded */ 663 /* by the sfnt, truetype, and opentype drivers. See @FT_Sfnt_Tag for */ 664 /* a list. */ 665 /* */ 666 /* Here an example how to access the `vhea' table: */ 667 /* */ 668 /* { */ 669 /* TT_VertHeader* vert_header; */ 670 /* */ 671 /* */ 672 /* vert_header = */ 673 /* (TT_VertHeader*)FT_Get_Sfnt_Table( face, FT_SFNT_VHEA ); */ 674 /* } */ 675 /* */ 676 FT_EXPORT( void* ) 677 FT_Get_Sfnt_Table( FT_Face face, 678 FT_Sfnt_Tag tag ); 679 680 681 /************************************************************************** 682 * 683 * @function: 684 * FT_Load_Sfnt_Table 685 * 686 * @description: 687 * Load any SFNT font table into client memory. 688 * 689 * @input: 690 * face :: 691 * A handle to the source face. 692 * 693 * tag :: 694 * The four-byte tag of the table to load. Use value~0 if you want 695 * to access the whole font file. Otherwise, you can use one of the 696 * definitions found in the @FT_TRUETYPE_TAGS_H file, or forge a new 697 * one with @FT_MAKE_TAG. 698 * 699 * offset :: 700 * The starting offset in the table (or file if tag~==~0). 701 * 702 * @output: 703 * buffer :: 704 * The target buffer address. The client must ensure that the memory 705 * array is big enough to hold the data. 706 * 707 * @inout: 708 * length :: 709 * If the `length' parameter is NULL, try to load the whole table. 710 * Return an error code if it fails. 711 * 712 * Else, if `*length' is~0, exit immediately while returning the 713 * table's (or file) full size in it. 714 * 715 * Else the number of bytes to read from the table or file, from the 716 * starting offset. 717 * 718 * @return: 719 * FreeType error code. 0~means success. 720 * 721 * @note: 722 * If you need to determine the table's length you should first call this 723 * function with `*length' set to~0, as in the following example: 724 * 725 * { 726 * FT_ULong length = 0; 727 * 728 * 729 * error = FT_Load_Sfnt_Table( face, tag, 0, NULL, &length ); 730 * if ( error ) { ... table does not exist ... } 731 * 732 * buffer = malloc( length ); 733 * if ( buffer == NULL ) { ... not enough memory ... } 734 * 735 * error = FT_Load_Sfnt_Table( face, tag, 0, buffer, &length ); 736 * if ( error ) { ... could not load table ... } 737 * } 738 * 739 * Note that structures like @TT_Header or @TT_OS2 can't be used with 740 * this function; they are limited to @FT_Get_Sfnt_Table. Reason is that 741 * those structures depend on the processor architecture, with varying 742 * size (e.g. 32bit vs. 64bit) or order (big endian vs. little endian). 743 * 744 */ 745 FT_EXPORT( FT_Error ) 746 FT_Load_Sfnt_Table( FT_Face face, 747 FT_ULong tag, 748 FT_Long offset, 749 FT_Byte* buffer, 750 FT_ULong* length ); 751 752 753 /************************************************************************** 754 * 755 * @function: 756 * FT_Sfnt_Table_Info 757 * 758 * @description: 759 * Return information on an SFNT table. 760 * 761 * @input: 762 * face :: 763 * A handle to the source face. 764 * 765 * table_index :: 766 * The index of an SFNT table. The function returns 767 * FT_Err_Table_Missing for an invalid value. 768 * 769 * @inout: 770 * tag :: 771 * The name tag of the SFNT table. If the value is NULL, `table_index' 772 * is ignored, and `length' returns the number of SFNT tables in the 773 * font. 774 * 775 * @output: 776 * length :: 777 * The length of the SFNT table (or the number of SFNT tables, depending 778 * on `tag'). 779 * 780 * @return: 781 * FreeType error code. 0~means success. 782 * 783 * @note: 784 * While parsing fonts, FreeType handles SFNT tables with length zero as 785 * missing. 786 * 787 */ 788 FT_EXPORT( FT_Error ) 789 FT_Sfnt_Table_Info( FT_Face face, 790 FT_UInt table_index, 791 FT_ULong *tag, 792 FT_ULong *length ); 793 794 795 /*************************************************************************/ 796 /* */ 797 /* <Function> */ 798 /* FT_Get_CMap_Language_ID */ 799 /* */ 800 /* <Description> */ 801 /* Return cmap language ID as specified in the OpenType standard. */ 802 /* Definitions of language ID values are in file @FT_TRUETYPE_IDS_H. */ 803 /* */ 804 /* <Input> */ 805 /* charmap :: */ 806 /* The target charmap. */ 807 /* */ 808 /* <Return> */ 809 /* The language ID of `charmap'. If `charmap' doesn't belong to an */ 810 /* SFNT face, just return~0 as the default value. */ 811 /* */ 812 /* For a format~14 cmap (to access Unicode IVS), the return value is */ 813 /* 0xFFFFFFFF. */ 814 /* */ 815 FT_EXPORT( FT_ULong ) 816 FT_Get_CMap_Language_ID( FT_CharMap charmap ); 817 818 819 /*************************************************************************/ 820 /* */ 821 /* <Function> */ 822 /* FT_Get_CMap_Format */ 823 /* */ 824 /* <Description> */ 825 /* Return the format of an SFNT `cmap' table. */ 826 /* */ 827 /* <Input> */ 828 /* charmap :: */ 829 /* The target charmap. */ 830 /* */ 831 /* <Return> */ 832 /* The format of `charmap'. If `charmap' doesn't belong to an SFNT */ 833 /* face, return -1. */ 834 /* */ 835 FT_EXPORT( FT_Long ) 836 FT_Get_CMap_Format( FT_CharMap charmap ); 837 838 /* */ 839 840 841 FT_END_HEADER 842 843 #endif /* TTTABLES_H_ */ 844 845 846 /* END */ | 1 /**************************************************************************** 2 * 3 * tttables.h 4 * 5 * Basic SFNT/TrueType tables definitions and interface 6 * (specification only). 7 * 8 * Copyright (C) 1996-2019 by 9 * David Turner, Robert Wilhelm, and Werner Lemberg. 10 * 11 * This file is part of the FreeType project, and may only be used, 12 * modified, and distributed under the terms of the FreeType project 13 * license, LICENSE.TXT. By continuing to use, modify, or distribute 14 * this file you indicate that you have read the license and 15 * understand and accept it fully. 16 * 17 */ 18 19 20 #ifndef TTTABLES_H_ 21 #define TTTABLES_H_ 22 23 24 #include <ft2build.h> 25 #include FT_FREETYPE_H 26 27 #ifdef FREETYPE_H 28 #error "freetype.h of FreeType 1 has been loaded!" 29 #error "Please fix the directory search order for header files" 30 #error "so that freetype.h of FreeType 2 is found first." 31 #endif 32 33 34 FT_BEGIN_HEADER 35 36 /************************************************************************** 37 * 38 * @section: 39 * truetype_tables 40 * 41 * @title: 42 * TrueType Tables 43 * 44 * @abstract: 45 * TrueType-specific table types and functions. 46 * 47 * @description: 48 * This section contains definitions of some basic tables specific to 49 * TrueType and OpenType as well as some routines used to access and 50 * process them. 51 * 52 * @order: 53 * TT_Header 54 * TT_HoriHeader 55 * TT_VertHeader 56 * TT_OS2 57 * TT_Postscript 58 * TT_PCLT 59 * TT_MaxProfile 60 * 61 * FT_Sfnt_Tag 62 * FT_Get_Sfnt_Table 63 * FT_Load_Sfnt_Table 64 * FT_Sfnt_Table_Info 65 * 66 * FT_Get_CMap_Language_ID 67 * FT_Get_CMap_Format 68 * 69 * FT_PARAM_TAG_UNPATENTED_HINTING 70 * 71 */ 72 73 74 /************************************************************************** 75 * 76 * @struct: 77 * TT_Header 78 * 79 * @description: 80 * A structure to model a TrueType font header table. All fields follow 81 * the OpenType specification. The 64-bit timestamps are stored in 82 * two-element arrays `Created` and `Modified`, first the upper then 83 * the lower 32~bits. 84 */ 85 typedef struct TT_Header_ 86 { 87 FT_Fixed Table_Version; 88 FT_Fixed Font_Revision; 89 90 FT_Long CheckSum_Adjust; 91 FT_Long Magic_Number; 92 93 FT_UShort Flags; 94 FT_UShort Units_Per_EM; 95 96 FT_ULong Created [2]; 97 FT_ULong Modified[2]; 98 99 FT_Short xMin; 100 FT_Short yMin; 101 FT_Short xMax; 102 FT_Short yMax; 103 104 FT_UShort Mac_Style; 105 FT_UShort Lowest_Rec_PPEM; 106 107 FT_Short Font_Direction; 108 FT_Short Index_To_Loc_Format; 109 FT_Short Glyph_Data_Format; 110 111 } TT_Header; 112 113 114 /************************************************************************** 115 * 116 * @struct: 117 * TT_HoriHeader 118 * 119 * @description: 120 * A structure to model a TrueType horizontal header, the 'hhea' table, 121 * as well as the corresponding horizontal metrics table, 'hmtx'. 122 * 123 * @fields: 124 * Version :: 125 * The table version. 126 * 127 * Ascender :: 128 * The font's ascender, i.e., the distance from the baseline to the 129 * top-most of all glyph points found in the font. 130 * 131 * This value is invalid in many fonts, as it is usually set by the 132 * font designer, and often reflects only a portion of the glyphs found 133 * in the font (maybe ASCII). 134 * 135 * You should use the `sTypoAscender` field of the 'OS/2' table instead 136 * if you want the correct one. 137 * 138 * Descender :: 139 * The font's descender, i.e., the distance from the baseline to the 140 * bottom-most of all glyph points found in the font. It is negative. 141 * 142 * This value is invalid in many fonts, as it is usually set by the 143 * font designer, and often reflects only a portion of the glyphs found 144 * in the font (maybe ASCII). 145 * 146 * You should use the `sTypoDescender` field of the 'OS/2' table 147 * instead if you want the correct one. 148 * 149 * Line_Gap :: 150 * The font's line gap, i.e., the distance to add to the ascender and 151 * descender to get the BTB, i.e., the baseline-to-baseline distance 152 * for the font. 153 * 154 * advance_Width_Max :: 155 * This field is the maximum of all advance widths found in the font. 156 * It can be used to compute the maximum width of an arbitrary string 157 * of text. 158 * 159 * min_Left_Side_Bearing :: 160 * The minimum left side bearing of all glyphs within the font. 161 * 162 * min_Right_Side_Bearing :: 163 * The minimum right side bearing of all glyphs within the font. 164 * 165 * xMax_Extent :: 166 * The maximum horizontal extent (i.e., the 'width' of a glyph's 167 * bounding box) for all glyphs in the font. 168 * 169 * caret_Slope_Rise :: 170 * The rise coefficient of the cursor's slope of the cursor 171 * (slope=rise/run). 172 * 173 * caret_Slope_Run :: 174 * The run coefficient of the cursor's slope. 175 * 176 * caret_Offset :: 177 * The cursor's offset for slanted fonts. 178 * 179 * Reserved :: 180 * 8~reserved bytes. 181 * 182 * metric_Data_Format :: 183 * Always~0. 184 * 185 * number_Of_HMetrics :: 186 * Number of HMetrics entries in the 'hmtx' table -- this value can be 187 * smaller than the total number of glyphs in the font. 188 * 189 * long_metrics :: 190 * A pointer into the 'hmtx' table. 191 * 192 * short_metrics :: 193 * A pointer into the 'hmtx' table. 194 * 195 * @note: 196 * For an OpenType variation font, the values of the following fields can 197 * change after a call to @FT_Set_Var_Design_Coordinates (and friends) if 198 * the font contains an 'MVAR' table: `caret_Slope_Rise`, 199 * `caret_Slope_Run`, and `caret_Offset`. 200 */ 201 typedef struct TT_HoriHeader_ 202 { 203 FT_Fixed Version; 204 FT_Short Ascender; 205 FT_Short Descender; 206 FT_Short Line_Gap; 207 208 FT_UShort advance_Width_Max; /* advance width maximum */ 209 210 FT_Short min_Left_Side_Bearing; /* minimum left-sb */ 211 FT_Short min_Right_Side_Bearing; /* minimum right-sb */ 212 FT_Short xMax_Extent; /* xmax extents */ 213 FT_Short caret_Slope_Rise; 214 FT_Short caret_Slope_Run; 215 FT_Short caret_Offset; 216 217 FT_Short Reserved[4]; 218 219 FT_Short metric_Data_Format; 220 FT_UShort number_Of_HMetrics; 221 222 /* The following fields are not defined by the OpenType specification */ 223 /* but they are used to connect the metrics header to the relevant */ 224 /* 'hmtx' table. */ 225 226 void* long_metrics; 227 void* short_metrics; 228 229 } TT_HoriHeader; 230 231 232 /************************************************************************** 233 * 234 * @struct: 235 * TT_VertHeader 236 * 237 * @description: 238 * A structure used to model a TrueType vertical header, the 'vhea' 239 * table, as well as the corresponding vertical metrics table, 'vmtx'. 240 * 241 * @fields: 242 * Version :: 243 * The table version. 244 * 245 * Ascender :: 246 * The font's ascender, i.e., the distance from the baseline to the 247 * top-most of all glyph points found in the font. 248 * 249 * This value is invalid in many fonts, as it is usually set by the 250 * font designer, and often reflects only a portion of the glyphs found 251 * in the font (maybe ASCII). 252 * 253 * You should use the `sTypoAscender` field of the 'OS/2' table instead 254 * if you want the correct one. 255 * 256 * Descender :: 257 * The font's descender, i.e., the distance from the baseline to the 258 * bottom-most of all glyph points found in the font. It is negative. 259 * 260 * This value is invalid in many fonts, as it is usually set by the 261 * font designer, and often reflects only a portion of the glyphs found 262 * in the font (maybe ASCII). 263 * 264 * You should use the `sTypoDescender` field of the 'OS/2' table 265 * instead if you want the correct one. 266 * 267 * Line_Gap :: 268 * The font's line gap, i.e., the distance to add to the ascender and 269 * descender to get the BTB, i.e., the baseline-to-baseline distance 270 * for the font. 271 * 272 * advance_Height_Max :: 273 * This field is the maximum of all advance heights found in the font. 274 * It can be used to compute the maximum height of an arbitrary string 275 * of text. 276 * 277 * min_Top_Side_Bearing :: 278 * The minimum top side bearing of all glyphs within the font. 279 * 280 * min_Bottom_Side_Bearing :: 281 * The minimum bottom side bearing of all glyphs within the font. 282 * 283 * yMax_Extent :: 284 * The maximum vertical extent (i.e., the 'height' of a glyph's 285 * bounding box) for all glyphs in the font. 286 * 287 * caret_Slope_Rise :: 288 * The rise coefficient of the cursor's slope of the cursor 289 * (slope=rise/run). 290 * 291 * caret_Slope_Run :: 292 * The run coefficient of the cursor's slope. 293 * 294 * caret_Offset :: 295 * The cursor's offset for slanted fonts. 296 * 297 * Reserved :: 298 * 8~reserved bytes. 299 * 300 * metric_Data_Format :: 301 * Always~0. 302 * 303 * number_Of_VMetrics :: 304 * Number of VMetrics entries in the 'vmtx' table -- this value can be 305 * smaller than the total number of glyphs in the font. 306 * 307 * long_metrics :: 308 * A pointer into the 'vmtx' table. 309 * 310 * short_metrics :: 311 * A pointer into the 'vmtx' table. 312 * 313 * @note: 314 * For an OpenType variation font, the values of the following fields can 315 * change after a call to @FT_Set_Var_Design_Coordinates (and friends) if 316 * the font contains an 'MVAR' table: `Ascender`, `Descender`, 317 * `Line_Gap`, `caret_Slope_Rise`, `caret_Slope_Run`, and `caret_Offset`. 318 */ 319 typedef struct TT_VertHeader_ 320 { 321 FT_Fixed Version; 322 FT_Short Ascender; 323 FT_Short Descender; 324 FT_Short Line_Gap; 325 326 FT_UShort advance_Height_Max; /* advance height maximum */ 327 328 FT_Short min_Top_Side_Bearing; /* minimum top-sb */ 329 FT_Short min_Bottom_Side_Bearing; /* minimum bottom-sb */ 330 FT_Short yMax_Extent; /* ymax extents */ 331 FT_Short caret_Slope_Rise; 332 FT_Short caret_Slope_Run; 333 FT_Short caret_Offset; 334 335 FT_Short Reserved[4]; 336 337 FT_Short metric_Data_Format; 338 FT_UShort number_Of_VMetrics; 339 340 /* The following fields are not defined by the OpenType specification */ 341 /* but they are used to connect the metrics header to the relevant */ 342 /* 'vmtx' table. */ 343 344 void* long_metrics; 345 void* short_metrics; 346 347 } TT_VertHeader; 348 349 350 /************************************************************************** 351 * 352 * @struct: 353 * TT_OS2 354 * 355 * @description: 356 * A structure to model a TrueType 'OS/2' table. All fields comply to 357 * the OpenType specification. 358 * 359 * Note that we now support old Mac fonts that do not include an 'OS/2' 360 * table. In this case, the `version` field is always set to 0xFFFF. 361 * 362 * @note: 363 * For an OpenType variation font, the values of the following fields can 364 * change after a call to @FT_Set_Var_Design_Coordinates (and friends) if 365 * the font contains an 'MVAR' table: `sCapHeight`, `sTypoAscender`, 366 * `sTypoDescender`, `sTypoLineGap`, `sxHeight`, `usWinAscent`, 367 * `usWinDescent`, `yStrikeoutPosition`, `yStrikeoutSize`, 368 * `ySubscriptXOffset`, `ySubScriptXSize`, `ySubscriptYOffset`, 369 * `ySubscriptYSize`, `ySuperscriptXOffset`, `ySuperscriptXSize`, 370 * `ySuperscriptYOffset`, and `ySuperscriptYSize`. 371 * 372 * Possible values for bits in the `ulUnicodeRangeX` fields are given by 373 * the @TT_UCR_XXX macros. 374 */ 375 376 typedef struct TT_OS2_ 377 { 378 FT_UShort version; /* 0x0001 - more or 0xFFFF */ 379 FT_Short xAvgCharWidth; 380 FT_UShort usWeightClass; 381 FT_UShort usWidthClass; 382 FT_UShort fsType; 383 FT_Short ySubscriptXSize; 384 FT_Short ySubscriptYSize; 385 FT_Short ySubscriptXOffset; 386 FT_Short ySubscriptYOffset; 387 FT_Short ySuperscriptXSize; 388 FT_Short ySuperscriptYSize; 389 FT_Short ySuperscriptXOffset; 390 FT_Short ySuperscriptYOffset; 391 FT_Short yStrikeoutSize; 392 FT_Short yStrikeoutPosition; 393 FT_Short sFamilyClass; 394 414 415 FT_ULong ulCodePageRange1; /* Bits 0-31 */ 416 FT_ULong ulCodePageRange2; /* Bits 32-63 */ 417 418 /* only version 2 and higher: */ 419 420 FT_Short sxHeight; 421 FT_Short sCapHeight; 422 FT_UShort usDefaultChar; 423 FT_UShort usBreakChar; 424 FT_UShort usMaxContext; 425 426 /* only version 5 and higher: */ 427 428 FT_UShort usLowerOpticalPointSize; /* in twips (1/20th points) */ 429 FT_UShort usUpperOpticalPointSize; /* in twips (1/20th points) */ 430 431 } TT_OS2; 432 433 434 /************************************************************************** 435 * 436 * @struct: 437 * TT_Postscript 438 * 439 * @description: 440 * A structure to model a TrueType 'post' table. All fields comply to 441 * the OpenType specification. This structure does not reference a 442 * font's PostScript glyph names; use @FT_Get_Glyph_Name to retrieve 443 * them. 444 * 445 * @note: 446 * For an OpenType variation font, the values of the following fields can 447 * change after a call to @FT_Set_Var_Design_Coordinates (and friends) if 448 * the font contains an 'MVAR' table: `underlinePosition` and 449 * `underlineThickness`. 450 */ 451 typedef struct TT_Postscript_ 452 { 453 FT_Fixed FormatType; 454 FT_Fixed italicAngle; 455 FT_Short underlinePosition; 456 FT_Short underlineThickness; 457 FT_ULong isFixedPitch; 458 FT_ULong minMemType42; 459 FT_ULong maxMemType42; 460 FT_ULong minMemType1; 461 FT_ULong maxMemType1; 462 463 /* Glyph names follow in the 'post' table, but we don't */ 464 /* load them by default. */ 465 466 } TT_Postscript; 467 468 469 /************************************************************************** 470 * 471 * @struct: 472 * TT_PCLT 473 * 474 * @description: 475 * A structure to model a TrueType 'PCLT' table. All fields comply to 476 * the OpenType specification. 477 */ 478 typedef struct TT_PCLT_ 479 { 480 FT_Fixed Version; 481 FT_ULong FontNumber; 482 FT_UShort Pitch; 483 FT_UShort xHeight; 484 FT_UShort Style; 485 FT_UShort TypeFamily; 486 FT_UShort CapHeight; 487 FT_UShort SymbolSet; 488 FT_Char TypeFace[16]; 489 FT_Char CharacterComplement[8]; 490 FT_Char FileName[6]; 491 FT_Char StrokeWeight; 492 FT_Char WidthType; 493 FT_Byte SerifStyle; 494 FT_Byte Reserved; 495 496 } TT_PCLT; 497 498 499 /************************************************************************** 500 * 501 * @struct: 502 * TT_MaxProfile 503 * 504 * @description: 505 * The maximum profile ('maxp') table contains many max values, which can 506 * be used to pre-allocate arrays for speeding up glyph loading and 507 * hinting. 508 * 509 * @fields: 510 * version :: 511 * The version number. 512 * 513 * numGlyphs :: 514 * The number of glyphs in this TrueType font. 515 * 516 * maxPoints :: 517 * The maximum number of points in a non-composite TrueType glyph. See 518 * also `maxCompositePoints`. 519 * 520 * maxContours :: 521 * The maximum number of contours in a non-composite TrueType glyph. 522 * See also `maxCompositeContours`. 523 * 524 * maxCompositePoints :: 525 * The maximum number of points in a composite TrueType glyph. See 526 * also `maxPoints`. 527 * 528 * maxCompositeContours :: 529 * The maximum number of contours in a composite TrueType glyph. See 530 * also `maxContours`. 531 * 532 * maxZones :: 533 * The maximum number of zones used for glyph hinting. 534 * 535 * maxTwilightPoints :: 536 * The maximum number of points in the twilight zone used for glyph 537 * hinting. 538 * 539 * maxStorage :: 540 * The maximum number of elements in the storage area used for glyph 541 * hinting. 542 * 543 * maxFunctionDefs :: 544 * The maximum number of function definitions in the TrueType bytecode 545 * for this font. 546 * 547 * maxInstructionDefs :: 548 * The maximum number of instruction definitions in the TrueType 549 * bytecode for this font. 550 * 551 * maxStackElements :: 552 * The maximum number of stack elements used during bytecode 553 * interpretation. 554 * 555 * maxSizeOfInstructions :: 556 * The maximum number of TrueType opcodes used for glyph hinting. 557 * 558 * maxComponentElements :: 559 * The maximum number of simple (i.e., non-composite) glyphs in a 560 * composite glyph. 561 * 562 * maxComponentDepth :: 563 * The maximum nesting depth of composite glyphs. 564 * 565 * @note: 566 * This structure is only used during font loading. 567 */ 568 typedef struct TT_MaxProfile_ 569 { 570 FT_Fixed version; 571 FT_UShort numGlyphs; 572 FT_UShort maxPoints; 573 FT_UShort maxContours; 574 FT_UShort maxCompositePoints; 575 FT_UShort maxCompositeContours; 576 FT_UShort maxZones; 577 FT_UShort maxTwilightPoints; 578 FT_UShort maxStorage; 579 FT_UShort maxFunctionDefs; 580 FT_UShort maxInstructionDefs; 581 FT_UShort maxStackElements; 582 FT_UShort maxSizeOfInstructions; 583 FT_UShort maxComponentElements; 584 FT_UShort maxComponentDepth; 585 586 } TT_MaxProfile; 587 588 589 /************************************************************************** 590 * 591 * @enum: 592 * FT_Sfnt_Tag 593 * 594 * @description: 595 * An enumeration to specify indices of SFNT tables loaded and parsed by 596 * FreeType during initialization of an SFNT font. Used in the 597 * @FT_Get_Sfnt_Table API function. 598 * 599 * @values: 600 * FT_SFNT_HEAD :: 601 * To access the font's @TT_Header structure. 602 * 603 * FT_SFNT_MAXP :: 604 * To access the font's @TT_MaxProfile structure. 605 * 606 * FT_SFNT_OS2 :: 607 * To access the font's @TT_OS2 structure. 608 * 609 * FT_SFNT_HHEA :: 610 * To access the font's @TT_HoriHeader structure. 611 * 612 * FT_SFNT_VHEA :: 613 * To access the font's @TT_VertHeader structure. 614 * 615 * FT_SFNT_POST :: 616 * To access the font's @TT_Postscript structure. 617 * 618 * FT_SFNT_PCLT :: 619 * To access the font's @TT_PCLT structure. 620 */ 621 typedef enum FT_Sfnt_Tag_ 622 { 623 FT_SFNT_HEAD, 624 FT_SFNT_MAXP, 625 FT_SFNT_OS2, 626 FT_SFNT_HHEA, 627 FT_SFNT_VHEA, 628 FT_SFNT_POST, 629 FT_SFNT_PCLT, 630 631 FT_SFNT_MAX 632 633 } FT_Sfnt_Tag; 634 635 /* these constants are deprecated; use the corresponding `FT_Sfnt_Tag` */ 636 /* values instead */ 637 #define ft_sfnt_head FT_SFNT_HEAD 638 #define ft_sfnt_maxp FT_SFNT_MAXP 639 #define ft_sfnt_os2 FT_SFNT_OS2 640 #define ft_sfnt_hhea FT_SFNT_HHEA 641 #define ft_sfnt_vhea FT_SFNT_VHEA 642 #define ft_sfnt_post FT_SFNT_POST 643 #define ft_sfnt_pclt FT_SFNT_PCLT 644 645 646 /************************************************************************** 647 * 648 * @function: 649 * FT_Get_Sfnt_Table 650 * 651 * @description: 652 * Return a pointer to a given SFNT table stored within a face. 653 * 654 * @input: 655 * face :: 656 * A handle to the source. 657 * 658 * tag :: 659 * The index of the SFNT table. 660 * 661 * @return: 662 * A type-less pointer to the table. This will be `NULL` in case of 663 * error, or if the corresponding table was not found **OR** loaded from 664 * the file. 665 * 666 * Use a typecast according to `tag` to access the structure elements. 667 * 668 * @note: 669 * The table is owned by the face object and disappears with it. 670 * 671 * This function is only useful to access SFNT tables that are loaded by 672 * the sfnt, truetype, and opentype drivers. See @FT_Sfnt_Tag for a 673 * list. 674 * 675 * @example: 676 * Here is an example demonstrating access to the 'vhea' table. 677 * 678 * ``` 679 * TT_VertHeader* vert_header; 680 * 681 * 682 * vert_header = 683 * (TT_VertHeader*)FT_Get_Sfnt_Table( face, FT_SFNT_VHEA ); 684 * ``` 685 */ 686 FT_EXPORT( void* ) 687 FT_Get_Sfnt_Table( FT_Face face, 688 FT_Sfnt_Tag tag ); 689 690 691 /************************************************************************** 692 * 693 * @function: 694 * FT_Load_Sfnt_Table 695 * 696 * @description: 697 * Load any SFNT font table into client memory. 698 * 699 * @input: 700 * face :: 701 * A handle to the source face. 702 * 703 * tag :: 704 * The four-byte tag of the table to load. Use value~0 if you want to 705 * access the whole font file. Otherwise, you can use one of the 706 * definitions found in the @FT_TRUETYPE_TAGS_H file, or forge a new 707 * one with @FT_MAKE_TAG. 708 * 709 * offset :: 710 * The starting offset in the table (or file if tag~==~0). 711 * 712 * @output: 713 * buffer :: 714 * The target buffer address. The client must ensure that the memory 715 * array is big enough to hold the data. 716 * 717 * @inout: 718 * length :: 719 * If the `length` parameter is `NULL`, try to load the whole table. 720 * Return an error code if it fails. 721 * 722 * Else, if `*length` is~0, exit immediately while returning the 723 * table's (or file) full size in it. 724 * 725 * Else the number of bytes to read from the table or file, from the 726 * starting offset. 727 * 728 * @return: 729 * FreeType error code. 0~means success. 730 * 731 * @note: 732 * If you need to determine the table's length you should first call this 733 * function with `*length` set to~0, as in the following example: 734 * 735 * ``` 736 * FT_ULong length = 0; 737 * 738 * 739 * error = FT_Load_Sfnt_Table( face, tag, 0, NULL, &length ); 740 * if ( error ) { ... table does not exist ... } 741 * 742 * buffer = malloc( length ); 743 * if ( buffer == NULL ) { ... not enough memory ... } 744 * 745 * error = FT_Load_Sfnt_Table( face, tag, 0, buffer, &length ); 746 * if ( error ) { ... could not load table ... } 747 * ``` 748 * 749 * Note that structures like @TT_Header or @TT_OS2 can't be used with 750 * this function; they are limited to @FT_Get_Sfnt_Table. Reason is that 751 * those structures depend on the processor architecture, with varying 752 * size (e.g. 32bit vs. 64bit) or order (big endian vs. little endian). 753 * 754 */ 755 FT_EXPORT( FT_Error ) 756 FT_Load_Sfnt_Table( FT_Face face, 757 FT_ULong tag, 758 FT_Long offset, 759 FT_Byte* buffer, 760 FT_ULong* length ); 761 762 763 /************************************************************************** 764 * 765 * @function: 766 * FT_Sfnt_Table_Info 767 * 768 * @description: 769 * Return information on an SFNT table. 770 * 771 * @input: 772 * face :: 773 * A handle to the source face. 774 * 775 * table_index :: 776 * The index of an SFNT table. The function returns 777 * FT_Err_Table_Missing for an invalid value. 778 * 779 * @inout: 780 * tag :: 781 * The name tag of the SFNT table. If the value is `NULL`, 782 * `table_index` is ignored, and `length` returns the number of SFNT 783 * tables in the font. 784 * 785 * @output: 786 * length :: 787 * The length of the SFNT table (or the number of SFNT tables, 788 * depending on `tag`). 789 * 790 * @return: 791 * FreeType error code. 0~means success. 792 * 793 * @note: 794 * While parsing fonts, FreeType handles SFNT tables with length zero as 795 * missing. 796 * 797 */ 798 FT_EXPORT( FT_Error ) 799 FT_Sfnt_Table_Info( FT_Face face, 800 FT_UInt table_index, 801 FT_ULong *tag, 802 FT_ULong *length ); 803 804 805 /************************************************************************** 806 * 807 * @function: 808 * FT_Get_CMap_Language_ID 809 * 810 * @description: 811 * Return cmap language ID as specified in the OpenType standard. 812 * Definitions of language ID values are in file @FT_TRUETYPE_IDS_H. 813 * 814 * @input: 815 * charmap :: 816 * The target charmap. 817 * 818 * @return: 819 * The language ID of `charmap`. If `charmap` doesn't belong to an SFNT 820 * face, just return~0 as the default value. 821 * 822 * For a format~14 cmap (to access Unicode IVS), the return value is 823 * 0xFFFFFFFF. 824 */ 825 FT_EXPORT( FT_ULong ) 826 FT_Get_CMap_Language_ID( FT_CharMap charmap ); 827 828 829 /************************************************************************** 830 * 831 * @function: 832 * FT_Get_CMap_Format 833 * 834 * @description: 835 * Return the format of an SFNT 'cmap' table. 836 * 837 * @input: 838 * charmap :: 839 * The target charmap. 840 * 841 * @return: 842 * The format of `charmap`. If `charmap` doesn't belong to an SFNT face, 843 * return -1. 844 */ 845 FT_EXPORT( FT_Long ) 846 FT_Get_CMap_Format( FT_CharMap charmap ); 847 848 /* */ 849 850 851 FT_END_HEADER 852 853 #endif /* TTTABLES_H_ */ 854 855 856 /* END */ |