2013-11-27 17:46:17 -05:00
|
|
|
from __future__ import print_function, division
|
2013-11-27 15:16:28 -05:00
|
|
|
from fontTools.misc.py23 import *
|
2013-11-27 17:27:45 -05:00
|
|
|
from fontTools import cffLib
|
|
|
|
from . import DefaultTable
|
1999-12-16 21:34:53 +00:00
|
|
|
|
|
|
|
|
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()
|
2013-12-04 21:28:50 -05:00
|
|
|
self._gaveGlyphOrder = False
|
1999-12-16 21:34:53 +00:00
|
|
|
|
|
|
|
def decompile(self, data, otFont):
|
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):
|
|
|
|
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"):
|
2013-12-04 21:28:50 -05:00
|
|
|
return False # CID-keyed font
|
2002-05-13 11:25:17 +00:00
|
|
|
else:
|
2013-12-04 21:28:50 -05:00
|
|
|
return True
|
2002-05-13 11:25:17 +00:00
|
|
|
|
1999-12-16 21:34:53 +00:00
|
|
|
def getGlyphOrder(self):
|
|
|
|
if self._gaveGlyphOrder:
|
|
|
|
from fontTools import ttLib
|
2013-11-27 02:42:28 -05:00
|
|
|
raise ttLib.TTLibError("illegal use of getGlyphOrder()")
|
2013-12-04 21:28:50 -05:00
|
|
|
self._gaveGlyphOrder = True
|
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
|
|
|
|
2013-11-27 03:19:32 -05:00
|
|
|
def fromXML(self, name, attrs, content, otFont):
|
2002-05-24 09:58:04 +00:00
|
|
|
if not hasattr(self, "cff"):
|
|
|
|
self.cff = cffLib.CFFFontSet()
|
2013-11-27 03:19:32 -05:00
|
|
|
self.cff.fromXML(name, attrs, content)
|
1999-12-16 21:34:53 +00:00
|
|
|
|