Coverage for /usr/lib/python3/dist-packages/fontTools/ttLib/tables/C_F_F_.py: 36%

33 statements  

« prev     ^ index     » next       coverage.py v7.9.1, created at 2025-06-14 15:55 +0200

1from io import BytesIO 

2from fontTools import cffLib 

3from . import DefaultTable 

4 

5 

6class table_C_F_F_(DefaultTable.DefaultTable): 

7 def __init__(self, tag=None): 

8 DefaultTable.DefaultTable.__init__(self, tag) 

9 self.cff = cffLib.CFFFontSet() 

10 self._gaveGlyphOrder = False 

11 

12 def decompile(self, data, otFont): 

13 self.cff.decompile(BytesIO(data), otFont, isCFF2=False) 

14 assert len(self.cff) == 1, "can't deal with multi-font CFF tables." 

15 

16 def compile(self, otFont): 

17 f = BytesIO() 

18 self.cff.compile(f, otFont, isCFF2=False) 

19 return f.getvalue() 

20 

21 def haveGlyphNames(self): 

22 if hasattr(self.cff[self.cff.fontNames[0]], "ROS"): 

23 return False # CID-keyed font 

24 else: 

25 return True 

26 

27 def getGlyphOrder(self): 

28 if self._gaveGlyphOrder: 

29 from fontTools import ttLib 

30 

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)