1999-12-16 21:34:53 +00:00
|
|
|
import DefaultTable
|
|
|
|
from fontTools import cffLib
|
|
|
|
|
|
|
|
|
2002-05-03 17:01:25 +00:00
|
|
|
# temporary switch:
|
|
|
|
# - if true use possibly incomplete compile/decompile/toXML/fromXML implementation
|
|
|
|
# - if false use DefaultTable, ie. dump as hex.
|
|
|
|
TESTING_CFF = 0
|
|
|
|
|
|
|
|
|
2002-05-03 14:33:41 +00:00
|
|
|
class table_C_F_F_(DefaultTable.DefaultTable):
|
1999-12-16 21:34:53 +00:00
|
|
|
|
|
|
|
def __init__(self, tag):
|
|
|
|
DefaultTable.DefaultTable.__init__(self, tag)
|
2002-05-03 14:33:41 +00:00
|
|
|
self.cff = cffLib.CFFFontSet()
|
1999-12-16 21:34:53 +00:00
|
|
|
self._gaveGlyphOrder = 0
|
|
|
|
|
|
|
|
def decompile(self, data, otFont):
|
2002-05-13 11:25:17 +00:00
|
|
|
from cStringIO import StringIO
|
1999-12-16 21:34:53 +00:00
|
|
|
self.data = data # XXX while work is in progress...
|
2002-05-13 11:25:17 +00:00
|
|
|
self.cff.decompile(StringIO(data))
|
2002-05-03 14:33:41 +00:00
|
|
|
assert len(self.cff.fonts) == 1, "can't deal with multi-font CFF tables."
|
1999-12-16 21:34:53 +00:00
|
|
|
|
|
|
|
#def compile(self, otFont):
|
|
|
|
# xxx
|
|
|
|
|
2002-05-13 11:25:17 +00:00
|
|
|
def haveGlyphNames(self):
|
|
|
|
if hasattr(self.cff.fonts[self.cff.fontNames[0]], "ROS"):
|
|
|
|
return 0 # CID-keyed font
|
|
|
|
else:
|
|
|
|
return 1
|
|
|
|
|
1999-12-16 21:34:53 +00:00
|
|
|
def getGlyphOrder(self):
|
|
|
|
if self._gaveGlyphOrder:
|
|
|
|
from fontTools import ttLib
|
|
|
|
raise ttLib.TTLibError, "illegal use of getGlyphOrder()"
|
|
|
|
self._gaveGlyphOrder = 1
|
2002-05-03 14:33:41 +00:00
|
|
|
return self.cff.fonts[self.cff.fontNames[0]].getGlyphOrder()
|
1999-12-16 21:34:53 +00:00
|
|
|
|
|
|
|
def setGlyphOrder(self, glyphOrder):
|
2002-05-03 14:33:41 +00:00
|
|
|
self.cff.fonts[self.cff.fontNames[0]].setGlyphOrder(glyphOrder)
|
1999-12-16 21:34:53 +00:00
|
|
|
|
|
|
|
def toXML(self, writer, otFont, progress=None):
|
2002-05-03 17:01:25 +00:00
|
|
|
if TESTING_CFF:
|
|
|
|
self.cff.toXML(writer, progress)
|
|
|
|
else:
|
2002-05-03 14:33:41 +00:00
|
|
|
# dump as hex as long as we can't compile
|
|
|
|
DefaultTable.DefaultTable.toXML(self, writer, otFont)
|
1999-12-16 21:34:53 +00:00
|
|
|
|
|
|
|
#def fromXML(self, (name, attrs, content), otFont):
|
|
|
|
# xxx
|
|
|
|
|