Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(497)

Side by Side Diff: src/sfnt/sfobjs.c

Issue 89753003: Update freetype to latest version of ASOP. (Closed) Base URL: https://chromium.googlesource.com/chromium/src/third_party/freetype.git@master
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/sfnt/sfntpic.c ('k') | src/sfnt/ttbdf.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /***************************************************************************/ 1 /***************************************************************************/
2 /* */ 2 /* */
3 /* sfobjs.c */ 3 /* sfobjs.c */
4 /* */ 4 /* */
5 /* SFNT object management (base). */ 5 /* SFNT object management (base). */
6 /* */ 6 /* */
7 /* Copyright 1996-2008, 2010-2011 by */ 7 /* Copyright 1996-2008, 2010-2013 by */
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
9 /* */ 9 /* */
10 /* This file is part of the FreeType project, and may only be used, */ 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 */ 11 /* modified, and distributed under the terms of the FreeType project */
12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
13 /* this file you indicate that you have read the license and */ 13 /* this file you indicate that you have read the license and */
14 /* understand and accept it fully. */ 14 /* understand and accept it fully. */
15 /* */ 15 /* */
16 /***************************************************************************/ 16 /***************************************************************************/
17 17
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 57
58 58
59 len = (FT_UInt)entry->stringLength / 2; 59 len = (FT_UInt)entry->stringLength / 2;
60 60
61 if ( FT_NEW_ARRAY( string, len + 1 ) ) 61 if ( FT_NEW_ARRAY( string, len + 1 ) )
62 return NULL; 62 return NULL;
63 63
64 for ( n = 0; n < len; n++ ) 64 for ( n = 0; n < len; n++ )
65 { 65 {
66 code = FT_NEXT_USHORT( read ); 66 code = FT_NEXT_USHORT( read );
67
68 if ( code == 0 )
69 break;
70
67 if ( code < 32 || code > 127 ) 71 if ( code < 32 || code > 127 )
68 code = '?'; 72 code = '?';
69 73
70 string[n] = (char)code; 74 string[n] = (char)code;
71 } 75 }
72 76
73 string[len] = 0; 77 string[n] = 0;
74 78
75 return string; 79 return string;
76 } 80 }
77 81
78 82
79 /* convert an Apple Roman or symbol name entry to ASCII */ 83 /* convert an Apple Roman or symbol name entry to ASCII */
80 static FT_String* 84 static FT_String*
81 tt_name_entry_ascii_from_other( TT_NameEntry entry, 85 tt_name_entry_ascii_from_other( TT_NameEntry entry,
82 FT_Memory memory ) 86 FT_Memory memory )
83 { 87 {
84 FT_String* string = NULL; 88 FT_String* string = NULL;
85 FT_UInt len, code, n; 89 FT_UInt len, code, n;
86 FT_Byte* read = (FT_Byte*)entry->string; 90 FT_Byte* read = (FT_Byte*)entry->string;
87 FT_Error error; 91 FT_Error error;
88 92
89 93
90 len = (FT_UInt)entry->stringLength; 94 len = (FT_UInt)entry->stringLength;
91 95
92 if ( FT_NEW_ARRAY( string, len + 1 ) ) 96 if ( FT_NEW_ARRAY( string, len + 1 ) )
93 return NULL; 97 return NULL;
94 98
95 for ( n = 0; n < len; n++ ) 99 for ( n = 0; n < len; n++ )
96 { 100 {
97 code = *read++; 101 code = *read++;
102
103 if ( code == 0 )
104 break;
105
98 if ( code < 32 || code > 127 ) 106 if ( code < 32 || code > 127 )
99 code = '?'; 107 code = '?';
100 108
101 string[n] = (char)code; 109 string[n] = (char)code;
102 } 110 }
103 111
104 string[len] = 0; 112 string[n] = 0;
105 113
106 return string; 114 return string;
107 } 115 }
108 116
109 117
110 typedef FT_String* (*TT_NameEntry_ConvertFunc)( TT_NameEntry entry, 118 typedef FT_String* (*TT_NameEntry_ConvertFunc)( TT_NameEntry entry,
111 FT_Memory memory ); 119 FT_Memory memory );
112 120
113 121
114 /*************************************************************************/ 122 /*************************************************************************/
(...skipping 15 matching lines...) Expand all
130 /* */ 138 /* */
131 /* <Return> */ 139 /* <Return> */
132 /* FreeType error code. 0 means success. */ 140 /* FreeType error code. 0 means success. */
133 /* */ 141 /* */
134 static FT_Error 142 static FT_Error
135 tt_face_get_name( TT_Face face, 143 tt_face_get_name( TT_Face face,
136 FT_UShort nameid, 144 FT_UShort nameid,
137 FT_String** name ) 145 FT_String** name )
138 { 146 {
139 FT_Memory memory = face->root.memory; 147 FT_Memory memory = face->root.memory;
140 FT_Error error = SFNT_Err_Ok; 148 FT_Error error = FT_Err_Ok;
141 FT_String* result = NULL; 149 FT_String* result = NULL;
142 FT_UShort n; 150 FT_UShort n;
143 TT_NameEntryRec* rec; 151 TT_NameEntryRec* rec;
144 FT_Int found_apple = -1; 152 FT_Int found_apple = -1;
145 FT_Int found_apple_roman = -1; 153 FT_Int found_apple_roman = -1;
146 FT_Int found_apple_english = -1; 154 FT_Int found_apple_english = -1;
147 FT_Int found_win = -1; 155 FT_Int found_win = -1;
148 FT_Int found_unicode = -1; 156 FT_Int found_unicode = -1;
149 157
150 FT_Bool is_english = 0; 158 FT_Bool is_english = 0;
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 return error; 379 return error;
372 380
373 if ( tag != 0x00010000UL && 381 if ( tag != 0x00010000UL &&
374 tag != TTAG_ttcf && 382 tag != TTAG_ttcf &&
375 tag != TTAG_OTTO && 383 tag != TTAG_OTTO &&
376 tag != TTAG_true && 384 tag != TTAG_true &&
377 tag != TTAG_typ1 && 385 tag != TTAG_typ1 &&
378 tag != 0x00020000UL ) 386 tag != 0x00020000UL )
379 { 387 {
380 FT_TRACE2(( " not a font using the SFNT container format\n" )); 388 FT_TRACE2(( " not a font using the SFNT container format\n" ));
381 return SFNT_Err_Unknown_File_Format; 389 return FT_THROW( Unknown_File_Format );
382 } 390 }
383 391
384 face->ttc_header.tag = TTAG_ttcf; 392 face->ttc_header.tag = TTAG_ttcf;
385 393
386 if ( tag == TTAG_ttcf ) 394 if ( tag == TTAG_ttcf )
387 { 395 {
388 FT_Int n; 396 FT_Int n;
389 397
390 398
391 FT_TRACE3(( "sfnt_open_font: file is a collection\n" )); 399 FT_TRACE3(( "sfnt_open_font: file is a collection\n" ));
392 400
393 if ( FT_STREAM_READ_FIELDS( ttc_header_fields, &face->ttc_header ) ) 401 if ( FT_STREAM_READ_FIELDS( ttc_header_fields, &face->ttc_header ) )
394 return error; 402 return error;
395 403
396 if ( face->ttc_header.count == 0 ) 404 if ( face->ttc_header.count == 0 )
397 return SFNT_Err_Invalid_Table; 405 return FT_THROW( Invalid_Table );
398 406
399 /* a rough size estimate: let's conservatively assume that there */ 407 /* a rough size estimate: let's conservatively assume that there */
400 /* is just a single table info in each subfont header (12 + 16*1 = */ 408 /* is just a single table info in each subfont header (12 + 16*1 = */
401 /* 28 bytes), thus we have (at least) `12 + 4*count' bytes for the */ 409 /* 28 bytes), thus we have (at least) `12 + 4*count' bytes for the */
402 /* size of the TTC header plus `28*count' bytes for all subfont */ 410 /* size of the TTC header plus `28*count' bytes for all subfont */
403 /* headers */ 411 /* headers */
404 if ( (FT_ULong)face->ttc_header.count > stream->size / ( 28 + 4 ) ) 412 if ( (FT_ULong)face->ttc_header.count > stream->size / ( 28 + 4 ) )
405 return SFNT_Err_Array_Too_Large; 413 return FT_THROW( Array_Too_Large );
406 414
407 /* now read the offsets of each font in the file */ 415 /* now read the offsets of each font in the file */
408 if ( FT_NEW_ARRAY( face->ttc_header.offsets, face->ttc_header.count ) ) 416 if ( FT_NEW_ARRAY( face->ttc_header.offsets, face->ttc_header.count ) )
409 return error; 417 return error;
410 418
411 if ( FT_FRAME_ENTER( face->ttc_header.count * 4L ) ) 419 if ( FT_FRAME_ENTER( face->ttc_header.count * 4L ) )
412 return error; 420 return error;
413 421
414 for ( n = 0; n < face->ttc_header.count; n++ ) 422 for ( n = 0; n < face->ttc_header.count; n++ )
415 face->ttc_header.offsets[n] = FT_GET_ULONG(); 423 face->ttc_header.offsets[n] = FT_GET_ULONG();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 FT_UNUSED( params ); 458 FT_UNUSED( params );
451 459
452 460
453 sfnt = (SFNT_Service)face->sfnt; 461 sfnt = (SFNT_Service)face->sfnt;
454 if ( !sfnt ) 462 if ( !sfnt )
455 { 463 {
456 sfnt = (SFNT_Service)FT_Get_Module_Interface( library, "sfnt" ); 464 sfnt = (SFNT_Service)FT_Get_Module_Interface( library, "sfnt" );
457 if ( !sfnt ) 465 if ( !sfnt )
458 { 466 {
459 FT_ERROR(( "sfnt_init_face: cannot access `sfnt' module\n" )); 467 FT_ERROR(( "sfnt_init_face: cannot access `sfnt' module\n" ));
460 return SFNT_Err_Missing_Module; 468 return FT_THROW( Missing_Module );
461 } 469 }
462 470
463 face->sfnt = sfnt; 471 face->sfnt = sfnt;
464 face->goto_table = sfnt->goto_table; 472 face->goto_table = sfnt->goto_table;
465 } 473 }
466 474
467 FT_FACE_FIND_GLOBAL_SERVICE( face, face->psnames, POSTSCRIPT_CMAPS ); 475 FT_FACE_FIND_GLOBAL_SERVICE( face, face->psnames, POSTSCRIPT_CMAPS );
468 476
469 FT_TRACE2(( "SFNT driver\n" )); 477 FT_TRACE2(( "SFNT driver\n" ));
470 478
471 error = sfnt_open_font( stream, face ); 479 error = sfnt_open_font( stream, face );
472 if ( error ) 480 if ( error )
473 return error; 481 return error;
474 482
475 FT_TRACE2(( "sfnt_init_face: %08p, %ld\n", face, face_index )); 483 FT_TRACE2(( "sfnt_init_face: %08p, %ld\n", face, face_index ));
476 484
477 if ( face_index < 0 ) 485 if ( face_index < 0 )
478 face_index = 0; 486 face_index = 0;
479 487
480 if ( face_index >= face->ttc_header.count ) 488 if ( face_index >= face->ttc_header.count )
481 return SFNT_Err_Invalid_Argument; 489 return FT_THROW( Invalid_Argument );
482 490
483 if ( FT_STREAM_SEEK( face->ttc_header.offsets[face_index] ) ) 491 if ( FT_STREAM_SEEK( face->ttc_header.offsets[face_index] ) )
484 return error; 492 return error;
485 493
486 /* check that we have a valid TrueType file */ 494 /* check that we have a valid TrueType file */
487 error = sfnt->load_font_dir( face, stream ); 495 error = sfnt->load_font_dir( face, stream );
488 if ( error ) 496 if ( error )
489 return error; 497 return error;
490 498
491 face->root.num_faces = face->ttc_header.count; 499 face->root.num_faces = face->ttc_header.count;
492 face->root.face_index = face_index; 500 face->root.face_index = face_index;
493 501
494 return error; 502 return error;
495 } 503 }
496 504
497 505
498 #define LOAD_( x ) \ 506 #define LOAD_( x ) \
499 do { \ 507 do { \
500 FT_TRACE2(( "`" #x "' " )); \ 508 FT_TRACE2(( "`" #x "' " )); \
501 FT_TRACE3(( "-->\n" )); \ 509 FT_TRACE3(( "-->\n" )); \
502 \ 510 \
503 error = sfnt->load_##x( face, stream ); \ 511 error = sfnt->load_ ## x( face, stream ); \
504 \ 512 \
505 FT_TRACE2(( "%s\n", ( !error ) \ 513 FT_TRACE2(( "%s\n", ( !error ) \
506 ? "loaded" \ 514 ? "loaded" \
507 : ( error == SFNT_Err_Table_Missing ) \ 515 : FT_ERR_EQ( error, Table_Missing ) \
508 ? "missing" \ 516 ? "missing" \
509 : "failed to load" )); \ 517 : "failed to load" )); \
510 FT_TRACE3(( "\n" )); \ 518 FT_TRACE3(( "\n" )); \
511 } while ( 0 ) 519 } while ( 0 )
512 520
513 #define LOADM_( x, vertical ) \ 521 #define LOADM_( x, vertical ) \
514 do { \ 522 do { \
515 FT_TRACE2(( "`%s" #x "' ", \ 523 FT_TRACE2(( "`%s" #x "' ", \
516 vertical ? "vertical " : "" )); \ 524 vertical ? "vertical " : "" )); \
517 FT_TRACE3(( "-->\n" )); \ 525 FT_TRACE3(( "-->\n" )); \
518 \ 526 \
519 error = sfnt->load_##x( face, stream, vertical ); \ 527 error = sfnt->load_ ## x( face, stream, vertical ); \
520 \ 528 \
521 FT_TRACE2(( "%s\n", ( !error ) \ 529 FT_TRACE2(( "%s\n", ( !error ) \
522 ? "loaded" \ 530 ? "loaded" \
523 : ( error == SFNT_Err_Table_Missing ) \ 531 : FT_ERR_EQ( error, Table_Missing ) \
524 ? "missing" \ 532 ? "missing" \
525 : "failed to load" )); \ 533 : "failed to load" )); \
526 FT_TRACE3(( "\n" )); \ 534 FT_TRACE3(( "\n" )); \
527 } while ( 0 ) 535 } while ( 0 )
528 536
529 #define GET_NAME( id, field ) \ 537 #define GET_NAME( id, field ) \
530 do { \ 538 do { \
531 error = tt_face_get_name( face, TT_NAME_ID_##id, field ); \ 539 error = tt_face_get_name( face, TT_NAME_ID_ ## id, field ); \
532 if ( error ) \ 540 if ( error ) \
533 goto Exit; \ 541 goto Exit; \
534 } while ( 0 ) 542 } while ( 0 )
535 543
536 544
537 FT_LOCAL_DEF( FT_Error ) 545 FT_LOCAL_DEF( FT_Error )
538 sfnt_load_face( FT_Stream stream, 546 sfnt_load_face( FT_Stream stream,
539 TT_Face face, 547 TT_Face face,
540 FT_Int face_index, 548 FT_Int face_index,
541 FT_Int num_params, 549 FT_Int num_params,
542 FT_Parameter* params ) 550 FT_Parameter* params )
543 { 551 {
544 FT_Error error; 552 FT_Error error;
545 #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES 553 #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
546 FT_Error psnames_error; 554 FT_Error psnames_error;
547 #endif 555 #endif
548 FT_Bool has_outline; 556 FT_Bool has_outline;
549 FT_Bool is_apple_sbit; 557 FT_Bool is_apple_sbit;
550 FT_Bool ignore_preferred_family = FALSE; 558 FT_Bool ignore_preferred_family = FALSE;
551 FT_Bool ignore_preferred_subfamily = FALSE; 559 FT_Bool ignore_preferred_subfamily = FALSE;
552 560
553 SFNT_Service sfnt = (SFNT_Service)face->sfnt; 561 SFNT_Service sfnt = (SFNT_Service)face->sfnt;
554 562
555 FT_UNUSED( face_index ); 563 FT_UNUSED( face_index );
556 564
565
557 /* Check parameters */ 566 /* Check parameters */
558 567
559 { 568 {
560 FT_Int i; 569 FT_Int i;
561 570
562 571
563 for ( i = 0; i < num_params; i++ ) 572 for ( i = 0; i < num_params; i++ )
564 { 573 {
565 if ( params[i].tag == FT_PARAM_TAG_IGNORE_PREFERRED_FAMILY ) 574 if ( params[i].tag == FT_PARAM_TAG_IGNORE_PREFERRED_FAMILY )
566 ignore_preferred_family = TRUE; 575 ignore_preferred_family = TRUE;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 /* sbit font file */ 621 /* sbit font file */
613 if ( !is_apple_sbit ) 622 if ( !is_apple_sbit )
614 { 623 {
615 LOAD_( head ); 624 LOAD_( head );
616 if ( error ) 625 if ( error )
617 goto Exit; 626 goto Exit;
618 } 627 }
619 628
620 if ( face->header.Units_Per_EM == 0 ) 629 if ( face->header.Units_Per_EM == 0 )
621 { 630 {
622 error = SFNT_Err_Invalid_Table; 631 error = FT_THROW( Invalid_Table );
623 632
624 goto Exit; 633 goto Exit;
625 } 634 }
626 635
627 /* the following tables are often not present in embedded TrueType */ 636 /* the following tables are often not present in embedded TrueType */
628 /* fonts within PDF documents, so don't check for them. */ 637 /* fonts within PDF documents, so don't check for them. */
629 LOAD_( maxp ); 638 LOAD_( maxp );
630 LOAD_( cmap ); 639 LOAD_( cmap );
631 640
632 /* the following tables are optional in PCL fonts -- */ 641 /* the following tables are optional in PCL fonts -- */
633 /* don't check for errors */ 642 /* don't check for errors */
634 LOAD_( name ); 643 LOAD_( name );
635 LOAD_( post ); 644 LOAD_( post );
636 645
637 #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES 646 #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
638 psnames_error = error; 647 psnames_error = error;
639 #endif 648 #endif
640 649
641 /* do not load the metrics headers and tables if this is an Apple */ 650 /* do not load the metrics headers and tables if this is an Apple */
642 /* sbit font file */ 651 /* sbit font file */
643 if ( !is_apple_sbit ) 652 if ( !is_apple_sbit )
644 { 653 {
645 /* load the `hhea' and `hmtx' tables */ 654 /* load the `hhea' and `hmtx' tables */
646 LOADM_( hhea, 0 ); 655 LOADM_( hhea, 0 );
647 if ( !error ) 656 if ( !error )
648 { 657 {
649 LOADM_( hmtx, 0 ); 658 LOADM_( hmtx, 0 );
650 if ( error == SFNT_Err_Table_Missing ) 659 if ( FT_ERR_EQ( error, Table_Missing ) )
651 { 660 {
652 error = SFNT_Err_Hmtx_Table_Missing; 661 error = FT_THROW( Hmtx_Table_Missing );
653 662
654 #ifdef FT_CONFIG_OPTION_INCREMENTAL 663 #ifdef FT_CONFIG_OPTION_INCREMENTAL
655 /* If this is an incrementally loaded font and there are */ 664 /* If this is an incrementally loaded font and there are */
656 /* overriding metrics, tolerate a missing `hmtx' table. */ 665 /* overriding metrics, tolerate a missing `hmtx' table. */
657 if ( face->root.internal->incremental_interface && 666 if ( face->root.internal->incremental_interface &&
658 face->root.internal->incremental_interface->funcs-> 667 face->root.internal->incremental_interface->funcs->
659 get_glyph_metrics ) 668 get_glyph_metrics )
660 { 669 {
661 face->horizontal.number_Of_HMetrics = 0; 670 face->horizontal.number_Of_HMetrics = 0;
662 error = SFNT_Err_Ok; 671 error = FT_Err_Ok;
663 } 672 }
664 #endif 673 #endif
665 } 674 }
666 } 675 }
667 else if ( error == SFNT_Err_Table_Missing ) 676 else if ( FT_ERR_EQ( error, Table_Missing ) )
668 { 677 {
669 /* No `hhea' table necessary for SFNT Mac fonts. */ 678 /* No `hhea' table necessary for SFNT Mac fonts. */
670 if ( face->format_tag == TTAG_true ) 679 if ( face->format_tag == TTAG_true )
671 { 680 {
672 FT_TRACE2(( "This is an SFNT Mac font.\n" )); 681 FT_TRACE2(( "This is an SFNT Mac font.\n" ));
673 682
674 has_outline = 0; 683 has_outline = 0;
675 error = SFNT_Err_Ok; 684 error = FT_Err_Ok;
676 } 685 }
677 else 686 else
678 { 687 {
679 error = SFNT_Err_Horiz_Header_Missing; 688 error = FT_THROW( Horiz_Header_Missing );
680 689
681 #ifdef FT_CONFIG_OPTION_INCREMENTAL 690 #ifdef FT_CONFIG_OPTION_INCREMENTAL
682 /* If this is an incrementally loaded font and there are */ 691 /* If this is an incrementally loaded font and there are */
683 /* overriding metrics, tolerate a missing `hhea' table. */ 692 /* overriding metrics, tolerate a missing `hhea' table. */
684 if ( face->root.internal->incremental_interface && 693 if ( face->root.internal->incremental_interface &&
685 face->root.internal->incremental_interface->funcs-> 694 face->root.internal->incremental_interface->funcs->
686 get_glyph_metrics ) 695 get_glyph_metrics )
687 { 696 {
688 face->horizontal.number_Of_HMetrics = 0; 697 face->horizontal.number_Of_HMetrics = 0;
689 error = SFNT_Err_Ok; 698 error = FT_Err_Ok;
690 } 699 }
691 #endif 700 #endif
692 701
693 } 702 }
694 } 703 }
695 704
696 if ( error ) 705 if ( error )
697 goto Exit; 706 goto Exit;
698 707
699 /* try to load the `vhea' and `vmtx' tables */ 708 /* try to load the `vhea' and `vmtx' tables */
700 LOADM_( hhea, 1 ); 709 LOADM_( hhea, 1 );
701 if ( !error ) 710 if ( !error )
702 { 711 {
703 LOADM_( hmtx, 1 ); 712 LOADM_( hmtx, 1 );
704 if ( !error ) 713 if ( !error )
705 face->vertical_info = 1; 714 face->vertical_info = 1;
706 } 715 }
707 716
708 if ( error && error != SFNT_Err_Table_Missing ) 717 if ( error && FT_ERR_NEQ( error, Table_Missing ) )
709 goto Exit; 718 goto Exit;
710 719
711 LOAD_( os2 ); 720 LOAD_( os2 );
712 if ( error ) 721 if ( error )
713 { 722 {
714 /* we treat the table as missing if there are any errors */ 723 /* we treat the table as missing if there are any errors */
715 face->os2.version = 0xFFFFU; 724 face->os2.version = 0xFFFFU;
716 } 725 }
717 } 726 }
718 727
719 /* the optional tables */ 728 /* the optional tables */
720 729
721 /* embedded bitmap support */ 730 /* embedded bitmap support */
722 if ( sfnt->load_eblc ) 731 if ( sfnt->load_eblc )
723 { 732 {
724 LOAD_( eblc ); 733 LOAD_( eblc );
725 if ( error ) 734 if ( error )
726 { 735 {
727 /* a font which contains neither bitmaps nor outlines is */ 736 /* a font which contains neither bitmaps nor outlines is */
728 /* still valid (although rather useless in most cases); */ 737 /* still valid (although rather useless in most cases); */
729 /* however, you can find such stripped fonts in PDFs */ 738 /* however, you can find such stripped fonts in PDFs */
730 if ( error == SFNT_Err_Table_Missing ) 739 if ( FT_ERR_EQ( error, Table_Missing ) )
731 error = SFNT_Err_Ok; 740 error = FT_Err_Ok;
732 else 741 else
733 goto Exit; 742 goto Exit;
734 } 743 }
735 } 744 }
736 745
737 LOAD_( pclt ); 746 LOAD_( pclt );
738 if ( error ) 747 if ( error )
739 { 748 {
740 if ( error != SFNT_Err_Table_Missing ) 749 if ( FT_ERR_NEQ( error, Table_Missing ) )
741 goto Exit; 750 goto Exit;
742 751
743 face->pclt.Version = 0; 752 face->pclt.Version = 0;
744 } 753 }
745 754
746 /* consider the kerning and gasp tables as optional */ 755 /* consider the kerning and gasp tables as optional */
747 LOAD_( gasp ); 756 LOAD_( gasp );
748 LOAD_( kern ); 757 LOAD_( kern );
749 758
750 face->root.num_glyphs = face->max_profile.numGlyphs; 759 face->root.num_glyphs = face->max_profile.numGlyphs;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 /* */ 805 /* */
797 if ( has_outline == TRUE ) 806 if ( has_outline == TRUE )
798 flags |= FT_FACE_FLAG_SCALABLE; /* scalable outlines */ 807 flags |= FT_FACE_FLAG_SCALABLE; /* scalable outlines */
799 808
800 /* The sfnt driver only supports bitmap fonts natively, thus we */ 809 /* The sfnt driver only supports bitmap fonts natively, thus we */
801 /* don't set FT_FACE_FLAG_HINTER. */ 810 /* don't set FT_FACE_FLAG_HINTER. */
802 flags |= FT_FACE_FLAG_SFNT | /* SFNT file format */ 811 flags |= FT_FACE_FLAG_SFNT | /* SFNT file format */
803 FT_FACE_FLAG_HORIZONTAL; /* horizontal data */ 812 FT_FACE_FLAG_HORIZONTAL; /* horizontal data */
804 813
805 #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES 814 #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
806 if ( psnames_error == SFNT_Err_Ok && 815 if ( !psnames_error &&
807 face->postscript.FormatType != 0x00030000L ) 816 face->postscript.FormatType != 0x00030000L )
808 flags |= FT_FACE_FLAG_GLYPH_NAMES; 817 flags |= FT_FACE_FLAG_GLYPH_NAMES;
809 #endif 818 #endif
810 819
811 /* fixed width font? */ 820 /* fixed width font? */
812 if ( face->postscript.isFixedPitch ) 821 if ( face->postscript.isFixedPitch )
813 flags |= FT_FACE_FLAG_FIXED_WIDTH; 822 flags |= FT_FACE_FLAG_FIXED_WIDTH;
814 823
815 /* vertical information? */ 824 /* vertical information? */
816 if ( face->vertical_info ) 825 if ( face->vertical_info )
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 912
904 /* 913 /*
905 * Now allocate the root array of FT_Bitmap_Size records and 914 * Now allocate the root array of FT_Bitmap_Size records and
906 * populate them. Unfortunately, it isn't possible to indicate bit 915 * populate them. Unfortunately, it isn't possible to indicate bit
907 * depths in the FT_Bitmap_Size record. This is a design error. 916 * depths in the FT_Bitmap_Size record. This is a design error.
908 */ 917 */
909 { 918 {
910 FT_UInt i, count; 919 FT_UInt i, count;
911 920
912 921
913 #ifndef FT_CONFIG_OPTION_OLD_INTERNALS
914 count = face->sbit_num_strikes; 922 count = face->sbit_num_strikes;
915 #else
916 count = (FT_UInt)face->num_sbit_strikes;
917 #endif
918 923
919 if ( count > 0 ) 924 if ( count > 0 )
920 { 925 {
921 FT_Memory memory = face->root.stream->memory; 926 FT_Memory memory = face->root.stream->memory;
922 FT_UShort em_size = face->header.Units_Per_EM; 927 FT_UShort em_size = face->header.Units_Per_EM;
923 FT_Short avgwidth = face->os2.xAvgCharWidth; 928 FT_Short avgwidth = face->os2.xAvgCharWidth;
924 FT_Size_Metrics metrics; 929 FT_Size_Metrics metrics;
925 930
926 931
927 if ( em_size == 0 || face->os2.version == 0xFFFFU ) 932 if ( em_size == 0 || face->os2.version == 0xFFFFU )
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
1108 { 1113 {
1109 FT_Stream stream = FT_FACE_STREAM( face ); 1114 FT_Stream stream = FT_FACE_STREAM( face );
1110 1115
1111 1116
1112 /* simply release the 'cmap' table frame */ 1117 /* simply release the 'cmap' table frame */
1113 FT_FRAME_RELEASE( face->cmap_table ); 1118 FT_FRAME_RELEASE( face->cmap_table );
1114 face->cmap_size = 0; 1119 face->cmap_size = 0;
1115 } 1120 }
1116 1121
1117 /* freeing the horizontal metrics */ 1122 /* freeing the horizontal metrics */
1118 #ifndef FT_CONFIG_OPTION_OLD_INTERNALS
1119 { 1123 {
1120 FT_Stream stream = FT_FACE_STREAM( face ); 1124 FT_Stream stream = FT_FACE_STREAM( face );
1121 1125
1122 1126
1123 FT_FRAME_RELEASE( face->horz_metrics ); 1127 FT_FRAME_RELEASE( face->horz_metrics );
1124 FT_FRAME_RELEASE( face->vert_metrics ); 1128 FT_FRAME_RELEASE( face->vert_metrics );
1125 face->horz_metrics_size = 0; 1129 face->horz_metrics_size = 0;
1126 face->vert_metrics_size = 0; 1130 face->vert_metrics_size = 0;
1127 } 1131 }
1128 #else
1129 FT_FREE( face->horizontal.long_metrics );
1130 FT_FREE( face->horizontal.short_metrics );
1131 #endif
1132 1132
1133 /* freeing the vertical ones, if any */ 1133 /* freeing the vertical ones, if any */
1134 if ( face->vertical_info ) 1134 if ( face->vertical_info )
1135 { 1135 {
1136 FT_FREE( face->vertical.long_metrics ); 1136 FT_FREE( face->vertical.long_metrics );
1137 FT_FREE( face->vertical.short_metrics ); 1137 FT_FREE( face->vertical.short_metrics );
1138 face->vertical_info = 0; 1138 face->vertical_info = 0;
1139 } 1139 }
1140 1140
1141 /* freeing the gasp table */ 1141 /* freeing the gasp table */
(...skipping 12 matching lines...) Expand all
1154 FT_FREE( face->root.available_sizes ); 1154 FT_FREE( face->root.available_sizes );
1155 face->root.num_fixed_sizes = 0; 1155 face->root.num_fixed_sizes = 0;
1156 1156
1157 FT_FREE( face->postscript_name ); 1157 FT_FREE( face->postscript_name );
1158 1158
1159 face->sfnt = 0; 1159 face->sfnt = 0;
1160 } 1160 }
1161 1161
1162 1162
1163 /* END */ 1163 /* END */
OLDNEW
« no previous file with comments | « src/sfnt/sfntpic.c ('k') | src/sfnt/ttbdf.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698