refactored slightly to make later specializations easier
git-svn-id: svn://svn.code.sf.net/p/fonttools/code/trunk@330 4cde692c-a291-49d1-8350-778aa11640f8
This commit is contained in:
parent
0cf88edbbd
commit
f7ef96ccca
@ -299,6 +299,7 @@ class BaseTable:
|
|||||||
def decompile(self, reader, font, tableStack=None):
|
def decompile(self, reader, font, tableStack=None):
|
||||||
if tableStack is None:
|
if tableStack is None:
|
||||||
tableStack = TableStack()
|
tableStack = TableStack()
|
||||||
|
self.readFormat(reader)
|
||||||
table = {}
|
table = {}
|
||||||
self.__rawTable = table # for debugging
|
self.__rawTable = table # for debugging
|
||||||
tableStack.push(table)
|
tableStack.push(table)
|
||||||
@ -321,6 +322,7 @@ class BaseTable:
|
|||||||
if tableStack is None:
|
if tableStack is None:
|
||||||
tableStack = TableStack()
|
tableStack = TableStack()
|
||||||
table = self.preWrite(font)
|
table = self.preWrite(font)
|
||||||
|
self.writeFormat(writer)
|
||||||
tableStack.push(table)
|
tableStack.push(table)
|
||||||
for conv in self.getConverters():
|
for conv in self.getConverters():
|
||||||
value = table.get(conv.name)
|
value = table.get(conv.name)
|
||||||
@ -344,6 +346,12 @@ class BaseTable:
|
|||||||
conv.write(writer, font, tableStack, value)
|
conv.write(writer, font, tableStack, value)
|
||||||
tableStack.pop()
|
tableStack.pop()
|
||||||
|
|
||||||
|
def readFormat(self, reader):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def writeFormat(self, writer):
|
||||||
|
pass
|
||||||
|
|
||||||
def postRead(self, table, font):
|
def postRead(self, table, font):
|
||||||
self.__dict__.update(table)
|
self.__dict__.update(table)
|
||||||
|
|
||||||
@ -415,14 +423,12 @@ class FormatSwitchingBaseTable(BaseTable):
|
|||||||
def getConverterByName(self, name):
|
def getConverterByName(self, name):
|
||||||
return self.convertersByName[self.Format][name]
|
return self.convertersByName[self.Format][name]
|
||||||
|
|
||||||
def decompile(self, reader, font, tableStack=None):
|
def readFormat(self, reader):
|
||||||
self.Format = reader.readUShort()
|
self.Format = reader.readUShort()
|
||||||
assert self.Format <> 0, (self, reader.pos, len(reader.data))
|
assert self.Format <> 0, (self, reader.pos, len(reader.data))
|
||||||
BaseTable.decompile(self, reader, font, tableStack)
|
|
||||||
|
|
||||||
def compile(self, writer, font, tableStack=None):
|
def writeFormat(self, writer):
|
||||||
writer.writeUShort(self.Format)
|
writer.writeUShort(self.Format)
|
||||||
BaseTable.compile(self, writer, font, tableStack)
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
Loading…
x
Reference in New Issue
Block a user