From b776a882ee55fff8c39543f352c528bb5d338177 Mon Sep 17 00:00:00 2001 From: jvr Date: Mon, 13 May 2002 18:10:05 +0000 Subject: [PATCH] added Fixed type git-svn-id: svn://svn.code.sf.net/p/fonttools/code/trunk@228 4cde692c-a291-49d1-8350-778aa11640f8 --- Lib/fontTools/ttLib/tables/otConverters.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Lib/fontTools/ttLib/tables/otConverters.py b/Lib/fontTools/ttLib/tables/otConverters.py index 27dc29890..eccffe727 100644 --- a/Lib/fontTools/ttLib/tables/otConverters.py +++ b/Lib/fontTools/ttLib/tables/otConverters.py @@ -82,6 +82,12 @@ class Long(IntValue): def write(self, writer, font, tableStack, value): writer.writeLong(value) +class Fixed(IntValue): + def read(self, reader, font, tableStack): + return float(reader.readLong()) / 0x10000 + def write(self, writer, font, tableStack, value): + writer.writeLong(int(round(value * 0x10000))) + class Short(IntValue): def read(self, reader, font, tableStack): return reader.readShort() @@ -111,6 +117,7 @@ class GlyphID(SimpleValue): def write(self, writer, font, tableStack, value): writer.writeUShort(font.getGlyphID(value)) + class Struct(BaseConverter): def read(self, reader, font, tableStack): @@ -184,6 +191,7 @@ class ValueFormat(IntValue): writer.writeUShort(format) writer.setValueFormat(format, self.which) + class ValueRecord(ValueFormat): def read(self, reader, font, tableStack): return reader.readValueRecord(font, self.which) @@ -263,6 +271,7 @@ converterMapping = { "int16": Short, "uint16": UShort, "ULONG": Long, + "Fixed": Fixed, "Tag": Tag, "GlyphID": GlyphID, "struct": Struct, @@ -272,5 +281,5 @@ converterMapping = { # equivalents: converterMapping["USHORT"] = converterMapping["uint16"] -converterMapping["Fixed"] = converterMapping["fixed32"] = converterMapping["ULONG"] +converterMapping["fixed32"] = converterMapping["Fixed"]