Support decode/encoding of unknown glyf hinting instructions
New instructions can be defined in the prep program. We don't
check that the "unknown" instruction was actually defined. Just
pass it through.
Fixes ttx with Skia.ttf on the Mac OS X.
Fixes https://github.com/behdad/fonttools/issues/21
diff --git a/Lib/fontTools/ttLib/tables/ttProgram.py b/Lib/fontTools/ttLib/tables/ttProgram.py
index 065984a..0863c29 100644
--- a/Lib/fontTools/ttLib/tables/ttProgram.py
+++ b/Lib/fontTools/ttLib/tables/ttProgram.py
@@ -285,7 +285,11 @@
continue
arg = strip(arg)
- if mnemonic not in ("NPUSHB", "NPUSHW", "PUSHB", "PUSHW"):
+ if mnemonic.startswith("INSTR"):
+ # Unknown instruction
+ op = int(mnemonic[5:])
+ push(op)
+ elif mnemonic not in ("NPUSHB", "NPUSHW", "PUSHB", "PUSHW"):
op, argBits = mnemonicDict[mnemonic]
if len(arg) <> argBits:
raise tt_instructions_error, "Incorrect number of argument bits (%s[%s])" % (mnemonic, arg)
@@ -383,7 +387,8 @@
assembly.append(`value`)
i = i + 2
else:
- raise tt_instructions_error, "illegal opcode: 0x%.2x" % op
+ assembly.append("INSTR%d[ ]" % op)
+ i = i + 1
else:
if argBits:
assembly.append(mnemonic + "[%s]" % num2binary(op - argoffset, argBits))