[oltLib.builder] Fix bug in building a variation font.

The logic for building a Device subtable didn't know about the VariationIndex flavor of a ValueRecord Device subtable.
This commit is contained in:
ReadRoberts 2019-06-12 14:31:38 -07:00
parent b756bcac18
commit b44c761526

View File

@ -479,7 +479,10 @@ def _getSinglePosValueKey(valueRecord):
valueFormat, result = 0, []
for name, value in valueRecord.__dict__.items():
if isinstance(value, ot.Device):
result.append((name, _makeDeviceTuple(value)))
if value.DeltaFormat & 0x8000:
result.append((name, _makeVariationInstance(value)))
else:
result.append((name, _makeDeviceTuple(value)))
else:
result.append((name, value))
valueFormat |= valueRecordFormatDict[name][0]
@ -493,12 +496,20 @@ def _makeDeviceTuple(device):
return (device.DeltaFormat, device.StartSize, device.EndSize,
tuple(device.DeltaValue))
def _makeVariationInstance(device):
"""otTables.Device --> tuple, for making device tables unique"""
return (device.DeltaFormat, device.StartSize, device.EndSize)
def _getSinglePosValueSize(valueKey):
"""Returns how many ushorts this valueKey (short form of ValueRecord) takes up"""
count = 0
for k in valueKey[1:]:
if hasattr(k[1], '__len__') and len(k[1]):
count += len(k[1][3]) + 3
# it is a device table key
if k[1][0] & 0x8000:
count += 3
else:
count += len(k[1][3]) + 3
else:
count += 1
return count