38 #define FT_COMPONENT trace_gxvcommon 73 for (
i = 0;
i < nmemb;
i++ )
76 for (
i = 0;
i < nmemb;
i++ )
81 (
int(*)(
const void*,
const void*) )gxv_compare_ushort_offset );
83 if ( buff[nmemb] >
limit )
86 for (
i = 0;
i < nmemb;
i++ )
91 for ( j = 0; j < nmemb; j++ )
138 for (
i = 0;
i < nmemb;
i++ )
141 for (
i = 0;
i < nmemb;
i++ )
146 (
int(*)(
const void*,
const void*) )gxv_compare_ulong_offset );
148 if ( buff[nmemb] >
limit )
151 for (
i = 0;
i < nmemb;
i++ )
156 for ( j = 0; j < nmemb; j++ )
163 *(
length[
i]) = buff[j + 1] - buff[j];
205 valid->subtable_length =
p -
table;
234 valid->subtable_length =
p -
table;
246 typedef struct GXV_BinSrchHeader_
266 if ( binSrchHeader->unitSize == 0 )
269 if ( binSrchHeader->nUnits == 0 )
271 if ( binSrchHeader->searchRange == 0 &&
272 binSrchHeader->entrySelector == 0 &&
273 binSrchHeader->rangeShift == 0 )
279 for ( searchRange = 1, entrySelector = 1;
280 ( searchRange * 2 ) <= binSrchHeader->nUnits &&
281 searchRange < 0x8000U;
282 searchRange *= 2, entrySelector++ )
286 searchRange = (
FT_UShort)( searchRange * binSrchHeader->unitSize );
287 rangeShift = (
FT_UShort)( binSrchHeader->nUnits * binSrchHeader->unitSize
290 if ( searchRange != binSrchHeader->searchRange ||
291 entrySelector != binSrchHeader->entrySelector ||
292 rangeShift != binSrchHeader->rangeShift )
294 GXV_TRACE((
"Inconsistency found in BinSrchHeader\n" ));
295 GXV_TRACE((
"originally: unitSize=%d, nUnits=%d, " 296 "searchRange=%d, entrySelector=%d, " 298 binSrchHeader->unitSize, binSrchHeader->nUnits,
299 binSrchHeader->searchRange, binSrchHeader->entrySelector,
300 binSrchHeader->rangeShift ));
301 GXV_TRACE((
"calculated: unitSize=%d, nUnits=%d, " 302 "searchRange=%d, entrySelector=%d, " 304 binSrchHeader->unitSize, binSrchHeader->nUnits,
305 searchRange, entrySelector, rangeShift ));
340 if ( *unitSize_p == 0 )
346 binSrchHeader.unitSize = *unitSize_p;
348 if ( *nUnits_p == 0 )
354 binSrchHeader.nUnits = *nUnits_p;
360 GXV_TRACE((
"nUnits %d\n", binSrchHeader.nUnits ));
362 gxv_BinSrchHeader_check_consistency( &binSrchHeader, valid );
364 if ( *unitSize_p == 0 )
365 *unitSize_p = binSrchHeader.unitSize;
367 if ( *nUnits_p == 0 )
368 *nUnits_p = binSrchHeader.nUnits;
383 #define GXV_LOOKUP_VALUE_LOAD( P, SIGNSPEC ) \ 384 ( P += 2, gxv_lookup_value_load( P - 2, SIGNSPEC ) ) 402 #define GXV_UNITSIZE_VALIDATE( FORMAT, UNITSIZE, NUNITS, CORRECTSIZE ) \ 404 if ( UNITSIZE != CORRECTSIZE ) \ 406 FT_ERROR(( "unitSize=%d differs from" \ 407 " expected unitSize=%d" \ 408 " in LookupTable %s\n", \ 409 UNITSIZE, CORRECTSIZE, FORMAT )); \ 410 if ( UNITSIZE != 0 && NUNITS != 0 ) \ 412 FT_ERROR(( " cannot validate anymore\n" )); \ 416 FT_ERROR(( " forcibly continues\n" )); \ 440 if ( p + 2 >= limit )
442 GXV_TRACE((
"too short, glyphs %d - %d are missing\n",
481 while ( ( p + 4 ) < valid->
root->limit )
483 if ( p[0] != 0xFF || p[1] != 0xFF ||
484 p[2] != 0xFF || p[3] != 0xFF )
511 unitSize = nUnits = 0;
517 for ( unit = 0, gid = 0; unit < nUnits; unit++ )
527 if ( lastGlyph < gid )
529 GXV_TRACE((
"reverse ordered segment specification:" 530 " lastGlyph[%d]=%d < lastGlyph[%d]=%d\n",
531 unit, lastGlyph, unit - 1 , gid ));
535 if ( lastGlyph < firstGlyph )
537 GXV_TRACE((
"reverse ordered range specification at unit %d:",
538 " lastGlyph %d < firstGlyph %d ",
539 unit, lastGlyph, firstGlyph ));
545 FT_TRACE4((
"continuing with exchanged values\n" ));
547 firstGlyph = lastGlyph;
551 for ( gid = firstGlyph; gid <= lastGlyph; gid++ )
555 gxv_LookupTable_fmt2_skip_endmarkers( p, unitSize, valid );
583 unitSize = nUnits = 0;
589 for ( unit = 0, gid = 0; unit < nUnits; unit++ )
598 if ( lastGlyph < gid )
600 GXV_TRACE((
"reverse ordered segment specification:" 601 " lastGlyph[%d]=%d < lastGlyph[%d]=%d\n",
602 unit, lastGlyph, unit - 1 , gid ));
606 if ( lastGlyph < firstGlyph )
608 GXV_TRACE((
"reverse ordered range specification at unit %d:",
609 " lastGlyph %d < firstGlyph %d ",
610 unit, lastGlyph, firstGlyph ));
616 FT_TRACE4((
"continuing with exchanged values\n" ));
618 firstGlyph = lastGlyph;
625 for ( gid = firstGlyph; gid <= lastGlyph; gid++ )
636 gxv_LookupTable_fmt2_skip_endmarkers( p, unitSize, valid );
655 if ( p[0] != 0xFF || p[1] != 0xFF )
681 unitSize = nUnits = 0;
687 for ( unit = 0, prev_glyph = 0; unit < nUnits; unit++ )
694 GXV_TRACE((
" endmarker found within defined range" 695 " (entry %d < nUnits=%d)\n",
698 if ( prev_glyph > glyph )
700 GXV_TRACE((
"current gid 0x%04x < previous gid 0x%04x\n",
701 glyph, prev_glyph ));
709 gxv_LookupTable_fmt6_skip_endmarkers( p, unitSize, valid );
742 for ( i = 0; i < glyphCount; i++ )
764 gxv_LookupTable_fmt0_validate,
766 gxv_LookupTable_fmt2_validate,
768 gxv_LookupTable_fmt4_validate,
770 gxv_LookupTable_fmt6_validate,
772 gxv_LookupTable_fmt8_validate,
819 if ( gid == 0xFFFFU )
828 GXV_TRACE((
" gxv_glyphid_check() gid overflow: num_glyphs %d < %d\n",
871 if ( !( ctl_point < n_points ) )
897 if ( name_index < min_index || max_index < name_index )
901 for (
i = 0;
i < nnames;
i++ )
906 if (
name.name_id == name_index )
910 GXV_TRACE((
" nameIndex = %d (UNTITLED)\n", name_index ));
915 FT_TRACE1((
" nameIndex = %d (", name_index ));
963 GXV_TRACE((
" (firstGlyph = %d, nGlyphs = %d)\n", firstGlyph, nGlyphs ));
979 for ( i = 0; i < nGlyphs; i++ )
994 if ( classID >= stateSize )
997 nGlyphInClass[classID]++;
1004 for ( i = 0; i < stateSize; i++ )
1005 if ( ( 3 < i ) && ( nGlyphInClass[
i] > 0 ) )
1010 GXV_TRACE((
"Declared stateSize=0x%02x, Used maxClassID=0x%02x\n",
1011 stateSize, *maxClassID_p ));
1037 GXV_TRACE((
"parse %d bytes by stateSize=%d maxClassID=%d\n",
1038 (
int)(*length_p), stateSize, (
int)(maxClassID) ));
1050 while ( p + ( 1 + maxClassID ) <= limit )
1053 for ( clazz = 0; clazz <= maxClassID; clazz++ )
1059 GXV_TRACE((
"parsed: maxState=%d, maxEntry=%d\n",
1060 *maxState_p, *maxEntry_p ));
1092 GXV_TRACE((
"maxEntry=%d entrySize=%d\n", maxEntry, entrySize ));
1094 if ( ( maxEntry + 1 ) * entrySize > *length_p )
1099 maxEntry = (
FT_Byte)( *length_p / entrySize - 1 );
1100 GXV_TRACE((
"too large maxEntry, shrinking to %d fit EntryTable length\n",
1104 for ( entry = 0; entry <= maxEntry; entry++ )
1115 if ( newState < stateArray ||
1116 stateArray + stateArray_length < newState )
1118 GXV_TRACE((
" newState offset 0x%04x is out of stateArray\n",
1124 if ( 0 != ( ( newState - stateArray ) % ( 1 + maxClassID ) ) )
1126 GXV_TRACE((
" newState offset 0x%04x is not aligned to %d-classes\n",
1127 newState, 1 + maxClassID ));
1132 state = (
FT_Byte)( ( newState - stateArray ) / ( 1 + maxClassID ) );
1205 l[0] = classTable_length_p;
1206 l[1] = stateArray_length_p;
1207 l[2] = entryTable_length_p;
1245 GXV_TRACE((
"stateSize=0x%04x\n", stateSize ));
1246 GXV_TRACE((
"offset to classTable=0x%04x\n", classTable ));
1247 GXV_TRACE((
"offset to stateArray=0x%04x\n", stateArray ));
1248 GXV_TRACE((
"offset to entryTable=0x%04x\n", entryTable ));
1250 if ( stateSize > 0xFF )
1270 GXV_TRACE((
"StateTable Subtables\n" ));
1272 if ( classTable != 0 )
1273 gxv_ClassTable_validate(
table + classTable,
1279 maxClassID = (
FT_Byte)( stateSize - 1 );
1281 if ( stateArray != 0 )
1282 gxv_StateArray_validate(
table + stateArray,
1295 if ( maxEntry > 0 && entryTable == 0 )
1298 if ( entryTable != 0 )
1299 gxv_EntryTable_validate(
table + entryTable,
1333 l[0] = classTable_length_p;
1334 l[1] = stateArray_length_p;
1335 l[2] = entryTable_length_p;
1342 gxv_XClassTable_lookupval_validate(
FT_UShort glyph,
1382 gxv_XClassTable_lookupfmt4_transit(
FT_UShort relative_gindex,
1397 limit = lookuptbl_limit;
1425 GXV_TRACE((
"parse % 3d bytes by stateSize=% 3d maxClassID=% 3d\n",
1426 (
int)(*length_p), stateSize, (
int)(maxClassID) ));
1438 while ( p + ( ( 1 + maxClassID ) * 2 ) <= limit )
1441 for ( clazz = 0; clazz <= maxClassID; clazz++ )
1447 GXV_TRACE((
"parsed: maxState=%d, maxEntry=%d\n",
1448 *maxState_p, *maxEntry_p ));
1450 *length_p = p -
table;
1474 GXV_TRACE((
"maxEntry=%d entrySize=%d\n", maxEntry, entrySize ));
1476 if ( ( p + ( maxEntry + 1 ) * entrySize ) > limit )
1479 for (entry = 0; entry <= maxEntry ; entry++ )
1490 if ( stateArray_length < (
FT_ULong)( newState_idx * 2 ) )
1492 GXV_TRACE((
" newState index 0x%04x points out of stateArray\n",
1497 state = (
FT_UShort)( newState_idx / ( 1 + maxClassID ) );
1498 if ( 0 != ( newState_idx % ( 1 + maxClassID ) ) )
1500 FT_TRACE4((
"-> new state = %d (supposed)\n" 1501 "but newState index 0x%04x is not aligned to %d-classes\n",
1502 state, newState_idx, 1 + maxClassID ));
1551 *length_p = p -
table;
1589 GXV_TRACE((
"offset to classTable=0x%08x\n", classTable ));
1590 GXV_TRACE((
"offset to stateArray=0x%08x\n", stateArray ));
1591 GXV_TRACE((
"offset to entryTable=0x%08x\n", entryTable ));
1596 GXV_TRACE((
"StateTable Subtables\n" ));
1615 if ( classTable != 0 )
1622 table + classTable + classTable_length,
1634 if ( stateArray != 0 )
1635 gxv_XStateArray_validate(
table + stateArray,
1648 if ( maxEntry > 0 && entryTable == 0 )
1651 if ( entryTable != 0 )
1652 gxv_XEntryTable_validate(
table + entryTable,
1674 gxv_compare_ranges(
FT_Bytes table1_start,
1679 if ( table1_start == table2_start )
1681 if ( ( table1_length == 0 || table2_length == 0 ) )
1684 else if ( table1_start < table2_start )
1686 if ( ( table1_start + table1_length ) <= table2_start )
1689 else if ( table1_start > table2_start )
1691 if ( ( table1_start >= table2_start + table2_length ) )
1707 odtect->range[odtect->nRanges].start =
start;
1708 odtect->range[odtect->nRanges].length =
length;
1723 for (
i = 0;
i < odtect->nRanges;
i++ )
1724 for ( j = 0; j <
i; j++ )
1725 if ( 0 != gxv_compare_ranges( odtect->range[
i].start,
1726 odtect->range[
i].length,
1727 odtect->range[j].start,
1728 odtect->range[j].length ) )
1730 if ( odtect->range[
i].name || odtect->range[j].name )
1731 GXV_TRACE((
"found overlap between range %d and range %d\n",
1734 GXV_TRACE((
"found overlap between `%s' and `%s\'\n",
1735 odtect->range[
i].name,
1736 odtect->range[j].name ));
GLenum GLuint GLenum GLsizei length
struct GXV_BinSrchHeader_ GXV_BinSrchHeader
GLboolean GLboolean GLboolean GLboolean a
#define FT_NEXT_LONG(buffer)
GXV_StateTable_Subtable_Setup_Func subtable_setup_func
gxv_ctlPoint_validate(FT_UShort gid, FT_Short ctl_point, GXV_Validator valid)
#define FT_INVALID_FORMAT
#define GXV_NAME_ENTER(name)
#define FT_NEXT_BYTE(buffer)
gxv_XStateTable_validate(FT_Bytes table, FT_Bytes limit, GXV_Validator valid)
#define FT_INVALID_TOO_SHORT
gxv_XStateTable_subtable_setup(FT_ULong table_size, FT_ULong classTable, FT_ULong stateArray, FT_ULong entryTable, FT_ULong *classTable_length_p, FT_ULong *stateArray_length_p, FT_ULong *entryTable_length_p, GXV_Validator valid)
gxv_BinSrchHeader_validate(FT_Bytes table, FT_Bytes limit, FT_UShort *unitSize_p, FT_UShort *nUnits_p, GXV_Validator valid)
#define GXV_GLYPHOFFSET_FMT(table)
GLboolean GLboolean GLboolean b
#define GXV_SET_ERR_IF_PARANOID(err)
GXV_XStateTable_Entry_Validate_Func entry_validate_func
#define FT_TRACE1(varformat)
GLenum GLuint GLint GLenum face
GXV_StateTable_Entry_Validate_Func entry_validate_func
#define GXV_LOOKUP_VALUE_LOAD(P, SIGNSPEC)
FT_Load_Glyph(FT_Face face, FT_UInt glyph_index, FT_Int32 load_flags)
#define FT_TRACE4(varformat)
#define GXV_GLYPHOFFSET_SIZE(table)
GXV_StateTable_ValidatorRec statetable
GXV_StateTable_OptData_Load_Func optdata_load_func
gxv_sfntName_validate(FT_UShort name_index, FT_UShort min_index, FT_UShort max_index, GXV_Validator valid)
float min(float a, float b)
GLenum const GLvoid GLbitfield GLuint firstGlyph
GXV_XStateTable_Subtable_Setup_Func subtable_setup_func
#define GXV_UNITSIZE_VALIDATE(FORMAT, UNITSIZE, NUNITS, CORRECTSIZE)
GXV_XStateTable_ValidatorRec xstatetable
FT_Get_Sfnt_Name(FT_Face face, FT_UInt idx, FT_SfntName *aname)
GLsizei const GLfloat * value
gxv_odtect_validate(GXV_odtect_Range odtect, GXV_Validator valid)
gxv_LookupTable_validate(FT_Bytes table, FT_Bytes limit, GXV_Validator valid)
GLuint const GLchar * name
#define FT_NEXT_USHORT(buffer)
FT_BEGIN_HEADER struct FT_SfntName_ FT_SfntName
GXV_XStateTable_OptData_Load_Func optdata_load_func
#define FT_INVALID_OFFSET
gxv_StateTable_subtable_setup(FT_UShort table_size, FT_UShort classTable, FT_UShort stateArray, FT_UShort entryTable, FT_UShort *classTable_length_p, FT_UShort *stateArray_length_p, FT_UShort *entryTable_length_p, GXV_Validator valid)
gxv_set_length_by_ushort_offset(FT_UShort *offset, FT_UShort **length, FT_UShort *buff, FT_UInt nmemb, FT_UShort limit, GXV_Validator valid)
gxv_array_getlimits_byte(FT_Bytes table, FT_Bytes limit, FT_Byte *min, FT_Byte *max, GXV_Validator valid)
void(* GXV_XStateTable_Subtable_Setup_Func)(FT_ULong table_size, FT_ULong classTable, FT_ULong stateArray, FT_ULong entryTable, FT_ULong *classTable_length_p, FT_ULong *stateArray_length_p, FT_ULong *entryTable_length_p, GXV_Validator valid)
#define FT_NEXT_ULONG(buffer)
GXV_Lookup_Fmt4_Transit_Func lookupfmt4_trans
FT_Get_Sfnt_Name_Count(FT_Face face)
#define FT_INVALID_GLYPH_ID
#define FT_NEXT_SHORT(buffer)
void(* GXV_Validate_Func)(FT_Bytes table, FT_Bytes limit, GXV_Validator valid)
#define FT_LOAD_NO_BITMAP
GXV_Lookup_Value_Validate_Func lookupval_func
GXV_LookupValue_SignSpec lookupval_sign
gxv_odtect_add_range(FT_Bytes start, FT_ULong length, const FT_String *name, GXV_odtect_Range odtect)
#define FT_LOAD_IGNORE_TRANSFORM
GLenum GLsizei GLenum GLenum const GLvoid * table
gxv_StateTable_validate(FT_Bytes table, FT_Bytes limit, GXV_Validator valid)
#define FT_NEXT_CHAR(buffer)
gxv_glyphid_validate(FT_UShort gid, GXV_Validator valid)
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
gxv_array_getlimits_ushort(FT_Bytes table, FT_Bytes limit, FT_UShort *min, FT_UShort *max, GXV_Validator valid)
#define GXV_TRACE_HEXDUMP_SFNTNAME(n)
gxv_set_length_by_ulong_offset(FT_ULong *offset, FT_ULong **length, FT_ULong *buff, FT_UInt nmemb, FT_ULong limit, GXV_Validator valid)
#define GXV_LIMIT_CHECK(_count)
void(* GXV_StateTable_Subtable_Setup_Func)(FT_UShort table_size, FT_UShort classTable, FT_UShort stateArray, FT_UShort entryTable, FT_UShort *classTable_length_p, FT_UShort *stateArray_length_p, FT_UShort *entryTable_length_p, GXV_Validator valid)