1 /**************************************************************************** 2 * 3 * ttload.c 4 * 5 * Load the basic TrueType tables, i.e., tables that can be either in 6 * TTF or OTF fonts (body). 7 * 8 * Copyright (C) 1996-2023 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 #include <freetype/internal/ftdebug.h> 21 #include <freetype/internal/ftstream.h> 22 #include <freetype/tttags.h> 23 #include "ttload.h" 24 25 #include "sferrors.h" 26 27 28 /************************************************************************** 29 * 30 * The macro FT_COMPONENT is used in trace mode. It is an implicit 31 * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log 32 * messages during execution. 33 */ 34 #undef FT_COMPONENT 35 #define FT_COMPONENT ttload 36 37 38 /************************************************************************** 39 * 40 * @Function: 41 * tt_face_lookup_table 42 * 43 * @Description: 44 * Looks for a TrueType table by name. 45 * 46 * @Input: 47 * face :: 48 * A face object handle. 49 * 50 * tag :: 51 * The searched tag. 52 * 53 * @Return: 54 * A pointer to the table directory entry. 0 if not found. 55 */ 56 FT_LOCAL_DEF( TT_Table ) tt_face_lookup_table(TT_Face face,FT_ULong tag)57 tt_face_lookup_table( TT_Face face, 58 FT_ULong tag ) 59 { 60 TT_Table entry; 61 TT_Table limit; 62 #ifdef FT_DEBUG_LEVEL_TRACE 63 FT_Bool zero_length = FALSE; 64 #endif 65 66 67 FT_TRACE4(( "tt_face_lookup_table: %p, `%c%c%c%c' -- ", 68 (void *)face, 69 (FT_Char)( tag >> 24 ), 70 (FT_Char)( tag >> 16 ), 71 (FT_Char)( tag >> 8 ), 72 (FT_Char)( tag ) )); 73 74 entry = face->dir_tables; 75 limit = entry + face->num_tables; 76 77 for ( ; entry < limit; entry++ ) 78 { 79 /* For compatibility with Windows, we consider */ 80 /* zero-length tables the same as missing tables. */ 81 if ( entry->Tag == tag ) 82 { 83 if ( entry->Length != 0 ) 84 { 85 FT_TRACE4(( "found table.\n" )); 86 return entry; 87 } 88 #ifdef FT_DEBUG_LEVEL_TRACE 89 zero_length = TRUE; 90 #endif 91 } 92 } 93 94 #ifdef FT_DEBUG_LEVEL_TRACE 95 if ( zero_length ) 96 FT_TRACE4(( "ignoring empty table\n" )); 97 else 98 FT_TRACE4(( "could not find table\n" )); 99 #endif 100 101 return NULL; 102 } 103 104 105 /************************************************************************** 106 * 107 * @Function: 108 * tt_face_goto_table 109 * 110 * @Description: 111 * Looks for a TrueType table by name, then seek a stream to it. 112 * 113 * @Input: 114 * face :: 115 * A face object handle. 116 * 117 * tag :: 118 * The searched tag. 119 * 120 * stream :: 121 * The stream to seek when the table is found. 122 * 123 * @Output: 124 * length :: 125 * The length of the table if found, undefined otherwise. 126 * 127 * @Return: 128 * FreeType error code. 0 means success. 129 */ 130 FT_LOCAL_DEF( FT_Error ) tt_face_goto_table(TT_Face face,FT_ULong tag,FT_Stream stream,FT_ULong * length)131 tt_face_goto_table( TT_Face face, 132 FT_ULong tag, 133 FT_Stream stream, 134 FT_ULong* length ) 135 { 136 TT_Table table; 137 FT_Error error; 138 139 140 table = tt_face_lookup_table( face, tag ); 141 if ( table ) 142 { 143 if ( length ) 144 *length = table->Length; 145 146 if ( FT_STREAM_SEEK( table->Offset ) ) 147 goto Exit; 148 } 149 else 150 error = FT_THROW( Table_Missing ); 151 152 Exit: 153 return error; 154 } 155 156 157 /* Here, we */ 158 /* */ 159 /* - check that `num_tables' is valid (and adjust it if necessary); */ 160 /* also return the number of valid table entries */ 161 /* */ 162 /* - look for a `head' table, check its size, and parse it to check */ 163 /* whether its `magic' field is correctly set */ 164 /* */ 165 /* - errors (except errors returned by stream handling) */ 166 /* */ 167 /* SFNT_Err_Unknown_File_Format: */ 168 /* no table is defined in directory, it is not sfnt-wrapped */ 169 /* data */ 170 /* SFNT_Err_Table_Missing: */ 171 /* table directory is valid, but essential tables */ 172 /* (head/bhed/SING) are missing */ 173 /* */ 174 static FT_Error check_table_dir(SFNT_Header sfnt,FT_Stream stream,FT_UShort * valid)175 check_table_dir( SFNT_Header sfnt, 176 FT_Stream stream, 177 FT_UShort* valid ) 178 { 179 FT_Error error; 180 FT_UShort nn, valid_entries = 0; 181 FT_UInt has_head = 0, has_sing = 0, has_meta = 0; 182 FT_ULong offset = sfnt->offset + 12; 183 184 static const FT_Frame_Field table_dir_entry_fields[] = 185 { 186 #undef FT_STRUCTURE 187 #define FT_STRUCTURE TT_TableRec 188 189 FT_FRAME_START( 16 ), 190 FT_FRAME_ULONG( Tag ), 191 FT_FRAME_ULONG( CheckSum ), 192 FT_FRAME_ULONG( Offset ), 193 FT_FRAME_ULONG( Length ), 194 FT_FRAME_END 195 }; 196 197 198 if ( FT_STREAM_SEEK( offset ) ) 199 goto Exit; 200 201 for ( nn = 0; nn < sfnt->num_tables; nn++ ) 202 { 203 TT_TableRec table; 204 205 206 if ( FT_STREAM_READ_FIELDS( table_dir_entry_fields, &table ) ) 207 { 208 FT_TRACE2(( "check_table_dir:" 209 " can read only %hu table%s in font (instead of %hu)\n", 210 nn, nn == 1 ? "" : "s", sfnt->num_tables )); 211 sfnt->num_tables = nn; 212 break; 213 } 214 215 /* we ignore invalid tables */ 216 217 if ( table.Offset > stream->size ) 218 { 219 FT_TRACE2(( "check_table_dir: table entry %hu invalid\n", nn )); 220 continue; 221 } 222 else if ( table.Length > stream->size - table.Offset ) 223 { 224 /* Some tables have such a simple structure that clipping its */ 225 /* contents is harmless. This also makes FreeType less sensitive */ 226 /* to invalid table lengths (which programs like Acroread seem to */ 227 /* ignore in general). */ 228 229 if ( table.Tag == TTAG_hmtx || 230 table.Tag == TTAG_vmtx ) 231 valid_entries++; 232 else 233 { 234 FT_TRACE2(( "check_table_dir: table entry %hu invalid\n", nn )); 235 continue; 236 } 237 } 238 else 239 valid_entries++; 240 241 if ( table.Tag == TTAG_head || table.Tag == TTAG_bhed ) 242 { 243 FT_UInt32 magic; 244 245 246 #ifndef TT_CONFIG_OPTION_EMBEDDED_BITMAPS 247 if ( table.Tag == TTAG_head ) 248 #endif 249 has_head = 1; 250 251 /* 252 * The table length should be 0x36, but certain font tools make it 253 * 0x38, so we will just check that it is greater. 254 * 255 * Note that according to the specification, the table must be 256 * padded to 32-bit lengths, but this doesn't apply to the value of 257 * its `Length' field! 258 * 259 */ 260 if ( table.Length < 0x36 ) 261 { 262 FT_TRACE2(( "check_table_dir:" 263 " `head' or `bhed' table too small\n" )); 264 error = FT_THROW( Table_Missing ); 265 goto Exit; 266 } 267 268 if ( FT_STREAM_SEEK( table.Offset + 12 ) || 269 FT_READ_ULONG( magic ) ) 270 goto Exit; 271 272 if ( magic != 0x5F0F3CF5UL ) 273 FT_TRACE2(( "check_table_dir:" 274 " invalid magic number in `head' or `bhed' table\n")); 275 276 if ( FT_STREAM_SEEK( offset + ( nn + 1 ) * 16 ) ) 277 goto Exit; 278 } 279 else if ( table.Tag == TTAG_SING ) 280 has_sing = 1; 281 else if ( table.Tag == TTAG_META ) 282 has_meta = 1; 283 } 284 285 *valid = valid_entries; 286 287 if ( !valid_entries ) 288 { 289 FT_TRACE2(( "check_table_dir: no valid tables found\n" )); 290 error = FT_THROW( Unknown_File_Format ); 291 goto Exit; 292 } 293 294 /* if `sing' and `meta' tables are present, there is no `head' table */ 295 if ( has_head || ( has_sing && has_meta ) ) 296 { 297 error = FT_Err_Ok; 298 goto Exit; 299 } 300 else 301 { 302 FT_TRACE2(( "check_table_dir:" )); 303 #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS 304 FT_TRACE2(( " neither `head', `bhed', nor `sing' table found\n" )); 305 #else 306 FT_TRACE2(( " neither `head' nor `sing' table found\n" )); 307 #endif 308 error = FT_THROW( Table_Missing ); 309 } 310 311 Exit: 312 return error; 313 } 314 315 316 /************************************************************************** 317 * 318 * @Function: 319 * tt_face_load_font_dir 320 * 321 * @Description: 322 * Loads the header of a SFNT font file. 323 * 324 * @Input: 325 * face :: 326 * A handle to the target face object. 327 * 328 * stream :: 329 * The input stream. 330 * 331 * @Output: 332 * sfnt :: 333 * The SFNT header. 334 * 335 * @Return: 336 * FreeType error code. 0 means success. 337 * 338 * @Note: 339 * The stream cursor must be at the beginning of the font directory. 340 */ 341 FT_LOCAL_DEF( FT_Error ) tt_face_load_font_dir(TT_Face face,FT_Stream stream)342 tt_face_load_font_dir( TT_Face face, 343 FT_Stream stream ) 344 { 345 SFNT_HeaderRec sfnt; 346 FT_Error error; 347 FT_Memory memory = stream->memory; 348 FT_UShort nn, valid_entries = 0; 349 350 static const FT_Frame_Field offset_table_fields[] = 351 { 352 #undef FT_STRUCTURE 353 #define FT_STRUCTURE SFNT_HeaderRec 354 355 FT_FRAME_START( 8 ), 356 FT_FRAME_USHORT( num_tables ), 357 FT_FRAME_USHORT( search_range ), 358 FT_FRAME_USHORT( entry_selector ), 359 FT_FRAME_USHORT( range_shift ), 360 FT_FRAME_END 361 }; 362 363 364 FT_TRACE2(( "tt_face_load_font_dir: %p\n", (void *)face )); 365 366 /* read the offset table */ 367 368 sfnt.offset = FT_STREAM_POS(); 369 370 if ( FT_READ_ULONG( sfnt.format_tag ) || 371 FT_STREAM_READ_FIELDS( offset_table_fields, &sfnt ) ) 372 goto Exit; 373 374 /* many fonts don't have these fields set correctly */ 375 #if 0 376 if ( sfnt.search_range != 1 << ( sfnt.entry_selector + 4 ) || 377 sfnt.search_range + sfnt.range_shift != sfnt.num_tables << 4 ) 378 return FT_THROW( Unknown_File_Format ); 379 #endif 380 381 /* load the table directory */ 382 383 FT_TRACE2(( "-- Number of tables: %10hu\n", sfnt.num_tables )); 384 FT_TRACE2(( "-- Format version: 0x%08lx\n", sfnt.format_tag )); 385 386 if ( sfnt.format_tag != TTAG_OTTO ) 387 { 388 /* check first */ 389 error = check_table_dir( &sfnt, stream, &valid_entries ); 390 if ( error ) 391 { 392 FT_TRACE2(( "tt_face_load_font_dir:" 393 " invalid table directory for TrueType\n" )); 394 goto Exit; 395 } 396 } 397 else 398 { 399 valid_entries = sfnt.num_tables; 400 if ( !valid_entries ) 401 { 402 FT_TRACE2(( "tt_face_load_font_dir: no valid tables found\n" )); 403 error = FT_THROW( Unknown_File_Format ); 404 goto Exit; 405 } 406 } 407 408 face->num_tables = valid_entries; 409 face->format_tag = sfnt.format_tag; 410 411 if ( FT_QNEW_ARRAY( face->dir_tables, face->num_tables ) ) 412 goto Exit; 413 414 if ( FT_STREAM_SEEK( sfnt.offset + 12 ) || 415 FT_FRAME_ENTER( sfnt.num_tables * 16L ) ) 416 goto Exit; 417 418 FT_TRACE2(( "\n" )); 419 FT_TRACE2(( " tag offset length checksum\n" )); 420 FT_TRACE2(( " ----------------------------------\n" )); 421 422 valid_entries = 0; 423 for ( nn = 0; nn < sfnt.num_tables; nn++ ) 424 { 425 TT_TableRec entry; 426 FT_UShort i; 427 FT_Bool duplicate; 428 429 430 entry.Tag = FT_GET_TAG4(); 431 entry.CheckSum = FT_GET_ULONG(); 432 entry.Offset = FT_GET_ULONG(); 433 entry.Length = FT_GET_ULONG(); 434 435 /* ignore invalid tables that can't be sanitized */ 436 437 if ( entry.Offset > stream->size ) 438 continue; 439 else if ( entry.Length > stream->size - entry.Offset ) 440 { 441 if ( entry.Tag == TTAG_hmtx || 442 entry.Tag == TTAG_vmtx ) 443 { 444 #ifdef FT_DEBUG_LEVEL_TRACE 445 FT_ULong old_length = entry.Length; 446 #endif 447 448 449 /* make metrics table length a multiple of 4 */ 450 entry.Length = ( stream->size - entry.Offset ) & ~3U; 451 452 FT_TRACE2(( " %c%c%c%c %08lx %08lx %08lx" 453 " (sanitized; original length %08lx)", 454 (FT_Char)( entry.Tag >> 24 ), 455 (FT_Char)( entry.Tag >> 16 ), 456 (FT_Char)( entry.Tag >> 8 ), 457 (FT_Char)( entry.Tag ), 458 entry.Offset, 459 entry.Length, 460 entry.CheckSum, 461 old_length )); 462 } 463 else 464 continue; 465 } 466 #ifdef FT_DEBUG_LEVEL_TRACE 467 else 468 FT_TRACE2(( " %c%c%c%c %08lx %08lx %08lx", 469 (FT_Char)( entry.Tag >> 24 ), 470 (FT_Char)( entry.Tag >> 16 ), 471 (FT_Char)( entry.Tag >> 8 ), 472 (FT_Char)( entry.Tag ), 473 entry.Offset, 474 entry.Length, 475 entry.CheckSum )); 476 #endif 477 478 /* ignore duplicate tables – the first one wins */ 479 duplicate = 0; 480 for ( i = 0; i < valid_entries; i++ ) 481 { 482 if ( face->dir_tables[i].Tag == entry.Tag ) 483 { 484 duplicate = 1; 485 break; 486 } 487 } 488 if ( duplicate ) 489 { 490 FT_TRACE2(( " (duplicate, ignored)\n" )); 491 continue; 492 } 493 else 494 { 495 FT_TRACE2(( "\n" )); 496 497 /* we finally have a valid entry */ 498 face->dir_tables[valid_entries++] = entry; 499 } 500 } 501 502 /* final adjustment to number of tables */ 503 face->num_tables = valid_entries; 504 505 FT_FRAME_EXIT(); 506 507 FT_TRACE2(( "table directory loaded\n" )); 508 FT_TRACE2(( "\n" )); 509 510 Exit: 511 return error; 512 } 513 514 515 /************************************************************************** 516 * 517 * @Function: 518 * tt_face_load_any 519 * 520 * @Description: 521 * Loads any font table into client memory. 522 * 523 * @Input: 524 * face :: 525 * The face object to look for. 526 * 527 * tag :: 528 * The tag of table to load. Use the value 0 if you want 529 * to access the whole font file, else set this parameter 530 * to a valid TrueType table tag that you can forge with 531 * the MAKE_TT_TAG macro. 532 * 533 * offset :: 534 * The starting offset in the table (or the file if 535 * tag == 0). 536 * 537 * length :: 538 * The address of the decision variable: 539 * 540 * If length == NULL: 541 * Loads the whole table. Returns an error if 542 * `offset' == 0! 543 * 544 * If *length == 0: 545 * Exits immediately; returning the length of the given 546 * table or of the font file, depending on the value of 547 * `tag'. 548 * 549 * If *length != 0: 550 * Loads the next `length' bytes of table or font, 551 * starting at offset `offset' (in table or font too). 552 * 553 * @Output: 554 * buffer :: 555 * The address of target buffer. 556 * 557 * @Return: 558 * FreeType error code. 0 means success. 559 */ 560 FT_LOCAL_DEF( FT_Error ) tt_face_load_any(TT_Face face,FT_ULong tag,FT_Long offset,FT_Byte * buffer,FT_ULong * length)561 tt_face_load_any( TT_Face face, 562 FT_ULong tag, 563 FT_Long offset, 564 FT_Byte* buffer, 565 FT_ULong* length ) 566 { 567 FT_Error error; 568 FT_Stream stream; 569 TT_Table table; 570 FT_ULong size; 571 572 573 if ( tag != 0 ) 574 { 575 /* look for tag in font directory */ 576 table = tt_face_lookup_table( face, tag ); 577 if ( !table ) 578 { 579 error = FT_THROW( Table_Missing ); 580 goto Exit; 581 } 582 583 offset += table->Offset; 584 size = table->Length; 585 } 586 else 587 /* tag == 0 -- the user wants to access the font file directly */ 588 size = face->root.stream->size; 589 590 if ( length && *length == 0 ) 591 { 592 *length = size; 593 594 return FT_Err_Ok; 595 } 596 597 if ( length ) 598 size = *length; 599 600 stream = face->root.stream; 601 /* the `if' is syntactic sugar for picky compilers */ 602 if ( FT_STREAM_READ_AT( offset, buffer, size ) ) 603 goto Exit; 604 605 Exit: 606 return error; 607 } 608 609 610 /************************************************************************** 611 * 612 * @Function: 613 * tt_face_load_generic_header 614 * 615 * @Description: 616 * Loads the TrueType table `head' or `bhed'. 617 * 618 * @Input: 619 * face :: 620 * A handle to the target face object. 621 * 622 * stream :: 623 * The input stream. 624 * 625 * @Return: 626 * FreeType error code. 0 means success. 627 */ 628 static FT_Error tt_face_load_generic_header(TT_Face face,FT_Stream stream,FT_ULong tag)629 tt_face_load_generic_header( TT_Face face, 630 FT_Stream stream, 631 FT_ULong tag ) 632 { 633 FT_Error error; 634 TT_Header* header; 635 636 static const FT_Frame_Field header_fields[] = 637 { 638 #undef FT_STRUCTURE 639 #define FT_STRUCTURE TT_Header 640 641 FT_FRAME_START( 54 ), 642 FT_FRAME_ULONG ( Table_Version ), 643 FT_FRAME_ULONG ( Font_Revision ), 644 FT_FRAME_LONG ( CheckSum_Adjust ), 645 FT_FRAME_LONG ( Magic_Number ), 646 FT_FRAME_USHORT( Flags ), 647 FT_FRAME_USHORT( Units_Per_EM ), 648 FT_FRAME_ULONG ( Created[0] ), 649 FT_FRAME_ULONG ( Created[1] ), 650 FT_FRAME_ULONG ( Modified[0] ), 651 FT_FRAME_ULONG ( Modified[1] ), 652 FT_FRAME_SHORT ( xMin ), 653 FT_FRAME_SHORT ( yMin ), 654 FT_FRAME_SHORT ( xMax ), 655 FT_FRAME_SHORT ( yMax ), 656 FT_FRAME_USHORT( Mac_Style ), 657 FT_FRAME_USHORT( Lowest_Rec_PPEM ), 658 FT_FRAME_SHORT ( Font_Direction ), 659 FT_FRAME_SHORT ( Index_To_Loc_Format ), 660 FT_FRAME_SHORT ( Glyph_Data_Format ), 661 FT_FRAME_END 662 }; 663 664 665 error = face->goto_table( face, tag, stream, 0 ); 666 if ( error ) 667 goto Exit; 668 669 header = &face->header; 670 671 if ( FT_STREAM_READ_FIELDS( header_fields, header ) ) 672 goto Exit; 673 674 FT_TRACE3(( "Units per EM: %4hu\n", header->Units_Per_EM )); 675 FT_TRACE3(( "IndexToLoc: %4hd\n", header->Index_To_Loc_Format )); 676 677 Exit: 678 return error; 679 } 680 681 682 FT_LOCAL_DEF( FT_Error ) tt_face_load_head(TT_Face face,FT_Stream stream)683 tt_face_load_head( TT_Face face, 684 FT_Stream stream ) 685 { 686 return tt_face_load_generic_header( face, stream, TTAG_head ); 687 } 688 689 690 #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS 691 692 FT_LOCAL_DEF( FT_Error ) tt_face_load_bhed(TT_Face face,FT_Stream stream)693 tt_face_load_bhed( TT_Face face, 694 FT_Stream stream ) 695 { 696 return tt_face_load_generic_header( face, stream, TTAG_bhed ); 697 } 698 699 #endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */ 700 701 702 /************************************************************************** 703 * 704 * @Function: 705 * tt_face_load_maxp 706 * 707 * @Description: 708 * Loads the maximum profile into a face object. 709 * 710 * @Input: 711 * face :: 712 * A handle to the target face object. 713 * 714 * stream :: 715 * The input stream. 716 * 717 * @Return: 718 * FreeType error code. 0 means success. 719 */ 720 FT_LOCAL_DEF( FT_Error ) tt_face_load_maxp(TT_Face face,FT_Stream stream)721 tt_face_load_maxp( TT_Face face, 722 FT_Stream stream ) 723 { 724 FT_Error error; 725 TT_MaxProfile* maxProfile = &face->max_profile; 726 727 static const FT_Frame_Field maxp_fields[] = 728 { 729 #undef FT_STRUCTURE 730 #define FT_STRUCTURE TT_MaxProfile 731 732 FT_FRAME_START( 6 ), 733 FT_FRAME_LONG ( version ), 734 FT_FRAME_USHORT( numGlyphs ), 735 FT_FRAME_END 736 }; 737 738 static const FT_Frame_Field maxp_fields_extra[] = 739 { 740 FT_FRAME_START( 26 ), 741 FT_FRAME_USHORT( maxPoints ), 742 FT_FRAME_USHORT( maxContours ), 743 FT_FRAME_USHORT( maxCompositePoints ), 744 FT_FRAME_USHORT( maxCompositeContours ), 745 FT_FRAME_USHORT( maxZones ), 746 FT_FRAME_USHORT( maxTwilightPoints ), 747 FT_FRAME_USHORT( maxStorage ), 748 FT_FRAME_USHORT( maxFunctionDefs ), 749 FT_FRAME_USHORT( maxInstructionDefs ), 750 FT_FRAME_USHORT( maxStackElements ), 751 FT_FRAME_USHORT( maxSizeOfInstructions ), 752 FT_FRAME_USHORT( maxComponentElements ), 753 FT_FRAME_USHORT( maxComponentDepth ), 754 FT_FRAME_END 755 }; 756 757 758 error = face->goto_table( face, TTAG_maxp, stream, 0 ); 759 if ( error ) 760 goto Exit; 761 762 if ( FT_STREAM_READ_FIELDS( maxp_fields, maxProfile ) ) 763 goto Exit; 764 765 maxProfile->maxPoints = 0; 766 maxProfile->maxContours = 0; 767 maxProfile->maxCompositePoints = 0; 768 maxProfile->maxCompositeContours = 0; 769 maxProfile->maxZones = 0; 770 maxProfile->maxTwilightPoints = 0; 771 maxProfile->maxStorage = 0; 772 maxProfile->maxFunctionDefs = 0; 773 maxProfile->maxInstructionDefs = 0; 774 maxProfile->maxStackElements = 0; 775 maxProfile->maxSizeOfInstructions = 0; 776 maxProfile->maxComponentElements = 0; 777 maxProfile->maxComponentDepth = 0; 778 779 if ( maxProfile->version >= 0x10000L ) 780 { 781 if ( FT_STREAM_READ_FIELDS( maxp_fields_extra, maxProfile ) ) 782 goto Exit; 783 784 /* XXX: an adjustment that is necessary to load certain */ 785 /* broken fonts like `Keystrokes MT' :-( */ 786 /* */ 787 /* We allocate 64 function entries by default when */ 788 /* the maxFunctionDefs value is smaller. */ 789 790 if ( maxProfile->maxFunctionDefs < 64 ) 791 maxProfile->maxFunctionDefs = 64; 792 793 /* we add 4 phantom points later */ 794 if ( maxProfile->maxTwilightPoints > ( 0xFFFFU - 4 ) ) 795 { 796 FT_TRACE0(( "tt_face_load_maxp:" 797 " too much twilight points in `maxp' table;\n" )); 798 FT_TRACE0(( " " 799 " some glyphs might be rendered incorrectly\n" )); 800 801 maxProfile->maxTwilightPoints = 0xFFFFU - 4; 802 } 803 } 804 805 FT_TRACE3(( "numGlyphs: %hu\n", maxProfile->numGlyphs )); 806 807 Exit: 808 return error; 809 } 810 811 812 /************************************************************************** 813 * 814 * @Function: 815 * tt_face_load_name 816 * 817 * @Description: 818 * Loads the name records. 819 * 820 * @Input: 821 * face :: 822 * A handle to the target face object. 823 * 824 * stream :: 825 * The input stream. 826 * 827 * @Return: 828 * FreeType error code. 0 means success. 829 */ 830 FT_LOCAL_DEF( FT_Error ) tt_face_load_name(TT_Face face,FT_Stream stream)831 tt_face_load_name( TT_Face face, 832 FT_Stream stream ) 833 { 834 FT_Error error; 835 FT_Memory memory = stream->memory; 836 FT_ULong table_pos, table_len; 837 FT_ULong storage_start, storage_limit; 838 TT_NameTable table; 839 TT_Name names = NULL; 840 TT_LangTag langTags = NULL; 841 842 static const FT_Frame_Field name_table_fields[] = 843 { 844 #undef FT_STRUCTURE 845 #define FT_STRUCTURE TT_NameTableRec 846 847 FT_FRAME_START( 6 ), 848 FT_FRAME_USHORT( format ), 849 FT_FRAME_USHORT( numNameRecords ), 850 FT_FRAME_USHORT( storageOffset ), 851 FT_FRAME_END 852 }; 853 854 static const FT_Frame_Field name_record_fields[] = 855 { 856 #undef FT_STRUCTURE 857 #define FT_STRUCTURE TT_NameRec 858 859 /* no FT_FRAME_START */ 860 FT_FRAME_USHORT( platformID ), 861 FT_FRAME_USHORT( encodingID ), 862 FT_FRAME_USHORT( languageID ), 863 FT_FRAME_USHORT( nameID ), 864 FT_FRAME_USHORT( stringLength ), 865 FT_FRAME_USHORT( stringOffset ), 866 FT_FRAME_END 867 }; 868 869 static const FT_Frame_Field langTag_record_fields[] = 870 { 871 #undef FT_STRUCTURE 872 #define FT_STRUCTURE TT_LangTagRec 873 874 /* no FT_FRAME_START */ 875 FT_FRAME_USHORT( stringLength ), 876 FT_FRAME_USHORT( stringOffset ), 877 FT_FRAME_END 878 }; 879 880 881 table = &face->name_table; 882 table->stream = stream; 883 884 error = face->goto_table( face, TTAG_name, stream, &table_len ); 885 if ( error ) 886 goto Exit; 887 888 table_pos = FT_STREAM_POS(); 889 890 if ( FT_STREAM_READ_FIELDS( name_table_fields, table ) ) 891 goto Exit; 892 893 /* Some popular Asian fonts have an invalid `storageOffset' value (it */ 894 /* should be at least `6 + 12*numNameRecords'). However, the string */ 895 /* offsets, computed as `storageOffset + entry->stringOffset', are */ 896 /* valid pointers within the name table... */ 897 /* */ 898 /* We thus can't check `storageOffset' right now. */ 899 /* */ 900 storage_start = table_pos + 6 + 12 * table->numNameRecords; 901 storage_limit = table_pos + table_len; 902 903 if ( storage_start > storage_limit ) 904 { 905 FT_ERROR(( "tt_face_load_name: invalid `name' table\n" )); 906 error = FT_THROW( Name_Table_Missing ); 907 goto Exit; 908 } 909 910 /* `name' format 1 contains additional language tag records, */ 911 /* which we load first */ 912 if ( table->format == 1 ) 913 { 914 if ( FT_STREAM_SEEK( storage_start ) || 915 FT_READ_USHORT( table->numLangTagRecords ) ) 916 goto Exit; 917 918 storage_start += 2 + 4 * table->numLangTagRecords; 919 920 /* allocate language tag records array */ 921 if ( FT_QNEW_ARRAY( langTags, table->numLangTagRecords ) || 922 FT_FRAME_ENTER( table->numLangTagRecords * 4 ) ) 923 goto Exit; 924 925 /* load language tags */ 926 { 927 TT_LangTag entry = langTags; 928 TT_LangTag limit = FT_OFFSET( entry, table->numLangTagRecords ); 929 930 931 for ( ; entry < limit; entry++ ) 932 { 933 (void)FT_STREAM_READ_FIELDS( langTag_record_fields, entry ); 934 935 /* check that the langTag string is within the table */ 936 entry->stringOffset += table_pos + table->storageOffset; 937 if ( entry->stringOffset < storage_start || 938 entry->stringOffset + entry->stringLength > storage_limit ) 939 { 940 /* invalid entry; ignore it */ 941 entry->stringLength = 0; 942 } 943 944 /* mark the string as not yet loaded */ 945 entry->string = NULL; 946 } 947 948 table->langTags = langTags; 949 langTags = NULL; 950 } 951 952 FT_FRAME_EXIT(); 953 954 (void)FT_STREAM_SEEK( table_pos + 6 ); 955 } 956 957 /* allocate name records array */ 958 if ( FT_QNEW_ARRAY( names, table->numNameRecords ) || 959 FT_FRAME_ENTER( table->numNameRecords * 12 ) ) 960 goto Exit; 961 962 /* load name records */ 963 { 964 TT_Name entry = names; 965 FT_UInt count = table->numNameRecords; 966 FT_UInt valid = 0; 967 968 969 for ( ; count > 0; count-- ) 970 { 971 if ( FT_STREAM_READ_FIELDS( name_record_fields, entry ) ) 972 continue; 973 974 /* check that the name is not empty */ 975 if ( entry->stringLength == 0 ) 976 continue; 977 978 /* check that the name string is within the table */ 979 entry->stringOffset += table_pos + table->storageOffset; 980 if ( entry->stringOffset < storage_start || 981 entry->stringOffset + entry->stringLength > storage_limit ) 982 { 983 /* invalid entry; ignore it */ 984 continue; 985 } 986 987 /* assure that we have a valid language tag ID, and */ 988 /* that the corresponding langTag entry is valid, too */ 989 if ( table->format == 1 && entry->languageID >= 0x8000U ) 990 { 991 if ( entry->languageID - 0x8000U >= table->numLangTagRecords || 992 !table->langTags[entry->languageID - 0x8000U].stringLength ) 993 { 994 /* invalid entry; ignore it */ 995 continue; 996 } 997 } 998 999 /* mark the string as not yet converted */ 1000 entry->string = NULL; 1001 1002 valid++; 1003 entry++; 1004 } 1005 1006 /* reduce array size to the actually used elements */ 1007 FT_MEM_QRENEW_ARRAY( names, 1008 table->numNameRecords, 1009 valid ); 1010 table->names = names; 1011 names = NULL; 1012 table->numNameRecords = valid; 1013 } 1014 1015 FT_FRAME_EXIT(); 1016 1017 /* everything went well, update face->num_names */ 1018 face->num_names = (FT_UShort)table->numNameRecords; 1019 1020 Exit: 1021 FT_FREE( names ); 1022 FT_FREE( langTags ); 1023 return error; 1024 } 1025 1026 1027 /************************************************************************** 1028 * 1029 * @Function: 1030 * tt_face_free_name 1031 * 1032 * @Description: 1033 * Frees the name records. 1034 * 1035 * @Input: 1036 * face :: 1037 * A handle to the target face object. 1038 */ 1039 FT_LOCAL_DEF( void ) tt_face_free_name(TT_Face face)1040 tt_face_free_name( TT_Face face ) 1041 { 1042 FT_Memory memory = face->root.driver->root.memory; 1043 TT_NameTable table = &face->name_table; 1044 1045 1046 if ( table->names ) 1047 { 1048 TT_Name entry = table->names; 1049 TT_Name limit = entry + table->numNameRecords; 1050 1051 1052 for ( ; entry < limit; entry++ ) 1053 FT_FREE( entry->string ); 1054 1055 FT_FREE( table->names ); 1056 } 1057 1058 if ( table->langTags ) 1059 { 1060 TT_LangTag entry = table->langTags; 1061 TT_LangTag limit = entry + table->numLangTagRecords; 1062 1063 1064 for ( ; entry < limit; entry++ ) 1065 FT_FREE( entry->string ); 1066 1067 FT_FREE( table->langTags ); 1068 } 1069 1070 table->numNameRecords = 0; 1071 table->numLangTagRecords = 0; 1072 table->format = 0; 1073 table->storageOffset = 0; 1074 } 1075 1076 1077 /************************************************************************** 1078 * 1079 * @Function: 1080 * tt_face_load_cmap 1081 * 1082 * @Description: 1083 * Loads the cmap directory in a face object. The cmaps themselves 1084 * are loaded on demand in the `ttcmap.c' module. 1085 * 1086 * @Input: 1087 * face :: 1088 * A handle to the target face object. 1089 * 1090 * stream :: 1091 * A handle to the input stream. 1092 * 1093 * @Return: 1094 * FreeType error code. 0 means success. 1095 */ 1096 1097 FT_LOCAL_DEF( FT_Error ) tt_face_load_cmap(TT_Face face,FT_Stream stream)1098 tt_face_load_cmap( TT_Face face, 1099 FT_Stream stream ) 1100 { 1101 FT_Error error; 1102 1103 1104 error = face->goto_table( face, TTAG_cmap, stream, &face->cmap_size ); 1105 if ( error ) 1106 goto Exit; 1107 1108 if ( FT_FRAME_EXTRACT( face->cmap_size, face->cmap_table ) ) 1109 face->cmap_size = 0; 1110 1111 Exit: 1112 return error; 1113 } 1114 1115 1116 1117 /************************************************************************** 1118 * 1119 * @Function: 1120 * tt_face_load_os2 1121 * 1122 * @Description: 1123 * Loads the OS2 table. 1124 * 1125 * @Input: 1126 * face :: 1127 * A handle to the target face object. 1128 * 1129 * stream :: 1130 * A handle to the input stream. 1131 * 1132 * @Return: 1133 * FreeType error code. 0 means success. 1134 */ 1135 FT_LOCAL_DEF( FT_Error ) tt_face_load_os2(TT_Face face,FT_Stream stream)1136 tt_face_load_os2( TT_Face face, 1137 FT_Stream stream ) 1138 { 1139 FT_Error error; 1140 TT_OS2* os2; 1141 1142 static const FT_Frame_Field os2_fields[] = 1143 { 1144 #undef FT_STRUCTURE 1145 #define FT_STRUCTURE TT_OS2 1146 1147 FT_FRAME_START( 78 ), 1148 FT_FRAME_USHORT( version ), 1149 FT_FRAME_SHORT ( xAvgCharWidth ), 1150 FT_FRAME_USHORT( usWeightClass ), 1151 FT_FRAME_USHORT( usWidthClass ), 1152 FT_FRAME_SHORT ( fsType ), 1153 FT_FRAME_SHORT ( ySubscriptXSize ), 1154 FT_FRAME_SHORT ( ySubscriptYSize ), 1155 FT_FRAME_SHORT ( ySubscriptXOffset ), 1156 FT_FRAME_SHORT ( ySubscriptYOffset ), 1157 FT_FRAME_SHORT ( ySuperscriptXSize ), 1158 FT_FRAME_SHORT ( ySuperscriptYSize ), 1159 FT_FRAME_SHORT ( ySuperscriptXOffset ), 1160 FT_FRAME_SHORT ( ySuperscriptYOffset ), 1161 FT_FRAME_SHORT ( yStrikeoutSize ), 1162 FT_FRAME_SHORT ( yStrikeoutPosition ), 1163 FT_FRAME_SHORT ( sFamilyClass ), 1164 FT_FRAME_BYTE ( panose[0] ), 1165 FT_FRAME_BYTE ( panose[1] ), 1166 FT_FRAME_BYTE ( panose[2] ), 1167 FT_FRAME_BYTE ( panose[3] ), 1168 FT_FRAME_BYTE ( panose[4] ), 1169 FT_FRAME_BYTE ( panose[5] ), 1170 FT_FRAME_BYTE ( panose[6] ), 1171 FT_FRAME_BYTE ( panose[7] ), 1172 FT_FRAME_BYTE ( panose[8] ), 1173 FT_FRAME_BYTE ( panose[9] ), 1174 FT_FRAME_ULONG ( ulUnicodeRange1 ), 1175 FT_FRAME_ULONG ( ulUnicodeRange2 ), 1176 FT_FRAME_ULONG ( ulUnicodeRange3 ), 1177 FT_FRAME_ULONG ( ulUnicodeRange4 ), 1178 FT_FRAME_BYTE ( achVendID[0] ), 1179 FT_FRAME_BYTE ( achVendID[1] ), 1180 FT_FRAME_BYTE ( achVendID[2] ), 1181 FT_FRAME_BYTE ( achVendID[3] ), 1182 1183 FT_FRAME_USHORT( fsSelection ), 1184 FT_FRAME_USHORT( usFirstCharIndex ), 1185 FT_FRAME_USHORT( usLastCharIndex ), 1186 FT_FRAME_SHORT ( sTypoAscender ), 1187 FT_FRAME_SHORT ( sTypoDescender ), 1188 FT_FRAME_SHORT ( sTypoLineGap ), 1189 FT_FRAME_USHORT( usWinAscent ), 1190 FT_FRAME_USHORT( usWinDescent ), 1191 FT_FRAME_END 1192 }; 1193 1194 /* `OS/2' version 1 and newer */ 1195 static const FT_Frame_Field os2_fields_extra1[] = 1196 { 1197 FT_FRAME_START( 8 ), 1198 FT_FRAME_ULONG( ulCodePageRange1 ), 1199 FT_FRAME_ULONG( ulCodePageRange2 ), 1200 FT_FRAME_END 1201 }; 1202 1203 /* `OS/2' version 2 and newer */ 1204 static const FT_Frame_Field os2_fields_extra2[] = 1205 { 1206 FT_FRAME_START( 10 ), 1207 FT_FRAME_SHORT ( sxHeight ), 1208 FT_FRAME_SHORT ( sCapHeight ), 1209 FT_FRAME_USHORT( usDefaultChar ), 1210 FT_FRAME_USHORT( usBreakChar ), 1211 FT_FRAME_USHORT( usMaxContext ), 1212 FT_FRAME_END 1213 }; 1214 1215 /* `OS/2' version 5 and newer */ 1216 static const FT_Frame_Field os2_fields_extra5[] = 1217 { 1218 FT_FRAME_START( 4 ), 1219 FT_FRAME_USHORT( usLowerOpticalPointSize ), 1220 FT_FRAME_USHORT( usUpperOpticalPointSize ), 1221 FT_FRAME_END 1222 }; 1223 1224 1225 /* We now support old Mac fonts where the OS/2 table doesn't */ 1226 /* exist. Simply put, we set the `version' field to 0xFFFF */ 1227 /* and test this value each time we need to access the table. */ 1228 error = face->goto_table( face, TTAG_OS2, stream, 0 ); 1229 if ( error ) 1230 goto Exit; 1231 1232 os2 = &face->os2; 1233 1234 if ( FT_STREAM_READ_FIELDS( os2_fields, os2 ) ) 1235 goto Exit; 1236 1237 os2->ulCodePageRange1 = 0; 1238 os2->ulCodePageRange2 = 0; 1239 os2->sxHeight = 0; 1240 os2->sCapHeight = 0; 1241 os2->usDefaultChar = 0; 1242 os2->usBreakChar = 0; 1243 os2->usMaxContext = 0; 1244 os2->usLowerOpticalPointSize = 0; 1245 os2->usUpperOpticalPointSize = 0xFFFF; 1246 1247 if ( os2->version >= 0x0001 ) 1248 { 1249 /* only version 1 tables */ 1250 if ( FT_STREAM_READ_FIELDS( os2_fields_extra1, os2 ) ) 1251 goto Exit; 1252 1253 if ( os2->version >= 0x0002 ) 1254 { 1255 /* only version 2 tables */ 1256 if ( FT_STREAM_READ_FIELDS( os2_fields_extra2, os2 ) ) 1257 goto Exit; 1258 1259 if ( os2->version >= 0x0005 ) 1260 { 1261 /* only version 5 tables */ 1262 if ( FT_STREAM_READ_FIELDS( os2_fields_extra5, os2 ) ) 1263 goto Exit; 1264 } 1265 } 1266 } 1267 1268 FT_TRACE3(( "sTypoAscender: %4hd\n", os2->sTypoAscender )); 1269 FT_TRACE3(( "sTypoDescender: %4hd\n", os2->sTypoDescender )); 1270 FT_TRACE3(( "usWinAscent: %4hu\n", os2->usWinAscent )); 1271 FT_TRACE3(( "usWinDescent: %4hu\n", os2->usWinDescent )); 1272 FT_TRACE3(( "fsSelection: 0x%2hx\n", os2->fsSelection )); 1273 1274 Exit: 1275 return error; 1276 } 1277 1278 1279 /************************************************************************** 1280 * 1281 * @Function: 1282 * tt_face_load_postscript 1283 * 1284 * @Description: 1285 * Loads the Postscript table. 1286 * 1287 * @Input: 1288 * face :: 1289 * A handle to the target face object. 1290 * 1291 * stream :: 1292 * A handle to the input stream. 1293 * 1294 * @Return: 1295 * FreeType error code. 0 means success. 1296 */ 1297 FT_LOCAL_DEF( FT_Error ) tt_face_load_post(TT_Face face,FT_Stream stream)1298 tt_face_load_post( TT_Face face, 1299 FT_Stream stream ) 1300 { 1301 FT_Error error; 1302 TT_Postscript* post = &face->postscript; 1303 1304 static const FT_Frame_Field post_fields[] = 1305 { 1306 #undef FT_STRUCTURE 1307 #define FT_STRUCTURE TT_Postscript 1308 1309 FT_FRAME_START( 32 ), 1310 FT_FRAME_LONG ( FormatType ), 1311 FT_FRAME_LONG ( italicAngle ), 1312 FT_FRAME_SHORT( underlinePosition ), 1313 FT_FRAME_SHORT( underlineThickness ), 1314 FT_FRAME_ULONG( isFixedPitch ), 1315 FT_FRAME_ULONG( minMemType42 ), 1316 FT_FRAME_ULONG( maxMemType42 ), 1317 FT_FRAME_ULONG( minMemType1 ), 1318 FT_FRAME_ULONG( maxMemType1 ), 1319 FT_FRAME_END 1320 }; 1321 1322 1323 error = face->goto_table( face, TTAG_post, stream, 0 ); 1324 if ( error ) 1325 return error; 1326 1327 if ( FT_STREAM_READ_FIELDS( post_fields, post ) ) 1328 return error; 1329 1330 if ( post->FormatType != 0x00030000L && 1331 post->FormatType != 0x00025000L && 1332 post->FormatType != 0x00020000L && 1333 post->FormatType != 0x00010000L ) 1334 return FT_THROW( Invalid_Post_Table_Format ); 1335 1336 /* we don't load the glyph names, we do that in another */ 1337 /* module (ttpost). */ 1338 1339 FT_TRACE3(( "FormatType: 0x%lx\n", post->FormatType )); 1340 FT_TRACE3(( "isFixedPitch: %s\n", post->isFixedPitch 1341 ? " yes" : " no" )); 1342 1343 return FT_Err_Ok; 1344 } 1345 1346 1347 /************************************************************************** 1348 * 1349 * @Function: 1350 * tt_face_load_pclt 1351 * 1352 * @Description: 1353 * Loads the PCL 5 Table. 1354 * 1355 * @Input: 1356 * face :: 1357 * A handle to the target face object. 1358 * 1359 * stream :: 1360 * A handle to the input stream. 1361 * 1362 * @Return: 1363 * FreeType error code. 0 means success. 1364 */ 1365 FT_LOCAL_DEF( FT_Error ) tt_face_load_pclt(TT_Face face,FT_Stream stream)1366 tt_face_load_pclt( TT_Face face, 1367 FT_Stream stream ) 1368 { 1369 static const FT_Frame_Field pclt_fields[] = 1370 { 1371 #undef FT_STRUCTURE 1372 #define FT_STRUCTURE TT_PCLT 1373 1374 FT_FRAME_START( 54 ), 1375 FT_FRAME_ULONG ( Version ), 1376 FT_FRAME_ULONG ( FontNumber ), 1377 FT_FRAME_USHORT( Pitch ), 1378 FT_FRAME_USHORT( xHeight ), 1379 FT_FRAME_USHORT( Style ), 1380 FT_FRAME_USHORT( TypeFamily ), 1381 FT_FRAME_USHORT( CapHeight ), 1382 FT_FRAME_USHORT( SymbolSet ), 1383 FT_FRAME_BYTES ( TypeFace, 16 ), 1384 FT_FRAME_BYTES ( CharacterComplement, 8 ), 1385 FT_FRAME_BYTES ( FileName, 6 ), 1386 FT_FRAME_CHAR ( StrokeWeight ), 1387 FT_FRAME_CHAR ( WidthType ), 1388 FT_FRAME_BYTE ( SerifStyle ), 1389 FT_FRAME_BYTE ( Reserved ), 1390 FT_FRAME_END 1391 }; 1392 1393 FT_Error error; 1394 TT_PCLT* pclt = &face->pclt; 1395 1396 1397 /* optional table */ 1398 error = face->goto_table( face, TTAG_PCLT, stream, 0 ); 1399 if ( error ) 1400 goto Exit; 1401 1402 if ( FT_STREAM_READ_FIELDS( pclt_fields, pclt ) ) 1403 goto Exit; 1404 1405 Exit: 1406 return error; 1407 } 1408 1409 1410 /************************************************************************** 1411 * 1412 * @Function: 1413 * tt_face_load_gasp 1414 * 1415 * @Description: 1416 * Loads the `gasp' table into a face object. 1417 * 1418 * @Input: 1419 * face :: 1420 * A handle to the target face object. 1421 * 1422 * stream :: 1423 * The input stream. 1424 * 1425 * @Return: 1426 * FreeType error code. 0 means success. 1427 */ 1428 FT_LOCAL_DEF( FT_Error ) tt_face_load_gasp(TT_Face face,FT_Stream stream)1429 tt_face_load_gasp( TT_Face face, 1430 FT_Stream stream ) 1431 { 1432 FT_Error error; 1433 FT_Memory memory = stream->memory; 1434 1435 FT_UShort j, num_ranges; 1436 TT_GaspRange gasp_ranges = NULL; 1437 1438 1439 /* the gasp table is optional */ 1440 error = face->goto_table( face, TTAG_gasp, stream, 0 ); 1441 if ( error ) 1442 goto Exit; 1443 1444 if ( FT_FRAME_ENTER( 4L ) ) 1445 goto Exit; 1446 1447 face->gasp.version = FT_GET_USHORT(); 1448 num_ranges = FT_GET_USHORT(); 1449 1450 FT_FRAME_EXIT(); 1451 1452 /* only support versions 0 and 1 of the table */ 1453 if ( face->gasp.version >= 2 ) 1454 { 1455 face->gasp.numRanges = 0; 1456 error = FT_THROW( Invalid_Table ); 1457 goto Exit; 1458 } 1459 1460 FT_TRACE3(( "numRanges: %hu\n", num_ranges )); 1461 1462 if ( FT_QNEW_ARRAY( gasp_ranges, num_ranges ) || 1463 FT_FRAME_ENTER( num_ranges * 4L ) ) 1464 goto Exit; 1465 1466 for ( j = 0; j < num_ranges; j++ ) 1467 { 1468 gasp_ranges[j].maxPPEM = FT_GET_USHORT(); 1469 gasp_ranges[j].gaspFlag = FT_GET_USHORT(); 1470 1471 FT_TRACE3(( "gaspRange %hu: rangeMaxPPEM %5hu, rangeGaspBehavior 0x%hx\n", 1472 j, 1473 gasp_ranges[j].maxPPEM, 1474 gasp_ranges[j].gaspFlag )); 1475 } 1476 1477 face->gasp.gaspRanges = gasp_ranges; 1478 gasp_ranges = NULL; 1479 face->gasp.numRanges = num_ranges; 1480 1481 FT_FRAME_EXIT(); 1482 1483 Exit: 1484 FT_FREE( gasp_ranges ); 1485 return error; 1486 } 1487 1488 1489 /* END */ 1490