Fix bug in subsetting T2 CharStrings from CFF font. The logic seeks to avoid unnecessarily executing subroutines that have already been subroutinized. It is necessary execute all subroutines when counting hints in order to determine the byte length of mask arguments, but we want to quit doing this when we know that counting hints is no longer necessary,. The previous logic stopped when a [vh]stem operator was seen, as this means there will not be need for hintmask mask arguments However, the [vh]stem operators can be used even when there is a cntrmask, so the logic stopped counting hints too early.

This commit is contained in:
ReadRoberts 2019-04-30 09:43:13 -07:00
parent 06e44e8503
commit dbcdde1bee

View File

@ -366,7 +366,7 @@ class StopHintCountEvent(Exception):
class _DesubroutinizingT2Decompiler(psCharStrings.SimpleT2Decompiler):
stop_hintcount_ops = ("op_hstem", "op_vstem", "op_rmoveto", "op_hmoveto",
stop_hintcount_ops = ("op_hintmask", "op_cntrmask", "op_rmoveto", "op_hmoveto",
"op_vmoveto")
def __init__(self, localSubrs, globalSubrs, private=None):
@ -379,6 +379,10 @@ class _DesubroutinizingT2Decompiler(psCharStrings.SimpleT2Decompiler):
setattr(self, op_name, self.stop_hint_count)
if hasattr(charString, '_desubroutinized'):
# If a charstring has already been desubroutinized, we will still
# need to execute it if we need to count hints in order to
# compute the byte length for mask arguments, and haven't finished
# counting hints pairs.
if self.need_hintcount and self.callingStack:
try:
psCharStrings.SimpleT2Decompiler.execute(self, charString)