Return three-byte operands from encodeIntCFF
This commit is contained in:
parent
3235454fcd
commit
4660b8c359
@ -197,11 +197,14 @@ t2Operators = [
|
|||||||
|
|
||||||
def getIntEncoder(format):
|
def getIntEncoder(format):
|
||||||
if format == "cff":
|
if format == "cff":
|
||||||
|
twoByteOp = bytechr(28)
|
||||||
fourByteOp = bytechr(29)
|
fourByteOp = bytechr(29)
|
||||||
elif format == "t1":
|
elif format == "t1":
|
||||||
|
twoByteOp = None
|
||||||
fourByteOp = bytechr(255)
|
fourByteOp = bytechr(255)
|
||||||
else:
|
else:
|
||||||
assert format == "t2"
|
assert format == "t2"
|
||||||
|
twoByteOp = bytechr(28)
|
||||||
fourByteOp = None
|
fourByteOp = None
|
||||||
|
|
||||||
def encodeInt(
|
def encodeInt(
|
||||||
@ -210,6 +213,7 @@ def getIntEncoder(format):
|
|||||||
bytechr=bytechr,
|
bytechr=bytechr,
|
||||||
pack=struct.pack,
|
pack=struct.pack,
|
||||||
unpack=struct.unpack,
|
unpack=struct.unpack,
|
||||||
|
twoByteOp=twoByteOp,
|
||||||
):
|
):
|
||||||
if -107 <= value <= 107:
|
if -107 <= value <= 107:
|
||||||
code = bytechr(value + 139)
|
code = bytechr(value + 139)
|
||||||
@ -219,11 +223,9 @@ def getIntEncoder(format):
|
|||||||
elif -1131 <= value <= -108:
|
elif -1131 <= value <= -108:
|
||||||
value = -value - 108
|
value = -value - 108
|
||||||
code = bytechr((value >> 8) + 251) + bytechr(value & 0xFF)
|
code = bytechr((value >> 8) + 251) + bytechr(value & 0xFF)
|
||||||
|
elif twoByteOp is not None and -32768 <= value <= 32767:
|
||||||
|
code = twoByteOp + pack(">h", value)
|
||||||
elif fourByteOp is None:
|
elif fourByteOp is None:
|
||||||
# T2 only supports 2 byte ints
|
|
||||||
if -32768 <= value <= 32767:
|
|
||||||
code = bytechr(28) + pack(">h", value)
|
|
||||||
else:
|
|
||||||
# Backwards compatible hack: due to a previous bug in FontTools,
|
# Backwards compatible hack: due to a previous bug in FontTools,
|
||||||
# 16.16 fixed numbers were written out as 4-byte ints. When
|
# 16.16 fixed numbers were written out as 4-byte ints. When
|
||||||
# these numbers were small, they were wrongly written back as
|
# these numbers were small, they were wrongly written back as
|
||||||
|
Loading…
x
Reference in New Issue
Block a user