1999-12-16 21:34:53 +00:00
|
|
|
import DefaultTable
|
|
|
|
from fontTools import cffLib
|
|
|
|
|
|
|
|
|
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
|
2002-05-24 09:58:04 +00:00
|
|
|
self.cff.decompile(StringIO(data), otFont)
|
2002-05-16 18:15:57 +00:00
|
|
|
assert len(self.cff) == 1, "can't deal with multi-font CFF tables."
|
1999-12-16 21:34:53 +00:00
|
|
|
|
2002-05-24 09:58:04 +00:00
|
|
|
def compile(self, otFont):
|
|
|
|
from cStringIO import StringIO
|
|
|
|
f = StringIO()
|
|
|
|
self.cff.compile(f, otFont)
|
|
|
|
return f.getvalue()
|
1999-12-16 21:34:53 +00:00
|
|
|
|
2002-05-13 11:25:17 +00:00
|
|
|
def haveGlyphNames(self):
|
2002-05-16 18:15:57 +00:00
|
|
|
if hasattr(self.cff[self.cff.fontNames[0]], "ROS"):
|
2002-05-13 11:25:17 +00:00
|
|
|
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-16 18:15:57 +00:00
|
|
|
return self.cff[self.cff.fontNames[0]].getGlyphOrder()
|
1999-12-16 21:34:53 +00:00
|
|
|
|
|
|
|
def setGlyphOrder(self, glyphOrder):
|
2002-05-16 18:15:57 +00:00
|
|
|
pass
|
|
|
|
# XXX
|
|
|
|
#self.cff[self.cff.fontNames[0]].setGlyphOrder(glyphOrder)
|
1999-12-16 21:34:53 +00:00
|
|
|
|
|
|
|
def toXML(self, writer, otFont, progress=None):
|
2002-05-24 09:58:04 +00:00
|
|
|
self.cff.toXML(writer, progress)
|
1999-12-16 21:34:53 +00:00
|
|
|
|
2002-05-24 09:58:04 +00:00
|
|
|
def fromXML(self, (name, attrs, content), otFont):
|
|
|
|
if not hasattr(self, "cff"):
|
|
|
|
self.cff = cffLib.CFFFontSet()
|
|
|
|
self.cff.fromXML((name, attrs, content))
|
1999-12-16 21:34:53 +00:00
|
|
|
|