psCharStrings: only assert no extra args on stack upon compile, not in toXML
Fixes #1451
This commit is contained in:
parent
dec9ec0e73
commit
1702536150
@ -1005,6 +1005,10 @@ class T2CharString(object):
|
|||||||
bytecode.append(encodeFixed(token))
|
bytecode.append(encodeFixed(token))
|
||||||
else:
|
else:
|
||||||
assert 0, "unsupported type: %s" % type(token)
|
assert 0, "unsupported type: %s" % type(token)
|
||||||
|
if not isCFF2 and program and not isinstance(program[-1], basestring):
|
||||||
|
raise CharStringCompileError(
|
||||||
|
"T2CharString or Subr has items on the stack after last operator."
|
||||||
|
)
|
||||||
try:
|
try:
|
||||||
bytecode = bytesjoin(bytecode)
|
bytecode = bytesjoin(bytecode)
|
||||||
except TypeError:
|
except TypeError:
|
||||||
@ -1088,13 +1092,12 @@ class T2CharString(object):
|
|||||||
else:
|
else:
|
||||||
args.append(token)
|
args.append(token)
|
||||||
if args:
|
if args:
|
||||||
if self.isCFF2:
|
# NOTE: only CFF2 charstrings/subrs can have numeric arguments on
|
||||||
# CFF2Subr's can have numeric arguments on the stack after the last operator.
|
# the stack after the last operator. Compiling this would fail if
|
||||||
args = [str(arg) for arg in args]
|
# this is part of CFF 1.0 table.
|
||||||
line = ' '.join(args)
|
args = [str(arg) for arg in args]
|
||||||
xmlWriter.write(line)
|
line = ' '.join(args)
|
||||||
else:
|
xmlWriter.write(line)
|
||||||
assert 0, "T2Charstring or Subr has items on the stack after last operator."
|
|
||||||
|
|
||||||
def fromXML(self, name, attrs, content):
|
def fromXML(self, name, attrs, content):
|
||||||
from fontTools.misc.textTools import binary2num, readHex
|
from fontTools.misc.textTools import binary2num, readHex
|
||||||
|
Loading…
x
Reference in New Issue
Block a user