* src/sfnt/ttcmap: Signature fixes.

This commit is contained in:
Werner Lemberg 2023-05-07 19:16:38 +02:00
parent 60c11919e0
commit 365eb10dd4
1 changed files with 239 additions and 182 deletions

View File

@ -59,10 +59,14 @@
FT_CALLBACK_DEF( FT_Error ) FT_CALLBACK_DEF( FT_Error )
tt_cmap_init( TT_CMap cmap, tt_cmap_init( FT_CMap cmap, /* TT_CMap */
FT_Byte* table ) void* table_ )
{ {
cmap->data = table; TT_CMap ttcmap = (TT_CMap)cmap;
FT_Byte* table = (FT_Byte*)table_;
ttcmap->data = table;
return FT_Err_Ok; return FT_Err_Ok;
} }
@ -128,10 +132,11 @@
FT_CALLBACK_DEF( FT_UInt ) FT_CALLBACK_DEF( FT_UInt )
tt_cmap0_char_index( TT_CMap cmap, tt_cmap0_char_index( FT_CMap cmap, /* TT_CMap */
FT_UInt32 char_code ) FT_UInt32 char_code )
{ {
FT_Byte* table = cmap->data; TT_CMap ttcmap = (TT_CMap)cmap;
FT_Byte* table = ttcmap->data;
return char_code < 256 ? table[6 + char_code] : 0; return char_code < 256 ? table[6 + char_code] : 0;
@ -139,10 +144,11 @@
FT_CALLBACK_DEF( FT_UInt ) FT_CALLBACK_DEF( FT_UInt )
tt_cmap0_char_next( TT_CMap cmap, tt_cmap0_char_next( FT_CMap cmap, /* TT_CMap */
FT_UInt32 *pchar_code ) FT_UInt32 *pchar_code )
{ {
FT_Byte* table = cmap->data; TT_CMap ttcmap = (TT_CMap)cmap;
FT_Byte* table = ttcmap->data;
FT_UInt32 charcode = *pchar_code; FT_UInt32 charcode = *pchar_code;
FT_UInt32 result = 0; FT_UInt32 result = 0;
FT_UInt gindex = 0; FT_UInt gindex = 0;
@ -165,10 +171,11 @@
FT_CALLBACK_DEF( FT_Error ) FT_CALLBACK_DEF( FT_Error )
tt_cmap0_get_info( TT_CMap cmap, tt_cmap0_get_info( FT_CharMap cmap, /* TT_CMap */
TT_CMapInfo *cmap_info ) TT_CMapInfo *cmap_info )
{ {
FT_Byte* p = cmap->data + 4; TT_CMap ttcmap = (TT_CMap)cmap;
FT_Byte* p = ttcmap->data + 4;
cmap_info->format = 0; cmap_info->format = 0;
@ -453,10 +460,11 @@
FT_CALLBACK_DEF( FT_UInt ) FT_CALLBACK_DEF( FT_UInt )
tt_cmap2_char_index( TT_CMap cmap, tt_cmap2_char_index( FT_CMap cmap, /* TT_CMap */
FT_UInt32 char_code ) FT_UInt32 char_code )
{ {
FT_Byte* table = cmap->data; TT_CMap ttcmap = (TT_CMap)cmap;
FT_Byte* table = ttcmap->data;
FT_UInt result = 0; FT_UInt result = 0;
FT_Byte* subheader; FT_Byte* subheader;
@ -492,10 +500,11 @@
FT_CALLBACK_DEF( FT_UInt ) FT_CALLBACK_DEF( FT_UInt )
tt_cmap2_char_next( TT_CMap cmap, tt_cmap2_char_next( FT_CMap cmap, /* TT_CMap */
FT_UInt32 *pcharcode ) FT_UInt32 *pcharcode )
{ {
FT_Byte* table = cmap->data; TT_CMap ttcmap = (TT_CMap)cmap;
FT_Byte* table = ttcmap->data;
FT_UInt gindex = 0; FT_UInt gindex = 0;
FT_UInt32 result = 0; FT_UInt32 result = 0;
FT_UInt32 charcode = *pcharcode + 1; FT_UInt32 charcode = *pcharcode + 1;
@ -579,10 +588,11 @@
FT_CALLBACK_DEF( FT_Error ) FT_CALLBACK_DEF( FT_Error )
tt_cmap2_get_info( TT_CMap cmap, tt_cmap2_get_info( FT_CharMap cmap, /* TT_CMap */
TT_CMapInfo *cmap_info ) TT_CMapInfo *cmap_info )
{ {
FT_Byte* p = cmap->data + 4; TT_CMap ttcmap = (TT_CMap)cmap;
FT_Byte* p = ttcmap->data + 4;
cmap_info->format = 2; cmap_info->format = 2;
@ -706,18 +716,20 @@
FT_CALLBACK_DEF( FT_Error ) FT_CALLBACK_DEF( FT_Error )
tt_cmap4_init( TT_CMap4 cmap, tt_cmap4_init( FT_CMap cmap, /* TT_CMap4 */
FT_Byte* table ) void* table_ )
{ {
TT_CMap4 ttcmap = (TT_CMap4)cmap;
FT_Byte* table = (FT_Byte*)table_;
FT_Byte* p; FT_Byte* p;
cmap->cmap.data = table; ttcmap->cmap.data = table;
p = table + 6; p = table + 6;
cmap->num_ranges = FT_PEEK_USHORT( p ) >> 1; ttcmap->num_ranges = FT_PEEK_USHORT( p ) >> 1;
cmap->cur_charcode = (FT_UInt32)0xFFFFFFFFUL; ttcmap->cur_charcode = (FT_UInt32)0xFFFFFFFFUL;
cmap->cur_gindex = 0; ttcmap->cur_gindex = 0;
return FT_Err_Ok; return FT_Err_Ok;
} }
@ -755,7 +767,7 @@
cmap->cur_start == 0xFFFFU && cmap->cur_start == 0xFFFFU &&
cmap->cur_end == 0xFFFFU ) cmap->cur_end == 0xFFFFU )
{ {
TT_Face face = (TT_Face)cmap->cmap.cmap.charmap.face; TT_Face face = (TT_Face)FT_CMAP_FACE( cmap );
FT_Byte* limit = face->cmap_table + face->cmap_size; FT_Byte* limit = face->cmap_table + face->cmap_size;
@ -788,7 +800,7 @@
static void static void
tt_cmap4_next( TT_CMap4 cmap ) tt_cmap4_next( TT_CMap4 cmap )
{ {
TT_Face face = (TT_Face)cmap->cmap.cmap.charmap.face; TT_Face face = (TT_Face)FT_CMAP_FACE( cmap );
FT_Byte* limit = face->cmap_table + face->cmap_size; FT_Byte* limit = face->cmap_table + face->cmap_size;
FT_UInt charcode; FT_UInt charcode;
@ -1093,7 +1105,7 @@
FT_UInt32* pcharcode, FT_UInt32* pcharcode,
FT_Bool next ) FT_Bool next )
{ {
TT_Face face = (TT_Face)cmap->cmap.charmap.face; TT_Face face = (TT_Face)FT_CMAP_FACE( cmap );
FT_Byte* limit = face->cmap_table + face->cmap_size; FT_Byte* limit = face->cmap_table + face->cmap_size;
@ -1222,7 +1234,7 @@
FT_UInt32* pcharcode, FT_UInt32* pcharcode,
FT_Bool next ) FT_Bool next )
{ {
TT_Face face = (TT_Face)cmap->cmap.charmap.face; TT_Face face = (TT_Face)FT_CMAP_FACE( cmap );
FT_Byte* limit = face->cmap_table + face->cmap_size; FT_Byte* limit = face->cmap_table + face->cmap_size;
FT_UInt num_segs2, start, end, offset; FT_UInt num_segs2, start, end, offset;
@ -1468,31 +1480,35 @@
FT_CALLBACK_DEF( FT_UInt ) FT_CALLBACK_DEF( FT_UInt )
tt_cmap4_char_index( TT_CMap cmap, tt_cmap4_char_index( FT_CMap cmap, /* TT_CMap */
FT_UInt32 char_code ) FT_UInt32 char_code )
{ {
TT_CMap ttcmap = (TT_CMap)cmap;
if ( char_code >= 0x10000UL ) if ( char_code >= 0x10000UL )
return 0; return 0;
if ( cmap->flags & TT_CMAP_FLAG_UNSORTED ) if ( ttcmap->flags & TT_CMAP_FLAG_UNSORTED )
return tt_cmap4_char_map_linear( cmap, &char_code, 0 ); return tt_cmap4_char_map_linear( ttcmap, &char_code, 0 );
else else
return tt_cmap4_char_map_binary( cmap, &char_code, 0 ); return tt_cmap4_char_map_binary( ttcmap, &char_code, 0 );
} }
FT_CALLBACK_DEF( FT_UInt ) FT_CALLBACK_DEF( FT_UInt )
tt_cmap4_char_next( TT_CMap cmap, tt_cmap4_char_next( FT_CMap cmap, /* TT_CMap */
FT_UInt32 *pchar_code ) FT_UInt32 *pchar_code )
{ {
TT_CMap ttcmap = (TT_CMap)cmap;
FT_UInt gindex; FT_UInt gindex;
if ( *pchar_code >= 0xFFFFU ) if ( *pchar_code >= 0xFFFFU )
return 0; return 0;
if ( cmap->flags & TT_CMAP_FLAG_UNSORTED ) if ( ttcmap->flags & TT_CMAP_FLAG_UNSORTED )
gindex = tt_cmap4_char_map_linear( cmap, pchar_code, 1 ); gindex = tt_cmap4_char_map_linear( ttcmap, pchar_code, 1 );
else else
{ {
TT_CMap4 cmap4 = (TT_CMap4)cmap; TT_CMap4 cmap4 = (TT_CMap4)cmap;
@ -1507,7 +1523,7 @@
*pchar_code = cmap4->cur_charcode; *pchar_code = cmap4->cur_charcode;
} }
else else
gindex = tt_cmap4_char_map_binary( cmap, pchar_code, 1 ); gindex = tt_cmap4_char_map_binary( ttcmap, pchar_code, 1 );
} }
return gindex; return gindex;
@ -1515,10 +1531,11 @@
FT_CALLBACK_DEF( FT_Error ) FT_CALLBACK_DEF( FT_Error )
tt_cmap4_get_info( TT_CMap cmap, tt_cmap4_get_info( FT_CharMap cmap, /* TT_CMap */
TT_CMapInfo *cmap_info ) TT_CMapInfo *cmap_info )
{ {
FT_Byte* p = cmap->data + 4; TT_CMap ttcmap = (TT_CMap)cmap;
FT_Byte* p = ttcmap->data + 4;
cmap_info->format = 4; cmap_info->format = 4;
@ -1619,10 +1636,11 @@
FT_CALLBACK_DEF( FT_UInt ) FT_CALLBACK_DEF( FT_UInt )
tt_cmap6_char_index( TT_CMap cmap, tt_cmap6_char_index( FT_CMap cmap, /* TT_CMap */
FT_UInt32 char_code ) FT_UInt32 char_code )
{ {
FT_Byte* table = cmap->data; TT_CMap ttcmap = (TT_CMap)cmap;
FT_Byte* table = ttcmap->data;
FT_UInt result = 0; FT_UInt result = 0;
FT_Byte* p = table + 6; FT_Byte* p = table + 6;
FT_UInt start = TT_NEXT_USHORT( p ); FT_UInt start = TT_NEXT_USHORT( p );
@ -1641,10 +1659,11 @@
FT_CALLBACK_DEF( FT_UInt ) FT_CALLBACK_DEF( FT_UInt )
tt_cmap6_char_next( TT_CMap cmap, tt_cmap6_char_next( FT_CMap cmap, /* TT_CMap */
FT_UInt32 *pchar_code ) FT_UInt32 *pchar_code )
{ {
FT_Byte* table = cmap->data; TT_CMap ttcmap = (TT_CMap)cmap;
FT_Byte* table = ttcmap->data;
FT_UInt32 result = 0; FT_UInt32 result = 0;
FT_UInt32 char_code = *pchar_code + 1; FT_UInt32 char_code = *pchar_code + 1;
FT_UInt gindex = 0; FT_UInt gindex = 0;
@ -1685,10 +1704,11 @@
FT_CALLBACK_DEF( FT_Error ) FT_CALLBACK_DEF( FT_Error )
tt_cmap6_get_info( TT_CMap cmap, tt_cmap6_get_info( FT_CharMap cmap, /* TT_CMap */
TT_CMapInfo *cmap_info ) TT_CMapInfo *cmap_info )
{ {
FT_Byte* p = cmap->data + 4; TT_CMap ttcmap = (TT_CMap)cmap;
FT_Byte* p = ttcmap->data + 4;
cmap_info->format = 6; cmap_info->format = 6;
@ -1879,10 +1899,11 @@
FT_CALLBACK_DEF( FT_UInt ) FT_CALLBACK_DEF( FT_UInt )
tt_cmap8_char_index( TT_CMap cmap, tt_cmap8_char_index( FT_CMap cmap, /* TT_CMap */
FT_UInt32 char_code ) FT_UInt32 char_code )
{ {
FT_Byte* table = cmap->data; TT_CMap ttcmap = (TT_CMap)cmap;
FT_Byte* table = ttcmap->data;
FT_UInt result = 0; FT_UInt result = 0;
FT_Byte* p = table + 8204; FT_Byte* p = table + 8204;
FT_UInt32 num_groups = TT_NEXT_ULONG( p ); FT_UInt32 num_groups = TT_NEXT_ULONG( p );
@ -1912,14 +1933,15 @@
FT_CALLBACK_DEF( FT_UInt ) FT_CALLBACK_DEF( FT_UInt )
tt_cmap8_char_next( TT_CMap cmap, tt_cmap8_char_next( FT_CMap cmap, /* TT_CMap */
FT_UInt32 *pchar_code ) FT_UInt32 *pchar_code )
{ {
FT_Face face = cmap->cmap.charmap.face; TT_CMap ttcmap = (TT_CMap)cmap;
FT_Face face = FT_CMAP_FACE( cmap );
FT_UInt32 result = 0; FT_UInt32 result = 0;
FT_UInt32 char_code; FT_UInt32 char_code;
FT_UInt gindex = 0; FT_UInt gindex = 0;
FT_Byte* table = cmap->data; FT_Byte* table = ttcmap->data;
FT_Byte* p = table + 8204; FT_Byte* p = table + 8204;
FT_UInt32 num_groups = TT_NEXT_ULONG( p ); FT_UInt32 num_groups = TT_NEXT_ULONG( p );
FT_UInt32 start, end, start_id; FT_UInt32 start, end, start_id;
@ -1979,10 +2001,11 @@
FT_CALLBACK_DEF( FT_Error ) FT_CALLBACK_DEF( FT_Error )
tt_cmap8_get_info( TT_CMap cmap, tt_cmap8_get_info( FT_CharMap cmap, /* TT_CMap */
TT_CMapInfo *cmap_info ) TT_CMapInfo *cmap_info )
{ {
FT_Byte* p = cmap->data + 8; TT_CMap ttcmap = (TT_CMap)cmap;
FT_Byte* p = ttcmap->data + 8;
cmap_info->format = 8; cmap_info->format = 8;
@ -2083,10 +2106,11 @@
FT_CALLBACK_DEF( FT_UInt ) FT_CALLBACK_DEF( FT_UInt )
tt_cmap10_char_index( TT_CMap cmap, tt_cmap10_char_index( FT_CMap cmap, /* TT_CMap */
FT_UInt32 char_code ) FT_UInt32 char_code )
{ {
FT_Byte* table = cmap->data; TT_CMap ttcmap = (TT_CMap)cmap;
FT_Byte* table = ttcmap->data;
FT_UInt result = 0; FT_UInt result = 0;
FT_Byte* p = table + 12; FT_Byte* p = table + 12;
FT_UInt32 start = TT_NEXT_ULONG( p ); FT_UInt32 start = TT_NEXT_ULONG( p );
@ -2110,10 +2134,11 @@
FT_CALLBACK_DEF( FT_UInt ) FT_CALLBACK_DEF( FT_UInt )
tt_cmap10_char_next( TT_CMap cmap, tt_cmap10_char_next( FT_CMap cmap, /* TT_CMap */
FT_UInt32 *pchar_code ) FT_UInt32 *pchar_code )
{ {
FT_Byte* table = cmap->data; TT_CMap ttcmap = (TT_CMap)cmap;
FT_Byte* table = ttcmap->data;
FT_UInt32 char_code; FT_UInt32 char_code;
FT_UInt gindex = 0; FT_UInt gindex = 0;
FT_Byte* p = table + 12; FT_Byte* p = table + 12;
@ -2151,10 +2176,11 @@
FT_CALLBACK_DEF( FT_Error ) FT_CALLBACK_DEF( FT_Error )
tt_cmap10_get_info( TT_CMap cmap, tt_cmap10_get_info( FT_CharMap cmap, /* TT_CMap */
TT_CMapInfo *cmap_info ) TT_CMapInfo *cmap_info )
{ {
FT_Byte* p = cmap->data + 8; TT_CMap ttcmap = (TT_CMap)cmap;
FT_Byte* p = ttcmap->data + 8;
cmap_info->format = 10; cmap_info->format = 10;
@ -2232,15 +2258,19 @@
FT_CALLBACK_DEF( FT_Error ) FT_CALLBACK_DEF( FT_Error )
tt_cmap12_init( TT_CMap12 cmap, tt_cmap12_init( FT_CMap cmap, /* TT_CMap12 */
FT_Byte* table ) void* table_ )
{ {
cmap->cmap.data = table; TT_CMap12 ttcmap = (TT_CMap12)cmap;
FT_Byte* table = (FT_Byte*)table_;
table += 12;
cmap->num_groups = FT_PEEK_ULONG( table );
cmap->valid = 0; ttcmap->cmap.data = table;
table += 12;
ttcmap->num_groups = FT_PEEK_ULONG( table );
ttcmap->valid = 0;
return FT_Err_Ok; return FT_Err_Ok;
} }
@ -2310,20 +2340,21 @@
/* cmap->cur_group should be set up properly by caller */ /* cmap->cur_group should be set up properly by caller */
/* */ /* */
static void static void
tt_cmap12_next( TT_CMap12 cmap ) tt_cmap12_next( FT_CMap cmap ) /* TT_CMap12 */
{ {
FT_Face face = cmap->cmap.cmap.charmap.face; TT_CMap12 ttcmap = (TT_CMap12)cmap;
FT_Byte* p; FT_Face face = FT_CMAP_FACE( cmap );
FT_ULong start, end, start_id, char_code; FT_Byte* p;
FT_ULong n; FT_ULong start, end, start_id, char_code;
FT_UInt gindex; FT_ULong n;
FT_UInt gindex;
char_code = cmap->cur_charcode + 1; char_code = ttcmap->cur_charcode + 1;
for ( n = cmap->cur_group; n < cmap->num_groups; n++ ) for ( n = ttcmap->cur_group; n < ttcmap->num_groups; n++ )
{ {
p = cmap->cmap.data + 16 + 12 * n; p = ttcmap->cmap.data + 16 + 12 * n;
start = TT_NEXT_ULONG( p ); start = TT_NEXT_ULONG( p );
end = TT_NEXT_ULONG( p ); end = TT_NEXT_ULONG( p );
start_id = TT_PEEK_ULONG( p ); start_id = TT_PEEK_ULONG( p );
@ -2355,16 +2386,16 @@
if ( gindex >= (FT_UInt)face->num_glyphs ) if ( gindex >= (FT_UInt)face->num_glyphs )
continue; continue;
cmap->cur_charcode = char_code; ttcmap->cur_charcode = char_code;
cmap->cur_gindex = gindex; ttcmap->cur_gindex = gindex;
cmap->cur_group = n; ttcmap->cur_group = n;
return; return;
} }
} }
Fail: Fail:
cmap->valid = 0; ttcmap->valid = 0;
} }
@ -2416,7 +2447,7 @@
if ( next ) if ( next )
{ {
FT_Face face = cmap->cmap.charmap.face; FT_Face face = FT_CMAP_FACE( cmap );
TT_CMap12 cmap12 = (TT_CMap12)cmap; TT_CMap12 cmap12 = (TT_CMap12)cmap;
@ -2435,7 +2466,7 @@
if ( !gindex ) if ( !gindex )
{ {
tt_cmap12_next( cmap12 ); tt_cmap12_next( FT_CMAP( cmap12 ) );
if ( cmap12->valid ) if ( cmap12->valid )
gindex = cmap12->cur_gindex; gindex = cmap12->cur_gindex;
@ -2451,15 +2482,15 @@
FT_CALLBACK_DEF( FT_UInt ) FT_CALLBACK_DEF( FT_UInt )
tt_cmap12_char_index( TT_CMap cmap, tt_cmap12_char_index( FT_CMap cmap, /* TT_CMap */
FT_UInt32 char_code ) FT_UInt32 char_code )
{ {
return tt_cmap12_char_map_binary( cmap, &char_code, 0 ); return tt_cmap12_char_map_binary( (TT_CMap)cmap, &char_code, 0 );
} }
FT_CALLBACK_DEF( FT_UInt ) FT_CALLBACK_DEF( FT_UInt )
tt_cmap12_char_next( TT_CMap cmap, tt_cmap12_char_next( FT_CMap cmap, /* TT_CMap12 */
FT_UInt32 *pchar_code ) FT_UInt32 *pchar_code )
{ {
TT_CMap12 cmap12 = (TT_CMap12)cmap; TT_CMap12 cmap12 = (TT_CMap12)cmap;
@ -2472,7 +2503,7 @@
/* no need to search */ /* no need to search */
if ( cmap12->valid && cmap12->cur_charcode == *pchar_code ) if ( cmap12->valid && cmap12->cur_charcode == *pchar_code )
{ {
tt_cmap12_next( cmap12 ); tt_cmap12_next( FT_CMAP( cmap12 ) );
if ( cmap12->valid ) if ( cmap12->valid )
{ {
gindex = cmap12->cur_gindex; gindex = cmap12->cur_gindex;
@ -2482,17 +2513,18 @@
gindex = 0; gindex = 0;
} }
else else
gindex = tt_cmap12_char_map_binary( cmap, pchar_code, 1 ); gindex = tt_cmap12_char_map_binary( (TT_CMap)cmap, pchar_code, 1 );
return gindex; return gindex;
} }
FT_CALLBACK_DEF( FT_Error ) FT_CALLBACK_DEF( FT_Error )
tt_cmap12_get_info( TT_CMap cmap, tt_cmap12_get_info( FT_CharMap cmap, /* TT_CMap */
TT_CMapInfo *cmap_info ) TT_CMapInfo *cmap_info )
{ {
FT_Byte* p = cmap->data + 8; TT_CMap ttcmap = (TT_CMap)cmap;
FT_Byte* p = ttcmap->data + 8;
cmap_info->format = 12; cmap_info->format = 12;
@ -2570,15 +2602,19 @@
FT_CALLBACK_DEF( FT_Error ) FT_CALLBACK_DEF( FT_Error )
tt_cmap13_init( TT_CMap13 cmap, tt_cmap13_init( FT_CMap cmap, /* TT_CMap13 */
FT_Byte* table ) void* table_ )
{ {
cmap->cmap.data = table; TT_CMap13 ttcmap = (TT_CMap13)cmap;
FT_Byte* table = (FT_Byte*)table_;
table += 12;
cmap->num_groups = FT_PEEK_ULONG( table );
cmap->valid = 0; ttcmap->cmap.data = table;
table += 12;
ttcmap->num_groups = FT_PEEK_ULONG( table );
ttcmap->valid = 0;
return FT_Err_Ok; return FT_Err_Ok;
} }
@ -2643,20 +2679,21 @@
/* cmap->cur_group should be set up properly by caller */ /* cmap->cur_group should be set up properly by caller */
/* */ /* */
static void static void
tt_cmap13_next( TT_CMap13 cmap ) tt_cmap13_next( FT_CMap cmap ) /* TT_CMap13 */
{ {
FT_Face face = cmap->cmap.cmap.charmap.face; TT_CMap13 ttcmap = (TT_CMap13)cmap;
FT_Byte* p; FT_Face face = FT_CMAP_FACE( cmap );
FT_ULong start, end, glyph_id, char_code; FT_Byte* p;
FT_ULong n; FT_ULong start, end, glyph_id, char_code;
FT_UInt gindex; FT_ULong n;
FT_UInt gindex;
char_code = cmap->cur_charcode + 1; char_code = ttcmap->cur_charcode + 1;
for ( n = cmap->cur_group; n < cmap->num_groups; n++ ) for ( n = ttcmap->cur_group; n < ttcmap->num_groups; n++ )
{ {
p = cmap->cmap.data + 16 + 12 * n; p = ttcmap->cmap.data + 16 + 12 * n;
start = TT_NEXT_ULONG( p ); start = TT_NEXT_ULONG( p );
end = TT_NEXT_ULONG( p ); end = TT_NEXT_ULONG( p );
glyph_id = TT_PEEK_ULONG( p ); glyph_id = TT_PEEK_ULONG( p );
@ -2670,16 +2707,16 @@
if ( gindex && gindex < (FT_UInt)face->num_glyphs ) if ( gindex && gindex < (FT_UInt)face->num_glyphs )
{ {
cmap->cur_charcode = char_code; ttcmap->cur_charcode = char_code;
cmap->cur_gindex = gindex; ttcmap->cur_gindex = gindex;
cmap->cur_group = n; ttcmap->cur_group = n;
return; return;
} }
} }
} }
cmap->valid = 0; ttcmap->valid = 0;
} }
@ -2745,7 +2782,7 @@
if ( !gindex ) if ( !gindex )
{ {
tt_cmap13_next( cmap13 ); tt_cmap13_next( FT_CMAP( cmap13 ) );
if ( cmap13->valid ) if ( cmap13->valid )
gindex = cmap13->cur_gindex; gindex = cmap13->cur_gindex;
@ -2761,15 +2798,15 @@
FT_CALLBACK_DEF( FT_UInt ) FT_CALLBACK_DEF( FT_UInt )
tt_cmap13_char_index( TT_CMap cmap, tt_cmap13_char_index( FT_CMap cmap, /* TT_CMap */
FT_UInt32 char_code ) FT_UInt32 char_code )
{ {
return tt_cmap13_char_map_binary( cmap, &char_code, 0 ); return tt_cmap13_char_map_binary( (TT_CMap)cmap, &char_code, 0 );
} }
FT_CALLBACK_DEF( FT_UInt ) FT_CALLBACK_DEF( FT_UInt )
tt_cmap13_char_next( TT_CMap cmap, tt_cmap13_char_next( FT_CMap cmap, /* TT_CMap13 */
FT_UInt32 *pchar_code ) FT_UInt32 *pchar_code )
{ {
TT_CMap13 cmap13 = (TT_CMap13)cmap; TT_CMap13 cmap13 = (TT_CMap13)cmap;
@ -2782,7 +2819,7 @@
/* no need to search */ /* no need to search */
if ( cmap13->valid && cmap13->cur_charcode == *pchar_code ) if ( cmap13->valid && cmap13->cur_charcode == *pchar_code )
{ {
tt_cmap13_next( cmap13 ); tt_cmap13_next( FT_CMAP( cmap13 ) );
if ( cmap13->valid ) if ( cmap13->valid )
{ {
gindex = cmap13->cur_gindex; gindex = cmap13->cur_gindex;
@ -2792,17 +2829,18 @@
gindex = 0; gindex = 0;
} }
else else
gindex = tt_cmap13_char_map_binary( cmap, pchar_code, 1 ); gindex = tt_cmap13_char_map_binary( (TT_CMap)cmap, pchar_code, 1 );
return gindex; return gindex;
} }
FT_CALLBACK_DEF( FT_Error ) FT_CALLBACK_DEF( FT_Error )
tt_cmap13_get_info( TT_CMap cmap, tt_cmap13_get_info( FT_CharMap cmap, /* TT_CMap */
TT_CMapInfo *cmap_info ) TT_CMapInfo *cmap_info )
{ {
FT_Byte* p = cmap->data + 8; TT_CMap ttcmap = (TT_CMap)cmap;
FT_Byte* p = ttcmap->data + 8;
cmap_info->format = 13; cmap_info->format = 13;
@ -2917,14 +2955,15 @@
FT_CALLBACK_DEF( void ) FT_CALLBACK_DEF( void )
tt_cmap14_done( TT_CMap14 cmap ) tt_cmap14_done( FT_CMap cmap ) /* TT_CMap14 */
{ {
FT_Memory memory = cmap->memory; TT_CMap14 ttcmap = (TT_CMap14)cmap;
FT_Memory memory = ttcmap->memory;
cmap->max_results = 0; ttcmap->max_results = 0;
if ( memory && cmap->results ) if ( memory && ttcmap->results )
FT_FREE( cmap->results ); FT_FREE( ttcmap->results );
} }
@ -2952,15 +2991,19 @@
FT_CALLBACK_DEF( FT_Error ) FT_CALLBACK_DEF( FT_Error )
tt_cmap14_init( TT_CMap14 cmap, tt_cmap14_init( FT_CMap cmap, /* TT_CMap14 */
FT_Byte* table ) void* table_ )
{ {
cmap->cmap.data = table; TT_CMap14 ttcmap = (TT_CMap14)cmap;
FT_Byte* table = (FT_Byte*)table_;
table += 6;
cmap->num_selectors = FT_PEEK_ULONG( table ); ttcmap->cmap.data = table;
cmap->max_results = 0;
cmap->results = NULL; table += 6;
ttcmap->num_selectors = FT_PEEK_ULONG( table );
ttcmap->max_results = 0;
ttcmap->results = NULL;
return FT_Err_Ok; return FT_Err_Ok;
} }
@ -3090,7 +3133,7 @@
FT_CALLBACK_DEF( FT_UInt ) FT_CALLBACK_DEF( FT_UInt )
tt_cmap14_char_index( TT_CMap cmap, tt_cmap14_char_index( FT_CMap cmap,
FT_UInt32 char_code ) FT_UInt32 char_code )
{ {
FT_UNUSED( cmap ); FT_UNUSED( cmap );
@ -3102,7 +3145,7 @@
FT_CALLBACK_DEF( FT_UInt ) FT_CALLBACK_DEF( FT_UInt )
tt_cmap14_char_next( TT_CMap cmap, tt_cmap14_char_next( FT_CMap cmap,
FT_UInt32 *pchar_code ) FT_UInt32 *pchar_code )
{ {
FT_UNUSED( cmap ); FT_UNUSED( cmap );
@ -3114,7 +3157,7 @@
FT_CALLBACK_DEF( FT_Error ) FT_CALLBACK_DEF( FT_Error )
tt_cmap14_get_info( TT_CMap cmap, tt_cmap14_get_info( FT_CharMap cmap,
TT_CMapInfo *cmap_info ) TT_CMapInfo *cmap_info )
{ {
FT_UNUSED( cmap ); FT_UNUSED( cmap );
@ -3228,12 +3271,16 @@
FT_CALLBACK_DEF( FT_UInt ) FT_CALLBACK_DEF( FT_UInt )
tt_cmap14_char_var_index( TT_CMap cmap, tt_cmap14_char_var_index( FT_CMap cmap, /* TT_CMap */
TT_CMap ucmap, FT_CMap ucmap, /* TT_CMap */
FT_UInt32 charcode, FT_UInt32 charcode,
FT_UInt32 variantSelector ) FT_UInt32 variantSelector )
{ {
FT_Byte* p = tt_cmap14_find_variant( cmap->data + 6, variantSelector ); TT_CMap ttcmap = (TT_CMap)cmap;
TT_CMap ttucmap = (TT_CMap)ucmap;
FT_Byte* p = tt_cmap14_find_variant( ttcmap->data + 6,
variantSelector );
FT_ULong defOff; FT_ULong defOff;
FT_ULong nondefOff; FT_ULong nondefOff;
@ -3244,16 +3291,16 @@
defOff = TT_NEXT_ULONG( p ); defOff = TT_NEXT_ULONG( p );
nondefOff = TT_PEEK_ULONG( p ); nondefOff = TT_PEEK_ULONG( p );
if ( defOff != 0 && if ( defOff != 0 &&
tt_cmap14_char_map_def_binary( cmap->data + defOff, charcode ) ) tt_cmap14_char_map_def_binary( ttcmap->data + defOff, charcode ) )
{ {
/* This is the default variant of this charcode. GID not stored */ /* This is the default variant of this charcode. GID not stored */
/* here; stored in the normal Unicode charmap instead. */ /* here; stored in the normal Unicode charmap instead. */
return ucmap->cmap.clazz->char_index( &ucmap->cmap, charcode ); return ttucmap->cmap.clazz->char_index( &ttucmap->cmap, charcode );
} }
if ( nondefOff != 0 ) if ( nondefOff != 0 )
return tt_cmap14_char_map_nondef_binary( cmap->data + nondefOff, return tt_cmap14_char_map_nondef_binary( ttcmap->data + nondefOff,
charcode ); charcode );
return 0; return 0;
@ -3261,11 +3308,13 @@
FT_CALLBACK_DEF( FT_Int ) FT_CALLBACK_DEF( FT_Int )
tt_cmap14_char_var_isdefault( TT_CMap cmap, tt_cmap14_char_var_isdefault( FT_CMap cmap, /* TT_CMap */
FT_UInt32 charcode, FT_UInt32 charcode,
FT_UInt32 variantSelector ) FT_UInt32 variantSelector )
{ {
FT_Byte* p = tt_cmap14_find_variant( cmap->data + 6, variantSelector ); TT_CMap ttcmap = (TT_CMap)cmap;
FT_Byte* p = tt_cmap14_find_variant( ttcmap->data + 6,
variantSelector );
FT_ULong defOff; FT_ULong defOff;
FT_ULong nondefOff; FT_ULong nondefOff;
@ -3276,13 +3325,13 @@
defOff = TT_NEXT_ULONG( p ); defOff = TT_NEXT_ULONG( p );
nondefOff = TT_NEXT_ULONG( p ); nondefOff = TT_NEXT_ULONG( p );
if ( defOff != 0 && if ( defOff != 0 &&
tt_cmap14_char_map_def_binary( cmap->data + defOff, charcode ) ) tt_cmap14_char_map_def_binary( ttcmap->data + defOff, charcode ) )
return 1; return 1;
if ( nondefOff != 0 && if ( nondefOff != 0 &&
tt_cmap14_char_map_nondef_binary( cmap->data + nondefOff, tt_cmap14_char_map_nondef_binary( ttcmap->data + nondefOff,
charcode ) != 0 ) charcode ) != 0 )
return 0; return 0;
return -1; return -1;
@ -3290,12 +3339,13 @@
FT_CALLBACK_DEF( FT_UInt32* ) FT_CALLBACK_DEF( FT_UInt32* )
tt_cmap14_variants( TT_CMap cmap, tt_cmap14_variants( FT_CMap cmap, /* TT_CMap14 */
FT_Memory memory ) FT_Memory memory )
{ {
TT_CMap ttcmap = (TT_CMap)cmap;
TT_CMap14 cmap14 = (TT_CMap14)cmap; TT_CMap14 cmap14 = (TT_CMap14)cmap;
FT_UInt32 count = cmap14->num_selectors; FT_UInt32 count = cmap14->num_selectors;
FT_Byte* p = cmap->data + 10; FT_Byte* p = ttcmap->data + 10;
FT_UInt32* result; FT_UInt32* result;
FT_UInt32 i; FT_UInt32 i;
@ -3316,13 +3366,14 @@
FT_CALLBACK_DEF( FT_UInt32 * ) FT_CALLBACK_DEF( FT_UInt32 * )
tt_cmap14_char_variants( TT_CMap cmap, tt_cmap14_char_variants( FT_CMap cmap, /* TT_CMap14 */
FT_Memory memory, FT_Memory memory,
FT_UInt32 charCode ) FT_UInt32 charCode )
{ {
TT_CMap14 cmap14 = (TT_CMap14) cmap; TT_CMap ttcmap = (TT_CMap)cmap;
TT_CMap14 cmap14 = (TT_CMap14)cmap;
FT_UInt32 count = cmap14->num_selectors; FT_UInt32 count = cmap14->num_selectors;
FT_Byte* p = cmap->data + 10; FT_Byte* p = ttcmap->data + 10;
FT_UInt32* q; FT_UInt32* q;
@ -3336,12 +3387,12 @@
FT_ULong nondefOff = TT_NEXT_ULONG( p ); FT_ULong nondefOff = TT_NEXT_ULONG( p );
if ( ( defOff != 0 && if ( ( defOff != 0 &&
tt_cmap14_char_map_def_binary( cmap->data + defOff, tt_cmap14_char_map_def_binary( ttcmap->data + defOff,
charCode ) ) || charCode ) ) ||
( nondefOff != 0 && ( nondefOff != 0 &&
tt_cmap14_char_map_nondef_binary( cmap->data + nondefOff, tt_cmap14_char_map_nondef_binary( ttcmap->data + nondefOff,
charCode ) != 0 ) ) charCode ) != 0 ) )
{ {
q[0] = varSel; q[0] = varSel;
q++; q++;
@ -3437,15 +3488,16 @@
FT_CALLBACK_DEF( FT_UInt32 * ) FT_CALLBACK_DEF( FT_UInt32 * )
tt_cmap14_variant_chars( TT_CMap cmap, tt_cmap14_variant_chars( FT_CMap cmap, /* TT_CMap */
FT_Memory memory, FT_Memory memory,
FT_UInt32 variantSelector ) FT_UInt32 variantSelector )
{ {
FT_Byte *p = tt_cmap14_find_variant( cmap->data + 6, TT_CMap ttcmap = (TT_CMap)cmap;
variantSelector ); FT_Byte *p = tt_cmap14_find_variant( ttcmap->data + 6,
FT_Int i; variantSelector );
FT_ULong defOff; FT_Int i;
FT_ULong nondefOff; FT_ULong defOff;
FT_ULong nondefOff;
if ( !p ) if ( !p )
@ -3458,16 +3510,16 @@
return NULL; return NULL;
if ( defOff == 0 ) if ( defOff == 0 )
return tt_cmap14_get_nondef_chars( cmap, cmap->data + nondefOff, return tt_cmap14_get_nondef_chars( ttcmap, ttcmap->data + nondefOff,
memory ); memory );
else if ( nondefOff == 0 ) else if ( nondefOff == 0 )
return tt_cmap14_get_def_chars( cmap, cmap->data + defOff, return tt_cmap14_get_def_chars( ttcmap, ttcmap->data + defOff,
memory ); memory );
else else
{ {
/* Both a default and a non-default glyph set? That's probably not */ /* Both a default and a non-default glyph set? That's probably not */
/* good font design, but the spec allows for it... */ /* good font design, but the spec allows for it... */
TT_CMap14 cmap14 = (TT_CMap14) cmap; TT_CMap14 cmap14 = (TT_CMap14)cmap;
FT_UInt32 numRanges; FT_UInt32 numRanges;
FT_UInt32 numMappings; FT_UInt32 numMappings;
FT_UInt32 duni; FT_UInt32 duni;
@ -3479,18 +3531,18 @@
FT_UInt32 *ret; FT_UInt32 *ret;
p = cmap->data + nondefOff; p = ttcmap->data + nondefOff;
dp = cmap->data + defOff; dp = ttcmap->data + defOff;
numMappings = (FT_UInt32)TT_NEXT_ULONG( p ); numMappings = (FT_UInt32)TT_NEXT_ULONG( p );
dcnt = tt_cmap14_def_char_count( dp ); dcnt = tt_cmap14_def_char_count( dp );
numRanges = (FT_UInt32)TT_NEXT_ULONG( dp ); numRanges = (FT_UInt32)TT_NEXT_ULONG( dp );
if ( numMappings == 0 ) if ( numMappings == 0 )
return tt_cmap14_get_def_chars( cmap, cmap->data + defOff, return tt_cmap14_get_def_chars( ttcmap, ttcmap->data + defOff,
memory ); memory );
if ( dcnt == 0 ) if ( dcnt == 0 )
return tt_cmap14_get_nondef_chars( cmap, cmap->data + nondefOff, return tt_cmap14_get_nondef_chars( ttcmap, ttcmap->data + nondefOff,
memory ); memory );
if ( tt_cmap14_ensure( cmap14, ( dcnt + numMappings + 1 ), memory ) ) if ( tt_cmap14_ensure( cmap14, ( dcnt + numMappings + 1 ), memory ) )
@ -3612,9 +3664,10 @@
#ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES #ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES
FT_CALLBACK_DEF( const char * ) FT_CALLBACK_DEF( const char * )
tt_get_glyph_name( TT_Face face, tt_get_glyph_name( void* face_, /* TT_Face */
FT_UInt idx ) FT_UInt idx )
{ {
TT_Face face = (TT_Face)face_;
FT_String* PSname = NULL; FT_String* PSname = NULL;
@ -3625,12 +3678,13 @@
FT_CALLBACK_DEF( FT_Error ) FT_CALLBACK_DEF( FT_Error )
tt_cmap_unicode_init( PS_Unicodes unicodes, tt_cmap_unicode_init( FT_CMap cmap, /* PS_Unicodes */
FT_Pointer pointer ) FT_Pointer pointer )
{ {
TT_Face face = (TT_Face)FT_CMAP_FACE( unicodes ); PS_Unicodes unicodes = (PS_Unicodes)cmap;
FT_Memory memory = FT_FACE_MEMORY( face ); TT_Face face = (TT_Face)FT_CMAP_FACE( cmap );
FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)face->psnames; FT_Memory memory = FT_FACE_MEMORY( face );
FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)face->psnames;
FT_UNUSED( pointer ); FT_UNUSED( pointer );
@ -3641,17 +3695,18 @@
return psnames->unicodes_init( memory, return psnames->unicodes_init( memory,
unicodes, unicodes,
face->root.num_glyphs, face->root.num_glyphs,
(PS_GetGlyphNameFunc)&tt_get_glyph_name, &tt_get_glyph_name,
(PS_FreeGlyphNameFunc)NULL, (PS_FreeGlyphNameFunc)NULL,
(FT_Pointer)face ); (FT_Pointer)face );
} }
FT_CALLBACK_DEF( void ) FT_CALLBACK_DEF( void )
tt_cmap_unicode_done( PS_Unicodes unicodes ) tt_cmap_unicode_done( FT_CMap cmap ) /* PS_Unicodes */
{ {
FT_Face face = FT_CMAP_FACE( unicodes ); PS_Unicodes unicodes = (PS_Unicodes)cmap;
FT_Memory memory = FT_FACE_MEMORY( face ); FT_Face face = FT_CMAP_FACE( cmap );
FT_Memory memory = FT_FACE_MEMORY( face );
FT_FREE( unicodes->maps ); FT_FREE( unicodes->maps );
@ -3660,11 +3715,12 @@
FT_CALLBACK_DEF( FT_UInt ) FT_CALLBACK_DEF( FT_UInt )
tt_cmap_unicode_char_index( PS_Unicodes unicodes, tt_cmap_unicode_char_index( FT_CMap cmap, /* PS_Unicodes */
FT_UInt32 char_code ) FT_UInt32 char_code )
{ {
TT_Face face = (TT_Face)FT_CMAP_FACE( unicodes ); PS_Unicodes unicodes = (PS_Unicodes)cmap;
FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)face->psnames; TT_Face face = (TT_Face)FT_CMAP_FACE( cmap );
FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)face->psnames;
return psnames->unicodes_char_index( unicodes, char_code ); return psnames->unicodes_char_index( unicodes, char_code );
@ -3672,11 +3728,12 @@
FT_CALLBACK_DEF( FT_UInt ) FT_CALLBACK_DEF( FT_UInt )
tt_cmap_unicode_char_next( PS_Unicodes unicodes, tt_cmap_unicode_char_next( FT_CMap cmap, /* PS_Unicodes */
FT_UInt32 *pchar_code ) FT_UInt32 *pchar_code )
{ {
TT_Face face = (TT_Face)FT_CMAP_FACE( unicodes ); PS_Unicodes unicodes = (PS_Unicodes)cmap;
FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)face->psnames; TT_Face face = (TT_Face)FT_CMAP_FACE( cmap );
FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)face->psnames;
return psnames->unicodes_char_next( unicodes, pchar_code ); return psnames->unicodes_char_next( unicodes, pchar_code );
@ -3831,7 +3888,7 @@
tt_get_cmap_info( FT_CharMap charmap, tt_get_cmap_info( FT_CharMap charmap,
TT_CMapInfo *cmap_info ) TT_CMapInfo *cmap_info )
{ {
FT_CMap cmap = (FT_CMap)charmap; FT_CMap cmap = FT_CMAP( charmap );
TT_CMap_Class clazz = (TT_CMap_Class)cmap->clazz; TT_CMap_Class clazz = (TT_CMap_Class)cmap->clazz;