C_F_F__2.py 807 B

1234567891011121314151617181920212223242526
  1. from io import BytesIO
  2. from fontTools.ttLib.tables.C_F_F_ import table_C_F_F_
  3. class table_C_F_F__2(table_C_F_F_):
  4. """Compact Font Format version 2 table
  5. The ``CFF2`` table contains glyph data for a CFF2-flavored OpenType
  6. font.
  7. .. note::
  8. ``CFF2`` is the successor to ``CFF``, and eliminates much of
  9. the redundancy incurred by embedding CFF version 1 in an OpenType
  10. font.
  11. See also https://learn.microsoft.com/en-us/typography/opentype/spec/cff2
  12. """
  13. def decompile(self, data, otFont):
  14. self.cff.decompile(BytesIO(data), otFont, isCFF2=True)
  15. assert len(self.cff) == 1, "can't deal with multi-font CFF tables."
  16. def compile(self, otFont):
  17. f = BytesIO()
  18. self.cff.compile(f, otFont, isCFF2=True)
  19. return f.getvalue()