>> Have you actually done binary searches in TTFs to find signatures? > > Well, only using the code here, not with a hex editor. I have seen > hits in some TTF files where I would not have expected them. May > speak to the issues you mentioned below.
OK. So it's definitely worth some tests :-) >> [...] I think it is best if you extend the code so that the >> function number is also checked to avoid false hits. > > Yes, this makes sense for functions where we know the number, such > as ttfautohint and 0. Well, most of the bytecode snippets are associated with one or more fixed function numbers. > But, I think the whitepaper states that on (at least some) > functions, the number varies, which is why you need the detection > code in the first place. Correct. My concern is that we get false hits due to the shortness of the snippets. > Regarding the problems with the opcode patterns, what did you see > that was incorrect? From scanning them (quickly) it seemed like it > was mostly correct (perhaps missing the end IF, etc.) Ah, I see that I've done a mistake, below is a corrected patch (untested). However, I think that the current method is flawed in general since arguments to opcodes are completely ignored by `SKIP_Code'. For example, it is not possible to decide whether the bytecode is SVTCA_x PUSHB_1 24 RS IF or SVTCA_x PUSHB_1 39 RS IF It seems to me that we really have to compare the *complete* bytecode (including the arguments) within `Ins_FDEF'. Werner
diff --git a/src/truetype/ttinterp.c b/src/truetype/ttinterp.c index 505168d..ebd433c 100644 --- a/src/truetype/ttinterp.c +++ b/src/truetype/ttinterp.c @@ -4610,25 +4610,91 @@ FT_ULong n; TT_DefRecord* rec; TT_DefRecord* limit; + #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING + /* arguments to opcodes are skipped by `SKIP_Code' */ FT_Byte opcode_pattern[7][12] = { - /* inline delta function 1 */ - {0x4B,0x53,0x23,0x4B,0x51,0x5A,0x58,0x38,0x1B,0x21,0x21,0x59}, - /* inline delta function 2 */ - {0x4B,0x54,0x58,0x38,0x1B,0x5A,0x21,0x21,0x59,}, - /* diagonal stroke function */ - {0x20,0x20,0x40,0x60,0x47,0x40,0x23,0x42,}, - /* VacuFormRound function */ - {0x45,0x23,0x46,0x60,0x20,}, - /* ttfautohinted */ - {0x20,0x64,0xb0,0x60,0x66,0x23,0xb0,}, - /* spacing functions */ - {0x01,0x41,0x43,0x58,}, - {0x01,0x18,0x41,0x43,0x58,}, + /* #0 inline delta function 1 */ + { + 0x4B, /* PPEM */ + 0x53, /* GTEQ */ + 0x23, /* SWAP */ + 0x4B, /* PPEM */ + 0x51, /* LTEQ */ + 0x5A, /* AND */ + 0x58, /* IF */ + 0x38, /* SHPIX */ + 0x1B, /* ELSE */ + 0x21, /* POP */ + 0x21, /* POP */ + 0x59 /* EIF */ + }, + /* #1 inline delta function 2 */ + { + 0x4B, /* PPEM */ + 0x54, /* EQ */ + 0x58, /* IF */ + 0x38, /* SHPIX */ + 0x1B, /* ELSE */ + 0x21, /* POP */ + 0x21, /* POP */ + 0x59 /* EIF */ + }, + /* #2 diagonal stroke function */ + { + 0x20, /* DUP */ + 0x20, /* DUP */ + 0xB0, /* PUSHB_1 */ + /* 1 */ + 0x60, /* ADD */ + 0x46, /* GC_cur */ + 0xB0, /* PUSHB_1 */ + /* 64 */ + 0x23, /* SWAP */ + 0x42 /* WS */ + }, + /* #3 VacuFormRound function */ + { + 0x45, /* RCVT */ + 0x23, /* SWAP */ + 0x46, /* GC_cur */ + 0x60, /* ADD */ + 0x20, /* DUP */ + 0xB0 /* PUSHB_1 */ + /* 38 */ + }, + /* #4 TTFautohint bytecode (old) */ + { + 0x20, /* DUP */ + 0x64, /* ABS */ + 0xB0, /* PUSHB_1 */ + /* 32 */ + 0x60, /* ADD */ + 0x66, /* FLOOR */ + 0x23, /* SWAP */ + 0xB0 /* PUSHB_1 */ + }, + /* #5 spacing function 1 */ + { + 0x01, /* SVTCA_x */ + 0xB0, /* PUSHB_1 */ + /* 24 */ + 0x43, /* RS */ + 0x58 /* IF */ + }, + /* #6 spacing function 2 */ + { + 0x01, /* SVTCA_x */ + 0x18, /* RTG */ + 0xB0, /* PUSHB_1 */ + /* 24 */ + 0x43, /* RS */ + 0x58 /* IF */ + }, }; FT_UShort opcode_patterns = 7; - FT_UShort opcode_pointer[7] = {0,0,0,0,0,0,0}; - FT_UShort opcode_size[7] = {12,9,8,5,7,4,5}; + FT_UShort opcode_pointer[7] = { 0, 0, 0, 0, 0, 0, 0 }; + FT_UShort opcode_size[7] = { 12, 8, 8, 6, 7, 4, 5 }; FT_UShort i; #endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
_______________________________________________ Freetype-devel mailing list Freetype-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/freetype-devel