Hi all, Following to the recent proposed change to enable the trickyness check by sfnt table checksum always, I propose to register a set of tricky fonts by NEC. They have no ASCII family names (in fact, they include SJIS and UCS-2 name tables only, no English name table), so my proposal update the checksum list only.
Considering that the number of blacklist is increased to 13, I changed the algorithm to compare the checksums slightly. It seems that the fonts are not so popular, so this is not urgent issue. Please give me comment. Regards, mpsuzuki diff --git a/src/truetype/ttobjs.c b/src/truetype/ttobjs.c index 349547a..fa6add4 100644 --- a/src/truetype/ttobjs.c +++ b/src/truetype/ttobjs.c @@ -238,19 +238,28 @@ } tt_sfnt_id_rec; - static FT_Bool - tt_check_trickyness_sfnt_ids( TT_Face face ) + static void + tt_copy_face_table_to_sfnt_id( tt_sfnt_id_rec* sfnt_id, + FT_UInt id_index, + TT_Face face, + FT_UInt table_index ) { -#define TRICK_SFNT_IDS_PER_FACE 3 -#define TRICK_SFNT_IDS_NUM_FACES 5 + sfnt_id[id_index].Length = face->dir_tables[table_index].Length; + sfnt_id[id_index].CheckSum = tt_get_sfnt_checksum( face, + table_index ); + } - static const tt_sfnt_id_rec sfnt_id[TRICK_SFNT_IDS_NUM_FACES] - [TRICK_SFNT_IDS_PER_FACE] = { + static FT_Bool + tt_check_trickyness_sfnt_ids( TT_Face face ) + { #define TRICK_SFNT_ID_cvt 0 #define TRICK_SFNT_ID_fpgm 1 #define TRICK_SFNT_ID_prep 2 +#define TRICK_SFNT_IDS_PER_FACE 3 + static const tt_sfnt_id_rec sfnt_id[] + [TRICK_SFNT_IDS_PER_FACE] = { { /* MingLiU 1995 */ { 0x05bcf058, 0x000002e4 }, /* cvt */ { 0x28233bf1, 0x000087c4 }, /* fpgm */ @@ -275,51 +284,90 @@ { 0xfffbfffc, 0x00000008 }, /* cvt */ { 0x0a5a0483, 0x00017c39 }, /* fpgm */ { 0x70020112, 0x00000008 } /* prep */ + }, + { /* NEC fadpop7.ttf */ + { 0x00000000, 0x00000000 }, /* cvt */ + { 0x40c92555, 0x000000e5 }, /* fpgm */ + { 0xa39b58e3, 0x0000117c } /* prep */ + }, + { /* NEC fadrei5.ttf */ + { 0x00000000, 0x00000000 }, /* cvt */ + { 0x33c41652, 0x000000e5 }, /* fpgm */ + { 0x26d6c52a, 0x00000f6a } /* prep */ + }, + { /* NEC fangot5.ttc */ + { 0x00000000, 0x00000000 }, /* cvt */ + { 0x40aa774c, 0x000001cb }, /* fpgm */ + { 0x9b5caa96, 0x00001f9a } /* prep */ + }, + { /* NEC fangot7.ttf */ + { 0x00000000, 0x00000000 }, /* cvt */ + { 0x6db1651d, 0x0000019d }, /* fpgm */ + { 0x6c6e4b03, 0x00002492 } /* prep */ + }, + { /* NEC fangyo5.ttf */ + { 0x00000000, 0x00000000 }, /* cvt */ + { 0x40c92555, 0x000000e5 }, /* fpgm */ + { 0xde51fad0, 0x0000117c } /* prep */ + }, + { /* NEC fankyo5.ttf */ + { 0x00000000, 0x00000000 }, /* cvt */ + { 0x85e47664, 0x000000e5 }, /* fpgm */ + { 0xa6c62831, 0x00001caa } /* prep */ + }, + { /* NEC fanmin3.ttc */ + { 0x00000000, 0x00000000 }, /* cvt */ + { 0x0d3de9cb, 0x00000141 }, /* fpgm */ + { 0xd4127766, 0x00002280 } /* prep */ + }, + { /* NEC fanrgo5.ttf */ + { 0x00000000, 0x00000000 }, /* cvt */ + { 0x2d891cfd, 0x0000019d }, /* fpgm */ + { 0xa0604633, 0x00001de8 } /* prep */ } }; - FT_ULong checksum; - int num_matched_ids[TRICK_SFNT_IDS_NUM_FACES]; - int i, j, k; +#define TRICK_SFNT_IDS_NUM_FACES \ + ( sizeof( sfnt_id ) \ + / ( sizeof( tt_sfnt_id_rec ) * TRICK_SFNT_IDS_PER_FACE ) ) + + tt_sfnt_id_rec this_face_id[TRICK_SFNT_IDS_PER_FACE]; + int i; - FT_MEM_SET( num_matched_ids, 0, - sizeof( int ) * TRICK_SFNT_IDS_NUM_FACES ); + FT_MEM_SET( this_face_id, 0, sizeof( this_face_id ) ); for ( i = 0; i < face->num_tables; i++ ) { - checksum = 0; - switch( face->dir_tables[i].Tag ) { case TTAG_cvt: - k = TRICK_SFNT_ID_cvt; + tt_copy_face_table_to_sfnt_id( this_face_id, + TRICK_SFNT_ID_cvt, + face, i ); break; case TTAG_fpgm: - k = TRICK_SFNT_ID_fpgm; + tt_copy_face_table_to_sfnt_id( this_face_id, + TRICK_SFNT_ID_fpgm, + face, i ); break; case TTAG_prep: - k = TRICK_SFNT_ID_prep; + tt_copy_face_table_to_sfnt_id( this_face_id, + TRICK_SFNT_ID_prep, + face, i ); break; default: continue; } + } - for ( j = 0; j < TRICK_SFNT_IDS_NUM_FACES; j++ ) - if ( face->dir_tables[i].Length == sfnt_id[j][k].Length ) - { - if ( !checksum ) - checksum = tt_get_sfnt_checksum( face, i ); - - if ( sfnt_id[j][k].CheckSum == checksum ) - num_matched_ids[j]++; - - if ( num_matched_ids[j] == TRICK_SFNT_IDS_PER_FACE ) - return TRUE; - } + for ( i = 0; i < TRICK_SFNT_IDS_NUM_FACES; i++ ) + { + if ( !ft_memcmp( this_face_id, sfnt_id[i], sizeof( this_face_id ) ) ) + return TRUE; } return FALSE; _______________________________________________ Freetype-devel mailing list Freetype-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/freetype-devel