31 #include FT_SFNT_NAMES_H 32 #include FT_SERVICE_GX_VALIDATE_H 42 #define FT_COMPONENT trace_gxvkern 71 typedef struct GXV_kern_DataRec_
80 #define GXV_KERN_DATA( field ) GXV_TABLE_DATA( kern, field ) 82 #define KERN_IS_CLASSIC( valid ) \ 83 ( KERN_VERSION_CLASSIC == GXV_KERN_DATA( version ) ) 84 #define KERN_IS_NEW( valid ) \ 85 ( KERN_VERSION_NEW == GXV_KERN_DATA( version ) ) 87 #define KERN_DIALECT( valid ) \ 88 GXV_KERN_DATA( dialect_request ) 89 #define KERN_ALLOWS_MS( valid ) \ 90 ( KERN_DIALECT( valid ) & KERN_DIALECT_MS ) 91 #define KERN_ALLOWS_APPLE( valid ) \ 92 ( KERN_DIALECT( valid ) & KERN_DIALECT_APPLE ) 94 #define GXV_KERN_HEADER_SIZE ( KERN_IS_NEW( valid ) ? 8 : 4 ) 95 #define GXV_KERN_SUBTABLE_HEADER_SIZE ( KERN_IS_NEW( valid ) ? 8 : 6 ) 126 for ( i = 0; i < nPairs; i++ )
130 #ifdef GXV_LOAD_UNUSED_VARS 144 GXV_TRACE((
"left gid = %u, right gid = %u\n", gid_left, gid_right ));
145 if ( gid_left == last_gid_left )
147 if ( last_gid_right < gid_right )
148 last_gid_right = gid_right;
152 else if ( last_gid_left < gid_left )
154 last_gid_left = gid_left;
155 last_gid_right = gid_right;
161 #ifdef GXV_LOAD_UNUSED_VARS 184 unitSize = 2 + 2 + 2;
192 gxv_kern_subtable_fmt0_pairs_validate( p,
limit, nPairs, valid );
201 typedef struct GXV_kern_fmt1_StateOptRec_
228 gxv_kern_subtable_fmt1_subtable_setup(
FT_UShort table_size,
248 o[3] = optdata->valueTable;
249 l[0] = classTable_length_p;
250 l[1] = stateArray_length_p;
251 l[2] = entryTable_length_p;
252 l[3] = &(optdata->valueTable_length);
262 gxv_kern_subtable_fmt1_entry_validate(
270 #ifdef GXV_LOAD_UNUSED_VARS 275 #ifdef GXV_LOAD_UNUSED_VARS 284 #ifdef GXV_LOAD_UNUSED_VARS 296 if ( valueOffset < vt_rec->valueTable )
300 limit =
table + vt_rec->valueTable + vt_rec->valueTable_length;
303 #ifdef GXV_LOAD_UNUSED_VARS 327 gxv_kern_subtable_fmt1_valueTable_load;
329 gxv_kern_subtable_fmt1_subtable_setup;
333 gxv_kern_subtable_fmt1_entry_validate;
355 typedef struct GXV_kern_subtable_fmt2_DataRec_
367 #define GXV_KERN_FMT2_DATA( field ) \ 368 ( ( (GXV_kern_subtable_fmt2_DataRec *) \ 369 ( GXV_KERN_DATA( subtable_data ) ) )->field ) 393 GXV_TRACE((
" %s firstGlyph=%d, nGlyphs=%d\n",
394 tag, firstGlyph, nGlyphs ));
417 { 0, 0, { 0, 0 }, { 0, 0 }, {
"leftClass",
"rightClass" },
NULL };
427 fmt2_rec.odtect = odtect;
443 gxv_kern_subtable_fmt2_clstbl_validate(
table + leftOffsetTable,
limit,
446 gxv_kern_subtable_fmt2_clstbl_validate(
table + rightOffsetTable,
limit,
492 GXV_TRACE((
"maxGID=%d, but glyphCount=%d\n",
498 GXV_TRACE((
"kern subtable fmt3 has nonzero value" 499 " (%d) in unused flag\n", flags ));
504 p += 2 * kernValueCount;
517 if ( leftClassCount < max )
532 if ( rightClassCount < max )
543 for ( i = 0; i < leftClassCount; i++ )
545 for ( j = 0; j < rightClassCount; j++ )
561 gxv_kern_coverage_new_apple_validate(
FT_UShort coverage,
566 #ifdef GXV_LOAD_TRACE_VARS 576 if ( coverage & 0x1FFC )
579 #ifdef GXV_LOAD_TRACE_VARS 580 kernVertical =
FT_BOOL( ( coverage >> 15 ) & 1 );
581 kernCrossStream =
FT_BOOL( ( coverage >> 14 ) & 1 );
582 kernVariation =
FT_BOOL( ( coverage >> 13 ) & 1 );
588 "horizontal=%d, cross-stream=%d, variation=%d, format=%d\n",
589 !kernVertical, kernCrossStream, kernVariation, *
format ));
591 GXV_TRACE((
"kerning values in Apple format subtable are ignored\n" ));
598 gxv_kern_coverage_classic_apple_validate(
FT_UShort coverage,
603 #ifdef GXV_LOAD_TRACE_VARS 614 if ( coverage & 0x02FC )
617 #ifdef GXV_LOAD_TRACE_VARS 618 horizontal =
FT_BOOL( ( coverage >> 15 ) & 1 );
619 cross_stream =
FT_BOOL( ( coverage >> 13 ) & 1 );
625 "horizontal=%d, cross-stream=%d, format=%d\n",
626 horizontal, cross_stream, *
format ));
632 GXV_TRACE((
"kerning values in Apple format subtable are ignored\n" ));
639 gxv_kern_coverage_classic_microsoft_validate(
FT_UShort coverage,
644 #ifdef GXV_LOAD_TRACE_VARS 655 if ( coverage & 0xFDF0 )
658 #ifdef GXV_LOAD_TRACE_VARS 659 horizontal =
FT_BOOL( coverage & 1 );
660 minimum =
FT_BOOL( ( coverage >> 1 ) & 1 );
661 cross_stream =
FT_BOOL( ( coverage >> 2 ) & 1 );
662 override =
FT_BOOL( ( coverage >> 3 ) & 1 );
667 GXV_TRACE((
"classic Microsoft-dialect: " 668 "horizontal=%d, minimum=%d, cross-stream=%d, " 669 "override=%d, format=%d\n",
670 horizontal, minimum, cross_stream,
override, *
format ));
674 "kerning values in Microsoft format 2 subtable are ignored\n" ));
689 gxv_kern_coverage_validate(
FT_UShort coverage,
698 GXV_TRACE((
"interprete coverage 0x%04x by Apple style\n", coverage ));
702 if ( gxv_kern_coverage_new_apple_validate( coverage,
713 if ( gxv_kern_coverage_classic_apple_validate( coverage,
724 if ( gxv_kern_coverage_classic_microsoft_validate( coverage,
733 GXV_TRACE((
"cannot interprete coverage, broken kern subtable\n" ));
747 #ifdef GXV_LOAD_TRACE_VARS 752 #ifdef GXV_LOAD_TRACE_VARS 766 switch ( gxv_kern_coverage_validate( coverage, &format, valid ) )
769 #ifdef GXV_LOAD_TRACE_VARS 773 #ifdef GXV_LOAD_TRACE_VARS 776 GXV_TRACE((
"Subtable version = %d\n", version ));
777 GXV_TRACE((
"Subtable length = %d\n", length ));
781 #ifdef GXV_LOAD_TRACE_VARS 784 length = ( u16[0] << 16 ) + u16[1];
785 #ifdef GXV_LOAD_TRACE_VARS 788 GXV_TRACE((
"Subtable length = %d\n", length ));
793 #ifdef GXV_LOAD_TRACE_VARS 798 GXV_TRACE((
"Subtable tupleIndex = %d\n", tupleIndex ));
804 GXV_TRACE((
"cannot detect subtable dialect, " 805 "just skip %d byte\n", length ));
811 gxv_kern_subtable_fmt0_validate(
table,
table + length, valid );
812 else if ( format == 1 )
813 gxv_kern_subtable_fmt1_validate(
table,
table + length, valid );
814 else if ( format == 2 )
815 gxv_kern_subtable_fmt2_validate(
table,
table + length, valid );
816 else if ( format == 3 )
817 gxv_kern_subtable_fmt3_validate(
table,
table + length, valid );
855 valid->
root = ftvalid;
859 FT_TRACE3((
"validating `kern' table\n" ));
865 GXV_TRACE((
"version 0x%04x (higher 16bit)\n",
887 for ( i = 0; i < nTables; i++ )
889 GXV_TRACE((
"validating subtable %d/%d\n", i, nTables ));
891 gxv_kern_subtable_validate( p, 0, valid );
918 gxv_kern_validate_generic(
table, face, 1, dialect_request, ftvalid );
GLenum GLuint GLenum GLsizei length
#define GXV_KERN_SUBTABLE_HEADER_SIZE
local int push(void *desc, unsigned char *buf, unsigned len)
enum GXV_kern_ClassSpec_ GXV_kern_ClassSpec
#define FT_VALIDATE_APPLE
struct GXV_kern_subtable_fmt2_DataRec_ * GXV_kern_subtable_fmt2_Data
GXV_StateTable_Subtable_Setup_Func subtable_setup_func
#define FT_INVALID_FORMAT
#define GXV_NAME_ENTER(name)
#define KERN_DIALECT(valid)
#define FT_NEXT_BYTE(buffer)
struct GXV_kern_DataRec_ GXV_kern_DataRec
#define GXV_ODTECT(n, odtect)
gxv_BinSrchHeader_validate(FT_Bytes table, FT_Bytes limit, FT_UShort *unitSize_p, FT_UShort *nUnits_p, GXV_Validator valid)
FT_BEGIN_HEADER typedef unsigned char FT_Bool
#define GXV_SET_ERR_IF_PARANOID(err)
GLenum GLuint GLint GLenum face
GXV_StateTable_Entry_Validate_Func entry_validate_func
enum GXV_kern_Version_ GXV_kern_Version
#define FT_TRACE4(varformat)
#define KERN_IS_CLASSIC(valid)
enum GXV_kern_Dialect_ GXV_kern_Dialect
GXV_StateTable_ValidatorRec statetable
GXV_GlyphOffset_Format entry_glyphoffset_fmt
struct GXV_kern_fmt1_StateOptRec_ * GXV_kern_fmt1_StateOptRecData
GXV_StateTable_OptData_Load_Func optdata_load_func
#define GXV_KERN_FMT2_DATA(field)
float min(float a, float b)
GLenum const GLvoid GLbitfield GLuint firstGlyph
#define KERN_ALLOWS_MS(valid)
typedefFT_BEGIN_HEADER struct FT_ValidatorRec_ volatile * FT_Validator
#define GXV_ODTECT_INIT(odtect)
gxv_kern_validate(FT_Bytes table, FT_Face face, FT_Validator ftvalid)
gxv_odtect_validate(GXV_odtect_Range odtect, GXV_Validator valid)
#define FT_NEXT_USHORT(buffer)
if(!abbox) return FT_THROW(Invalid_Argument)
#define FT_TRACE3(varformat)
#define FT_INVALID_OFFSET
#define KERN_ALLOWS_APPLE(valid)
#define FT_VALIDATE_CKERN
gxv_set_length_by_ushort_offset(FT_UShort *offset, FT_UShort **length, FT_UShort *buff, FT_UInt nmemb, FT_UShort limit, GXV_Validator valid)
struct GXV_kern_DataRec_ * GXV_kern_Data
gxv_array_getlimits_byte(FT_Bytes table, FT_Bytes limit, FT_Byte *min, FT_Byte *max, GXV_Validator valid)
#define FT_NEXT_ULONG(buffer)
gxv_kern_validate_classic(FT_Bytes table, FT_Face face, FT_Int dialect_flags, FT_Validator ftvalid)
struct GXV_kern_fmt1_StateOptRec_ GXV_kern_fmt1_StateOptRec
#define FT_INVALID_GLYPH_ID
#define FT_NEXT_SHORT(buffer)
gxv_odtect_add_range(FT_Bytes start, FT_ULong length, const FT_String *name, GXV_odtect_Range odtect)
GLenum GLsizei GLenum GLenum const GLvoid * table
unsigned short u16
16 bits unsigned integer
gxv_StateTable_validate(FT_Bytes table, FT_Bytes limit, GXV_Validator valid)
#define GXV_KERN_DATA(field)
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 KERN_IS_NEW(valid)
#define GXV_LIMIT_CHECK(_count)
struct GXV_kern_subtable_fmt2_DataRec_ GXV_kern_subtable_fmt2_DataRec