[instancer/CFF2] Micro-optimize commands

This commit is contained in:
Behdad Esfahbod 2024-05-14 13:38:18 -06:00
parent 1011d7e996
commit b3dc48a967
2 changed files with 9 additions and 2 deletions

View File

@ -751,7 +751,10 @@ def instantiateCFF2(
# Empty out the VarStore
for i, varData in enumerate(varStore.VarData):
assert varDataCursor[i] == varData.ItemCount, (varDataCursor[i], varData.ItemCount)
assert varDataCursor[i] == varData.ItemCount, (
varDataCursor[i],
varData.ItemCount,
)
varData.Item = []
varData.ItemCount = 0
@ -779,6 +782,11 @@ def instantiateCFF2(
if command[0] == "vsindex":
command[1][0] = vsindexMapping[command[1][0]]
# Remove initial vsindex commands that are implied
for commands in allCommands:
if commands and commands[0] == ("vsindex", [0]):
commands.pop(0)
# Ship the charstrings!
for cs, commands in zip(charStrings, allCommands):
cs.program = commandsToProgram(commands)

View File

@ -183,7 +183,6 @@
<CharString name=".notdef">
</CharString>
<CharString name="A">
0 vsindex
9 30 1 blend
hmoveto
122 31 1 blend