diff --git a/Lib/fontTools/otlLib/builder.py b/Lib/fontTools/otlLib/builder.py index f8b3ce3b0..1d5e7b6ee 100644 --- a/Lib/fontTools/otlLib/builder.py +++ b/Lib/fontTools/otlLib/builder.py @@ -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