Load / save FeatureParamSize decipoints values as float
diff --git a/Lib/fontTools/ttLib/tables/otBase.py b/Lib/fontTools/ttLib/tables/otBase.py
index 168553d..d3f4eb3 100644
--- a/Lib/fontTools/ttLib/tables/otBase.py
+++ b/Lib/fontTools/ttLib/tables/otBase.py
@@ -575,6 +575,7 @@
del self.reader, self.font
def compile(self, writer, font):
+ self.ensureDecompiled()
table = self.preWrite(font)
if hasattr(self, 'sortCoverageLast'):
@@ -627,7 +628,6 @@
self.__dict__.update(table)
def preWrite(self, font):
- self.ensureDecompiled()
return self.__dict__.copy()
def toXML(self, xmlWriter, font, attrs=None):
diff --git a/Lib/fontTools/ttLib/tables/otConverters.py b/Lib/fontTools/ttLib/tables/otConverters.py
index 065659d..0266c71 100644
--- a/Lib/fontTools/ttLib/tables/otConverters.py
+++ b/Lib/fontTools/ttLib/tables/otConverters.py
@@ -155,6 +155,17 @@
value = font.getGlyphID(value)
writer.writeUShort(value)
+class FloatValue(SimpleValue):
+ def xmlRead(self, attrs, content, font):
+ return float(attrs["value"])
+
+class DeciPoints(FloatValue):
+ def read(self, reader, font, tableDict):
+ value = reader.readUShort()
+ return value / 10.
+
+ def write(self, writer, font, tableDict, value, repeatIndex=None):
+ writer.writeUShort(int(round(value * 10)))
class Struct(BaseConverter):
@@ -355,6 +366,7 @@
"Version": Version,
"Tag": Tag,
"GlyphID": GlyphID,
+ "DeciPoints": DeciPoints,
"struct": Struct,
"Offset": Table,
"LOffset": LTable,
diff --git a/Lib/fontTools/ttLib/tables/otData.py b/Lib/fontTools/ttLib/tables/otData.py
index 40e6ba9..e06bd42 100644
--- a/Lib/fontTools/ttLib/tables/otData.py
+++ b/Lib/fontTools/ttLib/tables/otData.py
@@ -52,11 +52,11 @@
]),
('FeatureParamsSize', [
- ('uint16', 'DesignSize', None, None, 'The design size in 720/inch units (decipoints).'),
+ ('DeciPoints', 'DesignSize', None, None, 'The design size in 720/inch units (decipoints).'),
('uint16', 'SubfamilyID', None, None, 'Serves as an identifier that associates fonts in a subfamily.'),
('uint16', 'SubfamilyNameID', None, None, 'Subfamily NameID.'),
- ('uint16', 'RangeStart', None, None, 'Small end of recommended usage range (exclusive) in 720/inch units.'),
- ('uint16', 'RangeEnd', None, None, 'Large end of recommended usage range (inclusive) in 720/inch units.'),
+ ('DeciPoints', 'RangeStart', None, None, 'Small end of recommended usage range (exclusive) in 720/inch units.'),
+ ('DeciPoints', 'RangeEnd', None, None, 'Large end of recommended usage range (inclusive) in 720/inch units.'),
]),
('FeatureParamsStylisticSet', [