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

Side by Side Diff: third_party/freetype/src/cff/cffload.c

Issue 815103002: Update freetype to 2.5.4. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Adjust GYP and GN Created 6 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 | « third_party/freetype/src/cff/cffload.h ('k') | third_party/freetype/src/cff/cffobjs.h » ('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 /* cffload.c */ 3 /* cffload.c */
4 /* */ 4 /* */
5 /* OpenType and CFF data/program tables loader (body). */ 5 /* OpenType and CFF data/program tables loader (body). */
6 /* */ 6 /* */
7 /* Copyright 1996-2013 by */ 7 /* Copyright 1996-2014 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
18 18
19 #include "../../include/ft2build.h" 19 #include <ft2build.h>
20 #include "../../include/freetype/internal/ftdebug.h" 20 #include FT_INTERNAL_DEBUG_H
21 #include "../../include/freetype/internal/ftobjs.h" 21 #include FT_INTERNAL_OBJECTS_H
22 #include "../../include/freetype/internal/ftstream.h" 22 #include FT_INTERNAL_STREAM_H
23 #include "../../include/freetype/tttags.h" 23 #include FT_TRUETYPE_TAGS_H
24 #include "../../include/freetype/t1tables.h" 24 #include FT_TYPE1_TABLES_H
25 25
26 #include "cffload.h" 26 #include "cffload.h"
27 #include "cffparse.h" 27 #include "cffparse.h"
28 28
29 #include "cfferrs.h" 29 #include "cfferrs.h"
30 30
31 31
32 #if 1 32 #if 1
33 33
34 static const FT_UShort cff_isoadobe_charset[229] = 34 static const FT_UShort cff_isoadobe_charset[229] =
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 { 407 {
408 FT_ULong n, cur_offset; 408 FT_ULong n, cur_offset;
409 FT_ULong extra = 0; 409 FT_ULong extra = 0;
410 FT_Byte* org_bytes = idx->bytes; 410 FT_Byte* org_bytes = idx->bytes;
411 411
412 412
413 /* at this point, `idx->offsets' can't be NULL */ 413 /* at this point, `idx->offsets' can't be NULL */
414 cur_offset = idx->offsets[0] - 1; 414 cur_offset = idx->offsets[0] - 1;
415 415
416 /* sanity check */ 416 /* sanity check */
417 if ( cur_offset >= idx->data_size ) 417 if ( cur_offset != 0 )
418 { 418 {
419 FT_TRACE0(( "cff_index_get_pointers:" 419 FT_TRACE0(( "cff_index_get_pointers:"
420 " invalid first offset value %d set to zero\n", 420 " invalid first offset value %d set to zero\n",
421 cur_offset )); 421 cur_offset ));
422 cur_offset = 0; 422 cur_offset = 0;
423 } 423 }
424 424
425 if ( !pool ) 425 if ( !pool )
426 t[0] = org_bytes + cur_offset; 426 t[0] = org_bytes + cur_offset;
427 else 427 else
428 t[0] = new_bytes + cur_offset; 428 t[0] = new_bytes + cur_offset;
429 429
430 for ( n = 1; n <= idx->count; n++ ) 430 for ( n = 1; n <= idx->count; n++ )
431 { 431 {
432 FT_ULong next_offset = idx->offsets[n] - 1; 432 FT_ULong next_offset = idx->offsets[n] - 1;
433 433
434 434
435 /* empty slot + two sanity checks for invalid offset tables */ 435 /* two sanity checks for invalid offset tables */
436 if ( next_offset == 0 || 436 if ( next_offset < cur_offset )
437 next_offset < cur_offset ||
438 ( next_offset >= idx->data_size && n < idx->count ) )
439 next_offset = cur_offset; 437 next_offset = cur_offset;
438 else if ( next_offset > idx->data_size )
439 next_offset = idx->data_size;
440 440
441 if ( !pool ) 441 if ( !pool )
442 t[n] = org_bytes + next_offset; 442 t[n] = org_bytes + next_offset;
443 else 443 else
444 { 444 {
445 t[n] = new_bytes + next_offset + extra; 445 t[n] = new_bytes + next_offset + extra;
446 446
447 if ( next_offset != cur_offset ) 447 if ( next_offset != cur_offset )
448 { 448 {
449 FT_MEM_COPY( t[n - 1], org_bytes + cur_offset, t[n] - t[n - 1] ); 449 FT_MEM_COPY( t[n - 1], org_bytes + cur_offset, t[n] - t[n - 1] );
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 switch ( format ) 682 switch ( format )
683 { 683 {
684 case 0: /* format 0, that's simple */ 684 case 0: /* format 0, that's simple */
685 fdselect->data_size = num_glyphs; 685 fdselect->data_size = num_glyphs;
686 goto Load_Data; 686 goto Load_Data;
687 687
688 case 3: /* format 3, a tad more complex */ 688 case 3: /* format 3, a tad more complex */
689 if ( FT_READ_USHORT( num_ranges ) ) 689 if ( FT_READ_USHORT( num_ranges ) )
690 goto Exit; 690 goto Exit;
691 691
692 if ( !num_ranges )
693 {
694 FT_TRACE0(( "CFF_Load_FD_Select: empty FDSelect array\n" ));
695 error = FT_THROW( Invalid_File_Format );
696 goto Exit;
697 }
698
692 fdselect->data_size = num_ranges * 3 + 2; 699 fdselect->data_size = num_ranges * 3 + 2;
693 700
694 Load_Data: 701 Load_Data:
695 if ( FT_FRAME_EXTRACT( fdselect->data_size, fdselect->data ) ) 702 if ( FT_FRAME_EXTRACT( fdselect->data_size, fdselect->data ) )
696 goto Exit; 703 goto Exit;
697 break; 704 break;
698 705
699 default: /* hmm... that's wrong */ 706 default: /* hmm... that's wrong */
700 error = FT_THROW( Invalid_File_Format ); 707 error = FT_THROW( Invalid_File_Format );
701 } 708 }
(...skipping 10 matching lines...) Expand all
712 FT_Byte fd = 0; 719 FT_Byte fd = 0;
713 720
714 721
715 switch ( fdselect->format ) 722 switch ( fdselect->format )
716 { 723 {
717 case 0: 724 case 0:
718 fd = fdselect->data[glyph_index]; 725 fd = fdselect->data[glyph_index];
719 break; 726 break;
720 727
721 case 3: 728 case 3:
722 /* first, compare to cache */ 729 /* first, compare to the cache */
723 if ( (FT_UInt)( glyph_index - fdselect->cache_first ) < 730 if ( (FT_UInt)( glyph_index - fdselect->cache_first ) <
724 fdselect->cache_count ) 731 fdselect->cache_count )
725 { 732 {
726 fd = fdselect->cache_fd; 733 fd = fdselect->cache_fd;
727 break; 734 break;
728 } 735 }
729 736
730 /* then, lookup the ranges array */ 737 /* then, look up the ranges array */
731 { 738 {
732 FT_Byte* p = fdselect->data; 739 FT_Byte* p = fdselect->data;
733 FT_Byte* p_limit = p + fdselect->data_size; 740 FT_Byte* p_limit = p + fdselect->data_size;
734 FT_Byte fd2; 741 FT_Byte fd2;
735 FT_UInt first, limit; 742 FT_UInt first, limit;
736 743
737 744
738 first = FT_NEXT_USHORT( p ); 745 first = FT_NEXT_USHORT( p );
739 do 746 do
740 { 747 {
741 if ( glyph_index < first ) 748 if ( glyph_index < first )
742 break; 749 break;
743 750
744 fd2 = *p++; 751 fd2 = *p++;
745 limit = FT_NEXT_USHORT( p ); 752 limit = FT_NEXT_USHORT( p );
746 753
747 if ( glyph_index < limit ) 754 if ( glyph_index < limit )
748 { 755 {
749 fd = fd2; 756 fd = fd2;
750 757
751 /* update cache */ 758 /* update cache */
752 fdselect->cache_first = first; 759 fdselect->cache_first = first;
753 fdselect->cache_count = limit-first; 760 fdselect->cache_count = limit - first;
754 fdselect->cache_fd = fd2; 761 fdselect->cache_fd = fd2;
755 break; 762 break;
756 } 763 }
757 first = limit; 764 first = limit;
758 765
759 } while ( p < p_limit ); 766 } while ( p < p_limit );
760 } 767 }
761 break; 768 break;
762 769
763 default: 770 default:
(...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after
1687 1694
1688 if ( font->cf2_instance.finalizer ) 1695 if ( font->cf2_instance.finalizer )
1689 { 1696 {
1690 font->cf2_instance.finalizer( font->cf2_instance.data ); 1697 font->cf2_instance.finalizer( font->cf2_instance.data );
1691 FT_FREE( font->cf2_instance.data ); 1698 FT_FREE( font->cf2_instance.data );
1692 } 1699 }
1693 } 1700 }
1694 1701
1695 1702
1696 /* END */ 1703 /* END */
OLDNEW
« no previous file with comments | « third_party/freetype/src/cff/cffload.h ('k') | third_party/freetype/src/cff/cffobjs.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698