asciiTable.py 637 B

1234567891011121314151617181920
  1. from fontTools.misc.textTools import strjoin, tobytes, tostr
  2. from . import DefaultTable
  3. class asciiTable(DefaultTable.DefaultTable):
  4. def toXML(self, writer, ttFont):
  5. data = tostr(self.data)
  6. # removing null bytes. XXX needed??
  7. data = data.split("\0")
  8. data = strjoin(data)
  9. writer.begintag("source")
  10. writer.newline()
  11. writer.write_noindent(data)
  12. writer.newline()
  13. writer.endtag("source")
  14. writer.newline()
  15. def fromXML(self, name, attrs, content, ttFont):
  16. lines = strjoin(content).split("\n")
  17. self.data = tobytes("\n".join(lines[1:-1]))