• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1from io import BytesIO
2from fontTools import cffLib
3from . import DefaultTable
4
5
6class table_C_F_F_(DefaultTable.DefaultTable):
7
8	def __init__(self, tag=None):
9		DefaultTable.DefaultTable.__init__(self, tag)
10		self.cff = cffLib.CFFFontSet()
11		self._gaveGlyphOrder = False
12
13	def decompile(self, data, otFont):
14		self.cff.decompile(BytesIO(data), otFont, isCFF2=False)
15		assert len(self.cff) == 1, "can't deal with multi-font CFF tables."
16
17	def compile(self, otFont):
18		f = BytesIO()
19		self.cff.compile(f, otFont, isCFF2=False)
20		return f.getvalue()
21
22	def haveGlyphNames(self):
23		if hasattr(self.cff[self.cff.fontNames[0]], "ROS"):
24			return False  # CID-keyed font
25		else:
26			return True
27
28	def getGlyphOrder(self):
29		if self._gaveGlyphOrder:
30			from fontTools import ttLib
31			raise ttLib.TTLibError("illegal use of getGlyphOrder()")
32		self._gaveGlyphOrder = True
33		return self.cff[self.cff.fontNames[0]].getGlyphOrder()
34
35	def setGlyphOrder(self, glyphOrder):
36		pass
37		# XXX
38		#self.cff[self.cff.fontNames[0]].setGlyphOrder(glyphOrder)
39
40	def toXML(self, writer, otFont):
41		self.cff.toXML(writer)
42
43	def fromXML(self, name, attrs, content, otFont):
44		if not hasattr(self, "cff"):
45			self.cff = cffLib.CFFFontSet()
46		self.cff.fromXML(name, attrs, content, otFont)
47