ebxBitmaps.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. from lxml.etree import Element
  2. from tables.common.ebxMetrics import SmallGlyphMetrics, BigGlyphMetrics
  3. class EBDTBitmapFormat17:
  4. """
  5. Class representing a CBDT format 17 bitmap subtable.
  6. (this is the only CBDT subtable format supported by TTX)
  7. """
  8. def __init__(self, metrics, strikeRes, glyph):
  9. self.name = glyph.name()
  10. self.metrics = SmallGlyphMetrics(metrics)
  11. self.img = glyph.imgDict["png-" + strikeRes]
  12. def toTTX(self):
  13. bitmapTable = Element("cbdt_bitmap_format_17", {"name": self.name })
  14. bitmapTable.append(self.metrics.toTTX())
  15. rawImageData = Element("rawimagedata")
  16. rawImageData.text = self.img.getHexDump()
  17. bitmapTable.append(rawImageData)
  18. return bitmapTable
  19. class EBDTBitmapFormat18:
  20. """
  21. Class representing a CBDT format 18 bitmap subtable.
  22. (This is not supported by TTX)
  23. """
  24. def __init__(self, metrics, strikeRes, img):
  25. self.name = glyph.name()
  26. self.metrics = BigGlyphMetrics(metrics)
  27. self.img = img
  28. class EBDTBitmapFormat19:
  29. """
  30. Class representing a CBDT format 19 bitmap subtable.
  31. (This is not supported by TTX)
  32. """
  33. def __init__(self, metrics, strikeRes, img):
  34. self.name = glyph.name()
  35. self.img = img