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

Side by Side Diff: src/sfnt/ttcmap.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/ttcmap.h ('k') | src/sfnt/ttcmapc.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 /* ttcmap.c */ 3 /* ttcmap.c */
4 /* */ 4 /* */
5 /* TrueType character mapping table (cmap) support (body). */ 5 /* TrueType character mapping table (cmap) support (body). */
6 /* */ 6 /* */
7 /* Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by */ 7 /* Copyright 2002-2010, 2012, 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 #define TT_NEXT_UINT24 FT_NEXT_UOFF3 49 #define TT_NEXT_UINT24 FT_NEXT_UOFF3
50 #define TT_NEXT_LONG FT_NEXT_LONG 50 #define TT_NEXT_LONG FT_NEXT_LONG
51 #define TT_NEXT_ULONG FT_NEXT_ULONG 51 #define TT_NEXT_ULONG FT_NEXT_ULONG
52 52
53 53
54 FT_CALLBACK_DEF( FT_Error ) 54 FT_CALLBACK_DEF( FT_Error )
55 tt_cmap_init( TT_CMap cmap, 55 tt_cmap_init( TT_CMap cmap,
56 FT_Byte* table ) 56 FT_Byte* table )
57 { 57 {
58 cmap->data = table; 58 cmap->data = table;
59 return SFNT_Err_Ok; 59 return FT_Err_Ok;
60 } 60 }
61 61
62 62
63 /*************************************************************************/ 63 /*************************************************************************/
64 /*************************************************************************/ 64 /*************************************************************************/
65 /***** *****/ 65 /***** *****/
66 /***** FORMAT 0 *****/ 66 /***** FORMAT 0 *****/
67 /***** *****/ 67 /***** *****/
68 /*************************************************************************/ 68 /*************************************************************************/
69 /*************************************************************************/ 69 /*************************************************************************/
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 103
104 p = table + 6; 104 p = table + 6;
105 for ( n = 0; n < 256; n++ ) 105 for ( n = 0; n < 256; n++ )
106 { 106 {
107 idx = *p++; 107 idx = *p++;
108 if ( idx >= TT_VALID_GLYPH_COUNT( valid ) ) 108 if ( idx >= TT_VALID_GLYPH_COUNT( valid ) )
109 FT_INVALID_GLYPH_ID; 109 FT_INVALID_GLYPH_ID;
110 } 110 }
111 } 111 }
112 112
113 return SFNT_Err_Ok; 113 return FT_Err_Ok;
114 } 114 }
115 115
116 116
117 FT_CALLBACK_DEF( FT_UInt ) 117 FT_CALLBACK_DEF( FT_UInt )
118 tt_cmap0_char_index( TT_CMap cmap, 118 tt_cmap0_char_index( TT_CMap cmap,
119 FT_UInt32 char_code ) 119 FT_UInt32 char_code )
120 { 120 {
121 FT_Byte* table = cmap->data; 121 FT_Byte* table = cmap->data;
122 122
123 123
(...skipping 30 matching lines...) Expand all
154 FT_CALLBACK_DEF( FT_Error ) 154 FT_CALLBACK_DEF( FT_Error )
155 tt_cmap0_get_info( TT_CMap cmap, 155 tt_cmap0_get_info( TT_CMap cmap,
156 TT_CMapInfo *cmap_info ) 156 TT_CMapInfo *cmap_info )
157 { 157 {
158 FT_Byte* p = cmap->data + 4; 158 FT_Byte* p = cmap->data + 4;
159 159
160 160
161 cmap_info->format = 0; 161 cmap_info->format = 0;
162 cmap_info->language = (FT_ULong)TT_PEEK_USHORT( p ); 162 cmap_info->language = (FT_ULong)TT_PEEK_USHORT( p );
163 163
164 return SFNT_Err_Ok; 164 return FT_Err_Ok;
165 } 165 }
166 166
167 167
168 FT_DEFINE_TT_CMAP(tt_cmap0_class_rec, 168 FT_DEFINE_TT_CMAP(
169 sizeof ( TT_CMapRec ), 169 tt_cmap0_class_rec,
170 sizeof ( TT_CMapRec ),
170 171
171 (FT_CMap_InitFunc) tt_cmap_init, 172 (FT_CMap_InitFunc) tt_cmap_init,
172 (FT_CMap_DoneFunc) NULL, 173 (FT_CMap_DoneFunc) NULL,
173 (FT_CMap_CharIndexFunc)tt_cmap0_char_index, 174 (FT_CMap_CharIndexFunc)tt_cmap0_char_index,
174 (FT_CMap_CharNextFunc) tt_cmap0_char_next, 175 (FT_CMap_CharNextFunc) tt_cmap0_char_next,
175 176
176 NULL, NULL, NULL, NULL, NULL 177 NULL,
177 , 178 NULL,
179 NULL,
180 NULL,
181 NULL,
182
178 0, 183 0,
179 (TT_CMap_ValidateFunc) tt_cmap0_validate, 184 (TT_CMap_ValidateFunc)tt_cmap0_validate,
180 (TT_CMap_Info_GetFunc) tt_cmap0_get_info 185 (TT_CMap_Info_GetFunc)tt_cmap0_get_info )
181 )
182 186
183 #endif /* TT_CONFIG_CMAP_FORMAT_0 */ 187 #endif /* TT_CONFIG_CMAP_FORMAT_0 */
184 188
185 189
186 /*************************************************************************/ 190 /*************************************************************************/
187 /*************************************************************************/ 191 /*************************************************************************/
188 /***** *****/ 192 /***** *****/
189 /***** FORMAT 2 *****/ 193 /***** FORMAT 2 *****/
190 /***** *****/ 194 /***** *****/
191 /***** This is used for certain CJK encodings that encode text in a *****/ 195 /***** This is used for certain CJK encodings that encode text in a *****/
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 { 362 {
359 idx = ( idx + delta ) & 0xFFFFU; 363 idx = ( idx + delta ) & 0xFFFFU;
360 if ( idx >= TT_VALID_GLYPH_COUNT( valid ) ) 364 if ( idx >= TT_VALID_GLYPH_COUNT( valid ) )
361 FT_INVALID_GLYPH_ID; 365 FT_INVALID_GLYPH_ID;
362 } 366 }
363 } 367 }
364 } 368 }
365 } 369 }
366 } 370 }
367 371
368 return SFNT_Err_Ok; 372 return FT_Err_Ok;
369 } 373 }
370 374
371 375
372 /* return sub header corresponding to a given character code */ 376 /* return sub header corresponding to a given character code */
373 /* NULL on invalid charcode */ 377 /* NULL on invalid charcode */
374 static FT_Byte* 378 static FT_Byte*
375 tt_cmap2_get_subheader( FT_Byte* table, 379 tt_cmap2_get_subheader( FT_Byte* table,
376 FT_UInt32 char_code ) 380 FT_UInt32 char_code )
377 { 381 {
378 FT_Byte* result = NULL; 382 FT_Byte* result = NULL;
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 FT_CALLBACK_DEF( FT_Error ) 534 FT_CALLBACK_DEF( FT_Error )
531 tt_cmap2_get_info( TT_CMap cmap, 535 tt_cmap2_get_info( TT_CMap cmap,
532 TT_CMapInfo *cmap_info ) 536 TT_CMapInfo *cmap_info )
533 { 537 {
534 FT_Byte* p = cmap->data + 4; 538 FT_Byte* p = cmap->data + 4;
535 539
536 540
537 cmap_info->format = 2; 541 cmap_info->format = 2;
538 cmap_info->language = (FT_ULong)TT_PEEK_USHORT( p ); 542 cmap_info->language = (FT_ULong)TT_PEEK_USHORT( p );
539 543
540 return SFNT_Err_Ok; 544 return FT_Err_Ok;
541 } 545 }
542 546
543 547
544 FT_DEFINE_TT_CMAP(tt_cmap2_class_rec, 548 FT_DEFINE_TT_CMAP(
545 sizeof ( TT_CMapRec ), 549 tt_cmap2_class_rec,
550 sizeof ( TT_CMapRec ),
546 551
547 (FT_CMap_InitFunc) tt_cmap_init, 552 (FT_CMap_InitFunc) tt_cmap_init,
548 (FT_CMap_DoneFunc) NULL, 553 (FT_CMap_DoneFunc) NULL,
549 (FT_CMap_CharIndexFunc)tt_cmap2_char_index, 554 (FT_CMap_CharIndexFunc)tt_cmap2_char_index,
550 (FT_CMap_CharNextFunc) tt_cmap2_char_next, 555 (FT_CMap_CharNextFunc) tt_cmap2_char_next,
551 556
552 NULL, NULL, NULL, NULL, NULL 557 NULL,
553 , 558 NULL,
559 NULL,
560 NULL,
561 NULL,
562
554 2, 563 2,
555 (TT_CMap_ValidateFunc) tt_cmap2_validate, 564 (TT_CMap_ValidateFunc)tt_cmap2_validate,
556 (TT_CMap_Info_GetFunc) tt_cmap2_get_info 565 (TT_CMap_Info_GetFunc)tt_cmap2_get_info )
557 )
558 566
559 #endif /* TT_CONFIG_CMAP_FORMAT_2 */ 567 #endif /* TT_CONFIG_CMAP_FORMAT_2 */
560 568
561 569
562 /*************************************************************************/ 570 /*************************************************************************/
563 /*************************************************************************/ 571 /*************************************************************************/
564 /***** *****/ 572 /***** *****/
565 /***** FORMAT 4 *****/ 573 /***** FORMAT 4 *****/
566 /***** *****/ 574 /***** *****/
567 /*************************************************************************/ 575 /*************************************************************************/
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 FT_Byte* p; 663 FT_Byte* p;
656 664
657 665
658 cmap->cmap.data = table; 666 cmap->cmap.data = table;
659 667
660 p = table + 6; 668 p = table + 6;
661 cmap->num_ranges = FT_PEEK_USHORT( p ) >> 1; 669 cmap->num_ranges = FT_PEEK_USHORT( p ) >> 1;
662 cmap->cur_charcode = (FT_UInt32)0xFFFFFFFFUL; 670 cmap->cur_charcode = (FT_UInt32)0xFFFFFFFFUL;
663 cmap->cur_gindex = 0; 671 cmap->cur_gindex = 0;
664 672
665 return SFNT_Err_Ok; 673 return FT_Err_Ok;
666 } 674 }
667 675
668 676
669 static FT_Int 677 static FT_Int
670 tt_cmap4_set_range( TT_CMap4 cmap, 678 tt_cmap4_set_range( TT_CMap4 cmap,
671 FT_UInt range_index ) 679 FT_UInt range_index )
672 { 680 {
673 FT_Byte* table = cmap->cmap.data; 681 FT_Byte* table = cmap->cmap.data;
674 FT_Byte* p; 682 FT_Byte* p;
675 FT_UInt num_ranges = cmap->num_ranges; 683 FT_UInt num_ranges = cmap->num_ranges;
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 813
806 814
807 FT_CALLBACK_DEF( FT_Error ) 815 FT_CALLBACK_DEF( FT_Error )
808 tt_cmap4_validate( FT_Byte* table, 816 tt_cmap4_validate( FT_Byte* table,
809 FT_Validator valid ) 817 FT_Validator valid )
810 { 818 {
811 FT_Byte* p = table + 2; /* skip format */ 819 FT_Byte* p = table + 2; /* skip format */
812 FT_UInt length = TT_NEXT_USHORT( p ); 820 FT_UInt length = TT_NEXT_USHORT( p );
813 FT_Byte *ends, *starts, *offsets, *deltas, *glyph_ids; 821 FT_Byte *ends, *starts, *offsets, *deltas, *glyph_ids;
814 FT_UInt num_segs; 822 FT_UInt num_segs;
815 FT_Error error = SFNT_Err_Ok; 823 FT_Error error = FT_Err_Ok;
816 824
817 825
818 if ( length < 16 ) 826 if ( length < 16 )
819 FT_INVALID_TOO_SHORT; 827 FT_INVALID_TOO_SHORT;
820 828
821 /* in certain fonts, the `length' field is invalid and goes */ 829 /* in certain fonts, the `length' field is invalid and goes */
822 /* out of bound. We try to correct this here... */ 830 /* out of bound. We try to correct this here... */
823 if ( table + length > valid->limit ) 831 if ( table + length > valid->limit )
824 { 832 {
825 if ( valid->level >= FT_VALIDATE_TIGHT ) 833 if ( valid->level >= FT_VALIDATE_TIGHT )
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
1366 FT_CALLBACK_DEF( FT_Error ) 1374 FT_CALLBACK_DEF( FT_Error )
1367 tt_cmap4_get_info( TT_CMap cmap, 1375 tt_cmap4_get_info( TT_CMap cmap,
1368 TT_CMapInfo *cmap_info ) 1376 TT_CMapInfo *cmap_info )
1369 { 1377 {
1370 FT_Byte* p = cmap->data + 4; 1378 FT_Byte* p = cmap->data + 4;
1371 1379
1372 1380
1373 cmap_info->format = 4; 1381 cmap_info->format = 4;
1374 cmap_info->language = (FT_ULong)TT_PEEK_USHORT( p ); 1382 cmap_info->language = (FT_ULong)TT_PEEK_USHORT( p );
1375 1383
1376 return SFNT_Err_Ok; 1384 return FT_Err_Ok;
1377 } 1385 }
1378 1386
1379 1387
1380 FT_DEFINE_TT_CMAP(tt_cmap4_class_rec, 1388 FT_DEFINE_TT_CMAP(
1381 sizeof ( TT_CMap4Rec ), 1389 tt_cmap4_class_rec,
1382 (FT_CMap_InitFunc) tt_cmap4_init, 1390 sizeof ( TT_CMap4Rec ),
1383 (FT_CMap_DoneFunc) NULL, 1391 (FT_CMap_InitFunc) tt_cmap4_init,
1384 (FT_CMap_CharIndexFunc)tt_cmap4_char_index, 1392 (FT_CMap_DoneFunc) NULL,
1385 (FT_CMap_CharNextFunc) tt_cmap4_char_next, 1393 (FT_CMap_CharIndexFunc)tt_cmap4_char_index,
1394 (FT_CMap_CharNextFunc) tt_cmap4_char_next,
1386 1395
1387 NULL, NULL, NULL, NULL, NULL 1396 NULL,
1388 , 1397 NULL,
1398 NULL,
1399 NULL,
1400 NULL,
1401
1389 4, 1402 4,
1390 (TT_CMap_ValidateFunc) tt_cmap4_validate, 1403 (TT_CMap_ValidateFunc)tt_cmap4_validate,
1391 (TT_CMap_Info_GetFunc) tt_cmap4_get_info 1404 (TT_CMap_Info_GetFunc)tt_cmap4_get_info )
1392 )
1393 1405
1394 #endif /* TT_CONFIG_CMAP_FORMAT_4 */ 1406 #endif /* TT_CONFIG_CMAP_FORMAT_4 */
1395 1407
1396 1408
1397 /*************************************************************************/ 1409 /*************************************************************************/
1398 /*************************************************************************/ 1410 /*************************************************************************/
1399 /***** *****/ 1411 /***** *****/
1400 /***** FORMAT 6 *****/ 1412 /***** FORMAT 6 *****/
1401 /***** *****/ 1413 /***** *****/
1402 /*************************************************************************/ 1414 /*************************************************************************/
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1449 1461
1450 1462
1451 for ( ; count > 0; count-- ) 1463 for ( ; count > 0; count-- )
1452 { 1464 {
1453 gindex = TT_NEXT_USHORT( p ); 1465 gindex = TT_NEXT_USHORT( p );
1454 if ( gindex >= TT_VALID_GLYPH_COUNT( valid ) ) 1466 if ( gindex >= TT_VALID_GLYPH_COUNT( valid ) )
1455 FT_INVALID_GLYPH_ID; 1467 FT_INVALID_GLYPH_ID;
1456 } 1468 }
1457 } 1469 }
1458 1470
1459 return SFNT_Err_Ok; 1471 return FT_Err_Ok;
1460 } 1472 }
1461 1473
1462 1474
1463 FT_CALLBACK_DEF( FT_UInt ) 1475 FT_CALLBACK_DEF( FT_UInt )
1464 tt_cmap6_char_index( TT_CMap cmap, 1476 tt_cmap6_char_index( TT_CMap cmap,
1465 FT_UInt32 char_code ) 1477 FT_UInt32 char_code )
1466 { 1478 {
1467 FT_Byte* table = cmap->data; 1479 FT_Byte* table = cmap->data;
1468 FT_UInt result = 0; 1480 FT_UInt result = 0;
1469 FT_Byte* p = table + 6; 1481 FT_Byte* p = table + 6;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1525 FT_CALLBACK_DEF( FT_Error ) 1537 FT_CALLBACK_DEF( FT_Error )
1526 tt_cmap6_get_info( TT_CMap cmap, 1538 tt_cmap6_get_info( TT_CMap cmap,
1527 TT_CMapInfo *cmap_info ) 1539 TT_CMapInfo *cmap_info )
1528 { 1540 {
1529 FT_Byte* p = cmap->data + 4; 1541 FT_Byte* p = cmap->data + 4;
1530 1542
1531 1543
1532 cmap_info->format = 6; 1544 cmap_info->format = 6;
1533 cmap_info->language = (FT_ULong)TT_PEEK_USHORT( p ); 1545 cmap_info->language = (FT_ULong)TT_PEEK_USHORT( p );
1534 1546
1535 return SFNT_Err_Ok; 1547 return FT_Err_Ok;
1536 } 1548 }
1537 1549
1538 1550
1539 FT_DEFINE_TT_CMAP(tt_cmap6_class_rec, 1551 FT_DEFINE_TT_CMAP(
1540 sizeof ( TT_CMapRec ), 1552 tt_cmap6_class_rec,
1553 sizeof ( TT_CMapRec ),
1541 1554
1542 (FT_CMap_InitFunc) tt_cmap_init, 1555 (FT_CMap_InitFunc) tt_cmap_init,
1543 (FT_CMap_DoneFunc) NULL, 1556 (FT_CMap_DoneFunc) NULL,
1544 (FT_CMap_CharIndexFunc)tt_cmap6_char_index, 1557 (FT_CMap_CharIndexFunc)tt_cmap6_char_index,
1545 (FT_CMap_CharNextFunc) tt_cmap6_char_next, 1558 (FT_CMap_CharNextFunc) tt_cmap6_char_next,
1546 1559
1547 NULL, NULL, NULL, NULL, NULL 1560 NULL,
1548 , 1561 NULL,
1562 NULL,
1563 NULL,
1564 NULL,
1565
1549 6, 1566 6,
1550 (TT_CMap_ValidateFunc) tt_cmap6_validate, 1567 (TT_CMap_ValidateFunc)tt_cmap6_validate,
1551 (TT_CMap_Info_GetFunc) tt_cmap6_get_info 1568 (TT_CMap_Info_GetFunc)tt_cmap6_get_info )
1552 )
1553 1569
1554 #endif /* TT_CONFIG_CMAP_FORMAT_6 */ 1570 #endif /* TT_CONFIG_CMAP_FORMAT_6 */
1555 1571
1556 1572
1557 /*************************************************************************/ 1573 /*************************************************************************/
1558 /*************************************************************************/ 1574 /*************************************************************************/
1559 /***** *****/ 1575 /***** *****/
1560 /***** FORMAT 8 *****/ 1576 /***** FORMAT 8 *****/
1561 /***** *****/ 1577 /***** *****/
1562 /***** It is hard to completely understand what the OpenType spec *****/ 1578 /***** It is hard to completely understand what the OpenType spec *****/
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
1693 if ( (is32[lo >> 3] & ( 0x80 >> ( lo & 7 ) ) ) != 0 ) 1709 if ( (is32[lo >> 3] & ( 0x80 >> ( lo & 7 ) ) ) != 0 )
1694 FT_INVALID_DATA; 1710 FT_INVALID_DATA;
1695 } 1711 }
1696 } 1712 }
1697 } 1713 }
1698 1714
1699 last = end; 1715 last = end;
1700 } 1716 }
1701 } 1717 }
1702 1718
1703 return SFNT_Err_Ok; 1719 return FT_Err_Ok;
1704 } 1720 }
1705 1721
1706 1722
1707 FT_CALLBACK_DEF( FT_UInt ) 1723 FT_CALLBACK_DEF( FT_UInt )
1708 tt_cmap8_char_index( TT_CMap cmap, 1724 tt_cmap8_char_index( TT_CMap cmap,
1709 FT_UInt32 char_code ) 1725 FT_UInt32 char_code )
1710 { 1726 {
1711 FT_Byte* table = cmap->data; 1727 FT_Byte* table = cmap->data;
1712 FT_UInt result = 0; 1728 FT_UInt result = 0;
1713 FT_Byte* p = table + 8204; 1729 FT_Byte* p = table + 8204;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1778 FT_CALLBACK_DEF( FT_Error ) 1794 FT_CALLBACK_DEF( FT_Error )
1779 tt_cmap8_get_info( TT_CMap cmap, 1795 tt_cmap8_get_info( TT_CMap cmap,
1780 TT_CMapInfo *cmap_info ) 1796 TT_CMapInfo *cmap_info )
1781 { 1797 {
1782 FT_Byte* p = cmap->data + 8; 1798 FT_Byte* p = cmap->data + 8;
1783 1799
1784 1800
1785 cmap_info->format = 8; 1801 cmap_info->format = 8;
1786 cmap_info->language = (FT_ULong)TT_PEEK_ULONG( p ); 1802 cmap_info->language = (FT_ULong)TT_PEEK_ULONG( p );
1787 1803
1788 return SFNT_Err_Ok; 1804 return FT_Err_Ok;
1789 } 1805 }
1790 1806
1791 1807
1792 FT_DEFINE_TT_CMAP(tt_cmap8_class_rec, 1808 FT_DEFINE_TT_CMAP(
1793 sizeof ( TT_CMapRec ), 1809 tt_cmap8_class_rec,
1810 sizeof ( TT_CMapRec ),
1794 1811
1795 (FT_CMap_InitFunc) tt_cmap_init, 1812 (FT_CMap_InitFunc) tt_cmap_init,
1796 (FT_CMap_DoneFunc) NULL, 1813 (FT_CMap_DoneFunc) NULL,
1797 (FT_CMap_CharIndexFunc)tt_cmap8_char_index, 1814 (FT_CMap_CharIndexFunc)tt_cmap8_char_index,
1798 (FT_CMap_CharNextFunc) tt_cmap8_char_next, 1815 (FT_CMap_CharNextFunc) tt_cmap8_char_next,
1799 1816
1800 NULL, NULL, NULL, NULL, NULL 1817 NULL,
1801 , 1818 NULL,
1819 NULL,
1820 NULL,
1821 NULL,
1822
1802 8, 1823 8,
1803 (TT_CMap_ValidateFunc) tt_cmap8_validate, 1824 (TT_CMap_ValidateFunc)tt_cmap8_validate,
1804 (TT_CMap_Info_GetFunc) tt_cmap8_get_info 1825 (TT_CMap_Info_GetFunc)tt_cmap8_get_info )
1805 )
1806 1826
1807 #endif /* TT_CONFIG_CMAP_FORMAT_8 */ 1827 #endif /* TT_CONFIG_CMAP_FORMAT_8 */
1808 1828
1809 1829
1810 /*************************************************************************/ 1830 /*************************************************************************/
1811 /*************************************************************************/ 1831 /*************************************************************************/
1812 /***** *****/ 1832 /***** *****/
1813 /***** FORMAT 10 *****/ 1833 /***** FORMAT 10 *****/
1814 /***** *****/ 1834 /***** *****/
1815 /*************************************************************************/ 1835 /*************************************************************************/
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1860 1880
1861 1881
1862 for ( ; count > 0; count-- ) 1882 for ( ; count > 0; count-- )
1863 { 1883 {
1864 gindex = TT_NEXT_USHORT( p ); 1884 gindex = TT_NEXT_USHORT( p );
1865 if ( gindex >= TT_VALID_GLYPH_COUNT( valid ) ) 1885 if ( gindex >= TT_VALID_GLYPH_COUNT( valid ) )
1866 FT_INVALID_GLYPH_ID; 1886 FT_INVALID_GLYPH_ID;
1867 } 1887 }
1868 } 1888 }
1869 1889
1870 return SFNT_Err_Ok; 1890 return FT_Err_Ok;
1871 } 1891 }
1872 1892
1873 1893
1874 FT_CALLBACK_DEF( FT_UInt ) 1894 FT_CALLBACK_DEF( FT_UInt )
1875 tt_cmap10_char_index( TT_CMap cmap, 1895 tt_cmap10_char_index( TT_CMap cmap,
1876 FT_UInt32 char_code ) 1896 FT_UInt32 char_code )
1877 { 1897 {
1878 FT_Byte* table = cmap->data; 1898 FT_Byte* table = cmap->data;
1879 FT_UInt result = 0; 1899 FT_UInt result = 0;
1880 FT_Byte* p = table + 12; 1900 FT_Byte* p = table + 12;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1927 FT_CALLBACK_DEF( FT_Error ) 1947 FT_CALLBACK_DEF( FT_Error )
1928 tt_cmap10_get_info( TT_CMap cmap, 1948 tt_cmap10_get_info( TT_CMap cmap,
1929 TT_CMapInfo *cmap_info ) 1949 TT_CMapInfo *cmap_info )
1930 { 1950 {
1931 FT_Byte* p = cmap->data + 8; 1951 FT_Byte* p = cmap->data + 8;
1932 1952
1933 1953
1934 cmap_info->format = 10; 1954 cmap_info->format = 10;
1935 cmap_info->language = (FT_ULong)TT_PEEK_ULONG( p ); 1955 cmap_info->language = (FT_ULong)TT_PEEK_ULONG( p );
1936 1956
1937 return SFNT_Err_Ok; 1957 return FT_Err_Ok;
1938 } 1958 }
1939 1959
1940 1960
1941 FT_DEFINE_TT_CMAP(tt_cmap10_class_rec, 1961 FT_DEFINE_TT_CMAP(
1942 sizeof ( TT_CMapRec ), 1962 tt_cmap10_class_rec,
1963 sizeof ( TT_CMapRec ),
1943 1964
1944 (FT_CMap_InitFunc) tt_cmap_init, 1965 (FT_CMap_InitFunc) tt_cmap_init,
1945 (FT_CMap_DoneFunc) NULL, 1966 (FT_CMap_DoneFunc) NULL,
1946 (FT_CMap_CharIndexFunc)tt_cmap10_char_index, 1967 (FT_CMap_CharIndexFunc)tt_cmap10_char_index,
1947 (FT_CMap_CharNextFunc) tt_cmap10_char_next, 1968 (FT_CMap_CharNextFunc) tt_cmap10_char_next,
1948 1969
1949 NULL, NULL, NULL, NULL, NULL 1970 NULL,
1950 , 1971 NULL,
1972 NULL,
1973 NULL,
1974 NULL,
1975
1951 10, 1976 10,
1952 (TT_CMap_ValidateFunc) tt_cmap10_validate, 1977 (TT_CMap_ValidateFunc)tt_cmap10_validate,
1953 (TT_CMap_Info_GetFunc) tt_cmap10_get_info 1978 (TT_CMap_Info_GetFunc)tt_cmap10_get_info )
1954 )
1955 1979
1956 #endif /* TT_CONFIG_CMAP_FORMAT_10 */ 1980 #endif /* TT_CONFIG_CMAP_FORMAT_10 */
1957 1981
1958 1982
1959 /*************************************************************************/ 1983 /*************************************************************************/
1960 /*************************************************************************/ 1984 /*************************************************************************/
1961 /***** *****/ 1985 /***** *****/
1962 /***** FORMAT 12 *****/ 1986 /***** FORMAT 12 *****/
1963 /***** *****/ 1987 /***** *****/
1964 /*************************************************************************/ 1988 /*************************************************************************/
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2003 tt_cmap12_init( TT_CMap12 cmap, 2027 tt_cmap12_init( TT_CMap12 cmap,
2004 FT_Byte* table ) 2028 FT_Byte* table )
2005 { 2029 {
2006 cmap->cmap.data = table; 2030 cmap->cmap.data = table;
2007 2031
2008 table += 12; 2032 table += 12;
2009 cmap->num_groups = FT_PEEK_ULONG( table ); 2033 cmap->num_groups = FT_PEEK_ULONG( table );
2010 2034
2011 cmap->valid = 0; 2035 cmap->valid = 0;
2012 2036
2013 return SFNT_Err_Ok; 2037 return FT_Err_Ok;
2014 } 2038 }
2015 2039
2016 2040
2017 FT_CALLBACK_DEF( FT_Error ) 2041 FT_CALLBACK_DEF( FT_Error )
2018 tt_cmap12_validate( FT_Byte* table, 2042 tt_cmap12_validate( FT_Byte* table,
2019 FT_Validator valid ) 2043 FT_Validator valid )
2020 { 2044 {
2021 FT_Byte* p; 2045 FT_Byte* p;
2022 FT_ULong length; 2046 FT_ULong length;
2023 FT_ULong num_groups; 2047 FT_ULong num_groups;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2056 if ( valid->level >= FT_VALIDATE_TIGHT ) 2080 if ( valid->level >= FT_VALIDATE_TIGHT )
2057 { 2081 {
2058 if ( start_id + end - start >= TT_VALID_GLYPH_COUNT( valid ) ) 2082 if ( start_id + end - start >= TT_VALID_GLYPH_COUNT( valid ) )
2059 FT_INVALID_GLYPH_ID; 2083 FT_INVALID_GLYPH_ID;
2060 } 2084 }
2061 2085
2062 last = end; 2086 last = end;
2063 } 2087 }
2064 } 2088 }
2065 2089
2066 return SFNT_Err_Ok; 2090 return FT_Err_Ok;
2067 } 2091 }
2068 2092
2069 2093
2070 /* search the index of the charcode next to cmap->cur_charcode */ 2094 /* search the index of the charcode next to cmap->cur_charcode */
2071 /* cmap->cur_group should be set up properly by caller */ 2095 /* cmap->cur_group should be set up properly by caller */
2072 /* */ 2096 /* */
2073 static void 2097 static void
2074 tt_cmap12_next( TT_CMap12 cmap ) 2098 tt_cmap12_next( TT_CMap12 cmap )
2075 { 2099 {
2076 FT_Byte* p; 2100 FT_Byte* p;
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
2247 FT_CALLBACK_DEF( FT_Error ) 2271 FT_CALLBACK_DEF( FT_Error )
2248 tt_cmap12_get_info( TT_CMap cmap, 2272 tt_cmap12_get_info( TT_CMap cmap,
2249 TT_CMapInfo *cmap_info ) 2273 TT_CMapInfo *cmap_info )
2250 { 2274 {
2251 FT_Byte* p = cmap->data + 8; 2275 FT_Byte* p = cmap->data + 8;
2252 2276
2253 2277
2254 cmap_info->format = 12; 2278 cmap_info->format = 12;
2255 cmap_info->language = (FT_ULong)TT_PEEK_ULONG( p ); 2279 cmap_info->language = (FT_ULong)TT_PEEK_ULONG( p );
2256 2280
2257 return SFNT_Err_Ok; 2281 return FT_Err_Ok;
2258 } 2282 }
2259 2283
2260 2284
2261 FT_DEFINE_TT_CMAP(tt_cmap12_class_rec, 2285 FT_DEFINE_TT_CMAP(
2262 sizeof ( TT_CMap12Rec ), 2286 tt_cmap12_class_rec,
2287 sizeof ( TT_CMap12Rec ),
2263 2288
2264 (FT_CMap_InitFunc) tt_cmap12_init, 2289 (FT_CMap_InitFunc) tt_cmap12_init,
2265 (FT_CMap_DoneFunc) NULL, 2290 (FT_CMap_DoneFunc) NULL,
2266 (FT_CMap_CharIndexFunc)tt_cmap12_char_index, 2291 (FT_CMap_CharIndexFunc)tt_cmap12_char_index,
2267 (FT_CMap_CharNextFunc) tt_cmap12_char_next, 2292 (FT_CMap_CharNextFunc) tt_cmap12_char_next,
2268 2293
2269 NULL, NULL, NULL, NULL, NULL 2294 NULL,
2270 , 2295 NULL,
2296 NULL,
2297 NULL,
2298 NULL,
2299
2271 12, 2300 12,
2272 (TT_CMap_ValidateFunc) tt_cmap12_validate, 2301 (TT_CMap_ValidateFunc)tt_cmap12_validate,
2273 (TT_CMap_Info_GetFunc) tt_cmap12_get_info 2302 (TT_CMap_Info_GetFunc)tt_cmap12_get_info )
2274 )
2275 2303
2276 #endif /* TT_CONFIG_CMAP_FORMAT_12 */ 2304 #endif /* TT_CONFIG_CMAP_FORMAT_12 */
2277 2305
2278 2306
2279 /*************************************************************************/ 2307 /*************************************************************************/
2280 /*************************************************************************/ 2308 /*************************************************************************/
2281 /***** *****/ 2309 /***** *****/
2282 /***** FORMAT 13 *****/ 2310 /***** FORMAT 13 *****/
2283 /***** *****/ 2311 /***** *****/
2284 /*************************************************************************/ 2312 /*************************************************************************/
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2323 tt_cmap13_init( TT_CMap13 cmap, 2351 tt_cmap13_init( TT_CMap13 cmap,
2324 FT_Byte* table ) 2352 FT_Byte* table )
2325 { 2353 {
2326 cmap->cmap.data = table; 2354 cmap->cmap.data = table;
2327 2355
2328 table += 12; 2356 table += 12;
2329 cmap->num_groups = FT_PEEK_ULONG( table ); 2357 cmap->num_groups = FT_PEEK_ULONG( table );
2330 2358
2331 cmap->valid = 0; 2359 cmap->valid = 0;
2332 2360
2333 return SFNT_Err_Ok; 2361 return FT_Err_Ok;
2334 } 2362 }
2335 2363
2336 2364
2337 FT_CALLBACK_DEF( FT_Error ) 2365 FT_CALLBACK_DEF( FT_Error )
2338 tt_cmap13_validate( FT_Byte* table, 2366 tt_cmap13_validate( FT_Byte* table,
2339 FT_Validator valid ) 2367 FT_Validator valid )
2340 { 2368 {
2341 FT_Byte* p; 2369 FT_Byte* p;
2342 FT_ULong length; 2370 FT_ULong length;
2343 FT_ULong num_groups; 2371 FT_ULong num_groups;
2344 2372
2345 2373
2346 if ( table + 16 > valid->limit ) 2374 if ( table + 16 > valid->limit )
2347 FT_INVALID_TOO_SHORT; 2375 FT_INVALID_TOO_SHORT;
2348 2376
2349 p = table + 4; 2377 p = table + 4;
2350 length = TT_NEXT_ULONG( p ); 2378 length = TT_NEXT_ULONG( p );
2351 2379
2352 p = table + 12; 2380 p = table + 12;
2353 num_groups = TT_NEXT_ULONG( p ); 2381 num_groups = TT_NEXT_ULONG( p );
(...skipping 22 matching lines...) Expand all
2376 if ( valid->level >= FT_VALIDATE_TIGHT ) 2404 if ( valid->level >= FT_VALIDATE_TIGHT )
2377 { 2405 {
2378 if ( glyph_id >= TT_VALID_GLYPH_COUNT( valid ) ) 2406 if ( glyph_id >= TT_VALID_GLYPH_COUNT( valid ) )
2379 FT_INVALID_GLYPH_ID; 2407 FT_INVALID_GLYPH_ID;
2380 } 2408 }
2381 2409
2382 last = end; 2410 last = end;
2383 } 2411 }
2384 } 2412 }
2385 2413
2386 return SFNT_Err_Ok; 2414 return FT_Err_Ok;
2387 } 2415 }
2388 2416
2389 2417
2390 /* search the index of the charcode next to cmap->cur_charcode */ 2418 /* search the index of the charcode next to cmap->cur_charcode */
2391 /* cmap->cur_group should be set up properly by caller */ 2419 /* cmap->cur_group should be set up properly by caller */
2392 /* */ 2420 /* */
2393 static void 2421 static void
2394 tt_cmap13_next( TT_CMap13 cmap ) 2422 tt_cmap13_next( TT_CMap13 cmap )
2395 { 2423 {
2396 FT_Byte* p; 2424 FT_Byte* p;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
2483 } 2511 }
2484 } 2512 }
2485 2513
2486 if ( next ) 2514 if ( next )
2487 { 2515 {
2488 TT_CMap13 cmap13 = (TT_CMap13)cmap; 2516 TT_CMap13 cmap13 = (TT_CMap13)cmap;
2489 2517
2490 2518
2491 /* if `char_code' is not in any group, then `mid' is */ 2519 /* if `char_code' is not in any group, then `mid' is */
2492 /* the group nearest to `char_code' */ 2520 /* the group nearest to `char_code' */
2493 /* */
2494 2521
2495 if ( char_code > end ) 2522 if ( char_code > end )
2496 { 2523 {
2497 mid++; 2524 mid++;
2498 if ( mid == num_groups ) 2525 if ( mid == num_groups )
2499 return 0; 2526 return 0;
2500 } 2527 }
2501 2528
2502 cmap13->valid = 1; 2529 cmap13->valid = 1;
2503 cmap13->cur_charcode = char_code; 2530 cmap13->cur_charcode = char_code;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
2563 FT_CALLBACK_DEF( FT_Error ) 2590 FT_CALLBACK_DEF( FT_Error )
2564 tt_cmap13_get_info( TT_CMap cmap, 2591 tt_cmap13_get_info( TT_CMap cmap,
2565 TT_CMapInfo *cmap_info ) 2592 TT_CMapInfo *cmap_info )
2566 { 2593 {
2567 FT_Byte* p = cmap->data + 8; 2594 FT_Byte* p = cmap->data + 8;
2568 2595
2569 2596
2570 cmap_info->format = 13; 2597 cmap_info->format = 13;
2571 cmap_info->language = (FT_ULong)TT_PEEK_ULONG( p ); 2598 cmap_info->language = (FT_ULong)TT_PEEK_ULONG( p );
2572 2599
2573 return SFNT_Err_Ok; 2600 return FT_Err_Ok;
2574 } 2601 }
2575 2602
2576 2603
2577 FT_DEFINE_TT_CMAP(tt_cmap13_class_rec, 2604 FT_DEFINE_TT_CMAP(
2578 sizeof ( TT_CMap13Rec ), 2605 tt_cmap13_class_rec,
2606 sizeof ( TT_CMap13Rec ),
2579 2607
2580 (FT_CMap_InitFunc) tt_cmap13_init, 2608 (FT_CMap_InitFunc) tt_cmap13_init,
2581 (FT_CMap_DoneFunc) NULL, 2609 (FT_CMap_DoneFunc) NULL,
2582 (FT_CMap_CharIndexFunc)tt_cmap13_char_index, 2610 (FT_CMap_CharIndexFunc)tt_cmap13_char_index,
2583 (FT_CMap_CharNextFunc) tt_cmap13_char_next, 2611 (FT_CMap_CharNextFunc) tt_cmap13_char_next,
2584 2612
2585 NULL, NULL, NULL, NULL, NULL 2613 NULL,
2586 , 2614 NULL,
2615 NULL,
2616 NULL,
2617 NULL,
2618
2587 13, 2619 13,
2588 (TT_CMap_ValidateFunc) tt_cmap13_validate, 2620 (TT_CMap_ValidateFunc)tt_cmap13_validate,
2589 (TT_CMap_Info_GetFunc) tt_cmap13_get_info 2621 (TT_CMap_Info_GetFunc)tt_cmap13_get_info )
2590 )
2591 2622
2592 #endif /* TT_CONFIG_CMAP_FORMAT_13 */ 2623 #endif /* TT_CONFIG_CMAP_FORMAT_13 */
2593 2624
2594 2625
2595 /*************************************************************************/ 2626 /*************************************************************************/
2596 /*************************************************************************/ 2627 /*************************************************************************/
2597 /***** *****/ 2628 /***** *****/
2598 /***** FORMAT 14 *****/ 2629 /***** FORMAT 14 *****/
2599 /***** *****/ 2630 /***** *****/
2600 /*************************************************************************/ 2631 /*************************************************************************/
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
2681 if ( memory != NULL && cmap->results != NULL ) 2712 if ( memory != NULL && cmap->results != NULL )
2682 FT_FREE( cmap->results ); 2713 FT_FREE( cmap->results );
2683 } 2714 }
2684 2715
2685 2716
2686 static FT_Error 2717 static FT_Error
2687 tt_cmap14_ensure( TT_CMap14 cmap, 2718 tt_cmap14_ensure( TT_CMap14 cmap,
2688 FT_UInt32 num_results, 2719 FT_UInt32 num_results,
2689 FT_Memory memory ) 2720 FT_Memory memory )
2690 { 2721 {
2691 FT_UInt32 old_max = cmap->max_results; 2722 FT_UInt32 old_max = cmap->max_results;
2692 FT_Error error = SFNT_Err_Ok; 2723 FT_Error error = FT_Err_Ok;
2693 2724
2694 2725
2695 if ( num_results > cmap->max_results ) 2726 if ( num_results > cmap->max_results )
2696 { 2727 {
2697 cmap->memory = memory; 2728 cmap->memory = memory;
2698 2729
2699 if ( FT_QRENEW_ARRAY( cmap->results, old_max, num_results ) ) 2730 if ( FT_QRENEW_ARRAY( cmap->results, old_max, num_results ) )
2700 return error; 2731 return error;
2701 2732
2702 cmap->max_results = num_results; 2733 cmap->max_results = num_results;
2703 } 2734 }
2704 2735
2705 return error; 2736 return error;
2706 } 2737 }
2707 2738
2708 2739
2709 FT_CALLBACK_DEF( FT_Error ) 2740 FT_CALLBACK_DEF( FT_Error )
2710 tt_cmap14_init( TT_CMap14 cmap, 2741 tt_cmap14_init( TT_CMap14 cmap,
2711 FT_Byte* table ) 2742 FT_Byte* table )
2712 { 2743 {
2713 cmap->cmap.data = table; 2744 cmap->cmap.data = table;
2714 2745
2715 table += 6; 2746 table += 6;
2716 cmap->num_selectors = FT_PEEK_ULONG( table ); 2747 cmap->num_selectors = FT_PEEK_ULONG( table );
2717 cmap->max_results = 0; 2748 cmap->max_results = 0;
2718 cmap->results = NULL; 2749 cmap->results = NULL;
2719 2750
2720 return SFNT_Err_Ok; 2751 return FT_Err_Ok;
2721 } 2752 }
2722 2753
2723 2754
2724 FT_CALLBACK_DEF( FT_Error ) 2755 FT_CALLBACK_DEF( FT_Error )
2725 tt_cmap14_validate( FT_Byte* table, 2756 tt_cmap14_validate( FT_Byte* table,
2726 FT_Validator valid ) 2757 FT_Validator valid )
2727 { 2758 {
2728 FT_Byte* p = table + 2; 2759 FT_Byte* p = table + 2;
2729 FT_ULong length = TT_NEXT_ULONG( p ); 2760 FT_ULong length = TT_NEXT_ULONG( p );
2730 FT_ULong num_selectors = TT_NEXT_ULONG( p ); 2761 FT_ULong num_selectors = TT_NEXT_ULONG( p );
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
2784 2815
2785 lastBase = base + cnt + 1U; 2816 lastBase = base + cnt + 1U;
2786 } 2817 }
2787 } 2818 }
2788 2819
2789 /* and the non-default table (these glyphs are specified here) */ 2820 /* and the non-default table (these glyphs are specified here) */
2790 if ( nondefOff != 0 ) 2821 if ( nondefOff != 0 )
2791 { 2822 {
2792 FT_Byte* ndp = table + nondefOff; 2823 FT_Byte* ndp = table + nondefOff;
2793 FT_ULong numMappings = TT_NEXT_ULONG( ndp ); 2824 FT_ULong numMappings = TT_NEXT_ULONG( ndp );
2794 FT_ULong i, lastUni = 0; 2825 FT_ULong i, lastUni = 0;
2795 2826
2796 2827
2797 if ( numMappings * 4 > (FT_ULong)( valid->limit - ndp ) ) 2828 if ( numMappings * 4 > (FT_ULong)( valid->limit - ndp ) )
2798 FT_INVALID_TOO_SHORT; 2829 FT_INVALID_TOO_SHORT;
2799 2830
2800 for ( i = 0; i < numMappings; ++i ) 2831 for ( i = 0; i < numMappings; ++i )
2801 { 2832 {
2802 FT_ULong uni = TT_NEXT_UINT24( ndp ); 2833 FT_ULong uni = TT_NEXT_UINT24( ndp );
2803 FT_ULong gid = TT_NEXT_USHORT( ndp ); 2834 FT_ULong gid = TT_NEXT_USHORT( ndp );
2804 2835
2805 2836
2806 if ( uni >= 0x110000UL ) /* end of Unicode */ 2837 if ( uni >= 0x110000UL ) /* end of Unicode */
2807 FT_INVALID_DATA; 2838 FT_INVALID_DATA;
2808 2839
2809 if ( uni < lastUni ) 2840 if ( uni < lastUni )
2810 FT_INVALID_DATA; 2841 FT_INVALID_DATA;
2811 2842
2812 lastUni = uni + 1U; 2843 lastUni = uni + 1U;
2813 2844
2814 if ( valid->level >= FT_VALIDATE_TIGHT && 2845 if ( valid->level >= FT_VALIDATE_TIGHT &&
2815 gid >= TT_VALID_GLYPH_COUNT( valid ) ) 2846 gid >= TT_VALID_GLYPH_COUNT( valid ) )
2816 FT_INVALID_GLYPH_ID; 2847 FT_INVALID_GLYPH_ID;
2817 } 2848 }
2818 } 2849 }
2819 } 2850 }
2820 } 2851 }
2821 2852
2822 return SFNT_Err_Ok; 2853 return FT_Err_Ok;
2823 } 2854 }
2824 2855
2825 2856
2826 FT_CALLBACK_DEF( FT_UInt ) 2857 FT_CALLBACK_DEF( FT_UInt )
2827 tt_cmap14_char_index( TT_CMap cmap, 2858 tt_cmap14_char_index( TT_CMap cmap,
2828 FT_UInt32 char_code ) 2859 FT_UInt32 char_code )
2829 { 2860 {
2830 FT_UNUSED( cmap ); 2861 FT_UNUSED( cmap );
2831 FT_UNUSED( char_code ); 2862 FT_UNUSED( char_code );
2832 2863
(...skipping 17 matching lines...) Expand all
2850 FT_CALLBACK_DEF( FT_Error ) 2881 FT_CALLBACK_DEF( FT_Error )
2851 tt_cmap14_get_info( TT_CMap cmap, 2882 tt_cmap14_get_info( TT_CMap cmap,
2852 TT_CMapInfo *cmap_info ) 2883 TT_CMapInfo *cmap_info )
2853 { 2884 {
2854 FT_UNUSED( cmap ); 2885 FT_UNUSED( cmap );
2855 2886
2856 cmap_info->format = 14; 2887 cmap_info->format = 14;
2857 /* subtable 14 does not define a language field */ 2888 /* subtable 14 does not define a language field */
2858 cmap_info->language = 0xFFFFFFFFUL; 2889 cmap_info->language = 0xFFFFFFFFUL;
2859 2890
2860 return SFNT_Err_Ok; 2891 return FT_Err_Ok;
2861 } 2892 }
2862 2893
2863 2894
2864 static FT_UInt 2895 static FT_UInt
2865 tt_cmap14_char_map_def_binary( FT_Byte *base, 2896 tt_cmap14_char_map_def_binary( FT_Byte *base,
2866 FT_UInt32 char_code ) 2897 FT_UInt32 char_code )
2867 { 2898 {
2868 FT_UInt32 numRanges = TT_PEEK_ULONG( base ); 2899 FT_UInt32 numRanges = TT_PEEK_ULONG( base );
2869 FT_UInt32 max, min; 2900 FT_UInt32 max, min;
2870 2901
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
2958 } 2989 }
2959 2990
2960 return NULL; 2991 return NULL;
2961 } 2992 }
2962 2993
2963 2994
2964 FT_CALLBACK_DEF( FT_UInt ) 2995 FT_CALLBACK_DEF( FT_UInt )
2965 tt_cmap14_char_var_index( TT_CMap cmap, 2996 tt_cmap14_char_var_index( TT_CMap cmap,
2966 TT_CMap ucmap, 2997 TT_CMap ucmap,
2967 FT_UInt32 charcode, 2998 FT_UInt32 charcode,
2968 FT_UInt32 variantSelector) 2999 FT_UInt32 variantSelector )
2969 { 3000 {
2970 FT_Byte* p = tt_cmap14_find_variant( cmap->data + 6, variantSelector ); 3001 FT_Byte* p = tt_cmap14_find_variant( cmap->data + 6, variantSelector );
2971 FT_ULong defOff; 3002 FT_ULong defOff;
2972 FT_ULong nondefOff; 3003 FT_ULong nondefOff;
2973 3004
2974 3005
2975 if ( !p ) 3006 if ( !p )
2976 return 0; 3007 return 0;
2977 3008
2978 defOff = TT_NEXT_ULONG( p ); 3009 defOff = TT_NEXT_ULONG( p );
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
3099 { 3130 {
3100 tot += 1 + p[0]; 3131 tot += 1 + p[0];
3101 p += 4; 3132 p += 4;
3102 } 3133 }
3103 3134
3104 return tot; 3135 return tot;
3105 } 3136 }
3106 3137
3107 3138
3108 static FT_UInt32* 3139 static FT_UInt32*
3109 tt_cmap14_get_def_chars( TT_CMap cmap, 3140 tt_cmap14_get_def_chars( TT_CMap cmap,
3110 FT_Byte* p, 3141 FT_Byte* p,
3111 FT_Memory memory ) 3142 FT_Memory memory )
3112 { 3143 {
3113 TT_CMap14 cmap14 = (TT_CMap14) cmap; 3144 TT_CMap14 cmap14 = (TT_CMap14) cmap;
3114 FT_UInt32 numRanges; 3145 FT_UInt32 numRanges;
3115 FT_UInt cnt; 3146 FT_UInt cnt;
3116 FT_UInt32* q; 3147 FT_UInt32* q;
3117 3148
3118 3149
3119 cnt = tt_cmap14_def_char_count( p ); 3150 cnt = tt_cmap14_def_char_count( p );
3120 numRanges = (FT_UInt32)TT_NEXT_ULONG( p ); 3151 numRanges = (FT_UInt32)TT_NEXT_ULONG( p );
3121 3152
3122 if ( tt_cmap14_ensure( cmap14, ( cnt + 1 ), memory ) ) 3153 if ( tt_cmap14_ensure( cmap14, ( cnt + 1 ), memory ) )
3123 return NULL; 3154 return NULL;
3124 3155
3125 for ( q = cmap14->results; numRanges > 0; --numRanges ) 3156 for ( q = cmap14->results; numRanges > 0; --numRanges )
3126 { 3157 {
3127 FT_UInt32 uni = (FT_UInt32)TT_NEXT_UINT24( p ); 3158 FT_UInt32 uni = (FT_UInt32)TT_NEXT_UINT24( p );
3128 3159
3129 3160
3130 cnt = FT_NEXT_BYTE( p ) + 1; 3161 cnt = FT_NEXT_BYTE( p ) + 1;
3131 do 3162 do
3132 { 3163 {
3133 q[0] = uni; 3164 q[0] = uni;
3134 uni += 1; 3165 uni += 1;
3135 q += 1; 3166 q += 1;
3167
3136 } while ( --cnt != 0 ); 3168 } while ( --cnt != 0 );
3137 } 3169 }
3138 q[0] = 0; 3170 q[0] = 0;
3139 3171
3140 return cmap14->results; 3172 return cmap14->results;
3141 } 3173 }
3142 3174
3143 3175
3144 static FT_UInt32* 3176 static FT_UInt32*
3145 tt_cmap14_get_nondef_chars( TT_CMap cmap, 3177 tt_cmap14_get_nondef_chars( TT_CMap cmap,
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
3299 } 3331 }
3300 } 3332 }
3301 3333
3302 ret[i] = 0; 3334 ret[i] = 0;
3303 3335
3304 return ret; 3336 return ret;
3305 } 3337 }
3306 } 3338 }
3307 3339
3308 3340
3309 FT_DEFINE_TT_CMAP(tt_cmap14_class_rec, 3341 FT_DEFINE_TT_CMAP(
3310 sizeof ( TT_CMap14Rec ), 3342 tt_cmap14_class_rec,
3343 sizeof ( TT_CMap14Rec ),
3311 3344
3312 (FT_CMap_InitFunc) tt_cmap14_init, 3345 (FT_CMap_InitFunc) tt_cmap14_init,
3313 (FT_CMap_DoneFunc) tt_cmap14_done, 3346 (FT_CMap_DoneFunc) tt_cmap14_done,
3314 (FT_CMap_CharIndexFunc)tt_cmap14_char_index, 3347 (FT_CMap_CharIndexFunc)tt_cmap14_char_index,
3315 (FT_CMap_CharNextFunc) tt_cmap14_char_next, 3348 (FT_CMap_CharNextFunc) tt_cmap14_char_next,
3316 3349
3317 /* Format 14 extension functions */ 3350 /* Format 14 extension functions */
3318 (FT_CMap_CharVarIndexFunc) tt_cmap14_char_var_index, 3351 (FT_CMap_CharVarIndexFunc) tt_cmap14_char_var_index,
3319 (FT_CMap_CharVarIsDefaultFunc)tt_cmap14_char_var_isdefault, 3352 (FT_CMap_CharVarIsDefaultFunc)tt_cmap14_char_var_isdefault,
3320 (FT_CMap_VariantListFunc) tt_cmap14_variants, 3353 (FT_CMap_VariantListFunc) tt_cmap14_variants,
3321 (FT_CMap_CharVariantListFunc) tt_cmap14_char_variants, 3354 (FT_CMap_CharVariantListFunc) tt_cmap14_char_variants,
3322 (FT_CMap_VariantCharListFunc) tt_cmap14_variant_chars 3355 (FT_CMap_VariantCharListFunc) tt_cmap14_variant_chars,
3323 , 3356
3324 14, 3357 14,
3325 (TT_CMap_ValidateFunc)tt_cmap14_validate, 3358 (TT_CMap_ValidateFunc)tt_cmap14_validate,
3326 (TT_CMap_Info_GetFunc)tt_cmap14_get_info 3359 (TT_CMap_Info_GetFunc)tt_cmap14_get_info )
3327 )
3328 3360
3329 #endif /* TT_CONFIG_CMAP_FORMAT_14 */ 3361 #endif /* TT_CONFIG_CMAP_FORMAT_14 */
3330 3362
3331 3363
3332 #ifndef FT_CONFIG_OPTION_PIC 3364 #ifndef FT_CONFIG_OPTION_PIC
3333 3365
3334 static const TT_CMap_Class tt_cmap_classes[] = 3366 static const TT_CMap_Class tt_cmap_classes[] =
3335 { 3367 {
3336 #define TTCMAPCITEM(a) &a, 3368 #define TTCMAPCITEM( a ) &a,
3337 #include "ttcmapc.h" 3369 #include "ttcmapc.h"
3338 NULL, 3370 NULL,
3339 }; 3371 };
3340 3372
3341 #else /*FT_CONFIG_OPTION_PIC*/ 3373 #else /*FT_CONFIG_OPTION_PIC*/
3342 3374
3343 void FT_Destroy_Class_tt_cmap_classes(FT_Library library, TT_CMap_Class* clazz ) 3375 void
3376 FT_Destroy_Class_tt_cmap_classes( FT_Library library,
3377 TT_CMap_Class* clazz )
3344 { 3378 {
3345 FT_Memory memory = library->memory; 3379 FT_Memory memory = library->memory;
3380
3381
3346 if ( clazz ) 3382 if ( clazz )
3347 FT_FREE( clazz ); 3383 FT_FREE( clazz );
3348 } 3384 }
3349 3385
3350 FT_Error FT_Create_Class_tt_cmap_classes(FT_Library library, TT_CMap_Class** o utput_class) 3386
3387 FT_Error
3388 FT_Create_Class_tt_cmap_classes( FT_Library library,
3389 TT_CMap_Class** output_class )
3351 { 3390 {
3352 TT_CMap_Class* clazz; 3391 TT_CMap_Class* clazz = NULL;
3353 TT_CMap_ClassRec* recs; 3392 TT_CMap_ClassRec* recs;
3354 FT_Error error; 3393 FT_Error error;
3355 FT_Memory memory = library->memory; 3394 FT_Memory memory = library->memory;
3356 int i = 0;
3357 3395
3358 #define TTCMAPCITEM(a) i++; 3396 int i = 0;
3397
3398
3399 #define TTCMAPCITEM( a ) i++;
3359 #include "ttcmapc.h" 3400 #include "ttcmapc.h"
3360 3401
3361 /* allocate enough space for both the pointers +terminator and the class ins tances */ 3402 /* allocate enough space for both the pointers */
3362 if ( FT_ALLOC( clazz, sizeof(*clazz)*(i+1)+sizeof(TT_CMap_ClassRec)*i ) ) 3403 /* plus terminator and the class instances */
3404 if ( FT_ALLOC( clazz, sizeof ( *clazz ) * ( i + 1 ) +
3405 sizeof ( TT_CMap_ClassRec ) * i ) )
3363 return error; 3406 return error;
3364 3407
3365 /* the location of the class instances follows the array of pointers */ 3408 /* the location of the class instances follows the array of pointers */
3366 recs = (TT_CMap_ClassRec*) (((char*)clazz)+(sizeof(*clazz)*(i+1))); 3409 recs = (TT_CMap_ClassRec*)( (char*)clazz +
3367 i=0; 3410 sizeof ( *clazz ) * ( i + 1 ) );
3411 i = 0;
3368 3412
3369 #undef TTCMAPCITEM 3413 #undef TTCMAPCITEM
3370 #define TTCMAPCITEM(a) \ 3414 #define TTCMAPCITEM( a ) \
3371 FT_Init_Class_##a(&recs[i]); \ 3415 FT_Init_Class_ ## a( &recs[i] ); \
3372 clazz[i] = &recs[i]; \ 3416 clazz[i] = &recs[i]; \
3373 i++; 3417 i++;
3374 #include "ttcmapc.h" 3418 #include "ttcmapc.h"
3375 3419
3376 clazz[i] = NULL; 3420 clazz[i] = NULL;
3377 3421
3378 *output_class = clazz; 3422 *output_class = clazz;
3379 return SFNT_Err_Ok; 3423 return FT_Err_Ok;
3380 } 3424 }
3381 3425
3382 #endif /*FT_CONFIG_OPTION_PIC*/ 3426 #endif /*FT_CONFIG_OPTION_PIC*/
3383 3427
3384 3428
3385 /* parse the `cmap' table and build the corresponding TT_CMap objects */ 3429 /* parse the `cmap' table and build the corresponding TT_CMap objects */
3386 /* in the current face */ 3430 /* in the current face */
3387 /* */ 3431 /* */
3388 FT_LOCAL_DEF( FT_Error ) 3432 FT_LOCAL_DEF( FT_Error )
3389 tt_face_build_cmaps( TT_Face face ) 3433 tt_face_build_cmaps( TT_Face face )
3390 { 3434 {
3391 FT_Byte* table = face->cmap_table; 3435 FT_Byte* table = face->cmap_table;
3392 FT_Byte* limit = table + face->cmap_size; 3436 FT_Byte* limit = table + face->cmap_size;
3393 FT_UInt volatile num_cmaps; 3437 FT_UInt volatile num_cmaps;
3394 FT_Byte* volatile p = table; 3438 FT_Byte* volatile p = table;
3395 FT_Library library = FT_FACE_LIBRARY( face ); 3439 FT_Library library = FT_FACE_LIBRARY( face );
3396 3440
3397 FT_UNUSED( library ); 3441 FT_UNUSED( library );
3398 3442
3399 3443
3400 if ( !p || p + 4 > limit ) 3444 if ( !p || p + 4 > limit )
3401 return SFNT_Err_Invalid_Table; 3445 return FT_THROW( Invalid_Table );
3402 3446
3403 /* only recognize format 0 */ 3447 /* only recognize format 0 */
3404 if ( TT_NEXT_USHORT( p ) != 0 ) 3448 if ( TT_NEXT_USHORT( p ) != 0 )
3405 { 3449 {
3406 p -= 2; 3450 p -= 2;
3407 FT_ERROR(( "tt_face_build_cmaps:" 3451 FT_ERROR(( "tt_face_build_cmaps:"
3408 " unsupported `cmap' table format = %d\n", 3452 " unsupported `cmap' table format = %d\n",
3409 TT_PEEK_USHORT( p ) )); 3453 TT_PEEK_USHORT( p ) ));
3410 return SFNT_Err_Invalid_Table; 3454 return FT_THROW( Invalid_Table );
3411 } 3455 }
3412 3456
3413 num_cmaps = TT_NEXT_USHORT( p ); 3457 num_cmaps = TT_NEXT_USHORT( p );
3458
3414 #ifdef FT_MAX_CHARMAP_CACHEABLE 3459 #ifdef FT_MAX_CHARMAP_CACHEABLE
3415 if ( num_cmaps > FT_MAX_CHARMAP_CACHEABLE ) 3460 if ( num_cmaps > FT_MAX_CHARMAP_CACHEABLE )
3416 FT_ERROR(( "tt_face_build_cmaps: too many cmap subtables(%d) " 3461 FT_ERROR(( "tt_face_build_cmaps: too many cmap subtables (%d)\n"
3417 "subtable#%d and later are loaded but cannot be searched\n", 3462 " subtable #%d and higher are loaded"
3463 " but cannot be searched\n",
3418 num_cmaps, FT_MAX_CHARMAP_CACHEABLE + 1 )); 3464 num_cmaps, FT_MAX_CHARMAP_CACHEABLE + 1 ));
3419 #endif 3465 #endif
3420 3466
3421 for ( ; num_cmaps > 0 && p + 8 <= limit; num_cmaps-- ) 3467 for ( ; num_cmaps > 0 && p + 8 <= limit; num_cmaps-- )
3422 { 3468 {
3423 FT_CharMapRec charmap; 3469 FT_CharMapRec charmap;
3424 FT_UInt32 offset; 3470 FT_UInt32 offset;
3425 3471
3426 3472
3427 charmap.platform_id = TT_NEXT_USHORT( p ); 3473 charmap.platform_id = TT_NEXT_USHORT( p );
3428 charmap.encoding_id = TT_NEXT_USHORT( p ); 3474 charmap.encoding_id = TT_NEXT_USHORT( p );
3429 charmap.face = FT_FACE( face ); 3475 charmap.face = FT_FACE( face );
3430 charmap.encoding = FT_ENCODING_NONE; /* will be filled later */ 3476 charmap.encoding = FT_ENCODING_NONE; /* will be filled later */
3431 offset = TT_NEXT_ULONG( p ); 3477 offset = TT_NEXT_ULONG( p );
3432 3478
3433 if ( offset && offset <= face->cmap_size - 2 ) 3479 if ( offset && offset <= face->cmap_size - 2 )
3434 { 3480 {
3435 FT_Byte* volatile cmap = table + offset; 3481 FT_Byte* volatile cmap = table + offset;
3436 volatile FT_UInt format = TT_PEEK_USHORT( cmap ); 3482 volatile FT_UInt format = TT_PEEK_USHORT( cmap );
3437 const TT_CMap_Class* volatile pclazz = FT_TT_CMAP_CLASSES_GET; 3483 const TT_CMap_Class* volatile pclazz = TT_CMAP_CLASSES_GET;
3438 TT_CMap_Class volatile clazz; 3484 TT_CMap_Class volatile clazz;
3439 3485
3440 3486
3441 for ( ; *pclazz; pclazz++ ) 3487 for ( ; *pclazz; pclazz++ )
3442 { 3488 {
3443 clazz = *pclazz; 3489 clazz = *pclazz;
3444 if ( clazz->format == format ) 3490 if ( clazz->format == format )
3445 { 3491 {
3446 volatile TT_ValidatorRec valid; 3492 volatile TT_ValidatorRec valid;
3447 volatile FT_Error error = SFNT_Err_Ok; 3493 volatile FT_Error error = FT_Err_Ok;
3448 3494
3449 3495
3450 ft_validator_init( FT_VALIDATOR( &valid ), cmap, limit, 3496 ft_validator_init( FT_VALIDATOR( &valid ), cmap, limit,
3451 FT_VALIDATE_DEFAULT ); 3497 FT_VALIDATE_DEFAULT );
3452 3498
3453 valid.num_glyphs = (FT_UInt)face->max_profile.numGlyphs; 3499 valid.num_glyphs = (FT_UInt)face->max_profile.numGlyphs;
3454 3500
3455 if ( ft_setjmp( 3501 if ( ft_setjmp( FT_VALIDATOR( &valid )->jump_buffer) == 0 )
3456 *((ft_jmp_buf*)&FT_VALIDATOR( &valid )->jump_buffer) ) == 0 )
3457 { 3502 {
3458 /* validate this cmap sub-table */ 3503 /* validate this cmap sub-table */
3459 error = clazz->validate( cmap, FT_VALIDATOR( &valid ) ); 3504 error = clazz->validate( cmap, FT_VALIDATOR( &valid ) );
3460 } 3505 }
3461 3506
3462 if ( valid.validator.error == 0 ) 3507 if ( valid.validator.error == 0 )
3463 { 3508 {
3464 FT_CMap ttcmap; 3509 FT_CMap ttcmap;
3465 3510
3466 3511
3467 /* It might make sense to store the single variation selector */ 3512 /* It might make sense to store the single variation */
3468 /* cmap somewhere special. But it would have to be in the */ 3513 /* selector cmap somewhere special. But it would have to be */
3469 /* public FT_FaceRec, and we can't change that. */ 3514 /* in the public FT_FaceRec, and we can't change that. */
3470 3515
3471 if ( !FT_CMap_New( (FT_CMap_Class)clazz, 3516 if ( !FT_CMap_New( (FT_CMap_Class)clazz,
3472 cmap, &charmap, &ttcmap ) ) 3517 cmap, &charmap, &ttcmap ) )
3473 { 3518 {
3474 /* it is simpler to directly set `flags' than adding */ 3519 /* it is simpler to directly set `flags' than adding */
3475 /* a parameter to FT_CMap_New */ 3520 /* a parameter to FT_CMap_New */
3476 ((TT_CMap)ttcmap)->flags = (FT_Int)error; 3521 ((TT_CMap)ttcmap)->flags = (FT_Int)error;
3477 } 3522 }
3478 } 3523 }
3479 else 3524 else
3480 { 3525 {
3481 FT_TRACE0(( "tt_face_build_cmaps:" 3526 FT_TRACE0(( "tt_face_build_cmaps:"
3482 " broken cmap sub-table ignored\n" )); 3527 " broken cmap sub-table ignored\n" ));
3483 } 3528 }
3484 break; 3529 break;
3485 } 3530 }
3486 } 3531 }
3487 3532
3488 if ( *pclazz == NULL ) 3533 if ( *pclazz == NULL )
3489 { 3534 {
3490 FT_TRACE0(( "tt_face_build_cmaps:" 3535 FT_TRACE0(( "tt_face_build_cmaps:"
3491 " unsupported cmap sub-table ignored\n" )); 3536 " unsupported cmap sub-table ignored\n" ));
3492 } 3537 }
3493 } 3538 }
3494 } 3539 }
3495 3540
3496 return SFNT_Err_Ok; 3541 return FT_Err_Ok;
3497 } 3542 }
3498 3543
3499 3544
3500 FT_LOCAL( FT_Error ) 3545 FT_LOCAL( FT_Error )
3501 tt_get_cmap_info( FT_CharMap charmap, 3546 tt_get_cmap_info( FT_CharMap charmap,
3502 TT_CMapInfo *cmap_info ) 3547 TT_CMapInfo *cmap_info )
3503 { 3548 {
3504 FT_CMap cmap = (FT_CMap)charmap; 3549 FT_CMap cmap = (FT_CMap)charmap;
3505 TT_CMap_Class clazz = (TT_CMap_Class)cmap->clazz; 3550 TT_CMap_Class clazz = (TT_CMap_Class)cmap->clazz;
3506 3551
3507 3552
3508 return clazz->get_cmap_info( charmap, cmap_info ); 3553 return clazz->get_cmap_info( charmap, cmap_info );
3509 } 3554 }
3510 3555
3511 3556
3512 /* END */ 3557 /* END */
OLDNEW
« no previous file with comments | « src/sfnt/ttcmap.h ('k') | src/sfnt/ttcmapc.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698