added Fixed type

git-svn-id: svn://svn.code.sf.net/p/fonttools/code/trunk@228 4cde692c-a291-49d1-8350-778aa11640f8
This commit is contained in:
jvr 2002-05-13 18:10:05 +00:00
parent e69caf8771
commit b776a882ee

View File

@ -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"]