ebxIndexes.py 975 B

1234567891011121314151617181920212223242526272829
  1. from lxml.etree import Element
  2. # For storing EBLC/CBLC/bloc IndexSubTable classes.
  3. # (bloc only supports table formats 1-3.)
  4. class IndexSubTable1:
  5. """
  6. Class representing an EBLC/CBLC/bloc IndexSubTable, format 1.
  7. """
  8. def __init__(self, glyphs):
  9. self.glyphs = []
  10. for id, g in enumerate(glyphs["img_empty"]):
  11. if g.imgDict:
  12. self.glyphs.append({"id": id, "name": g.name() })
  13. def toTTX(self):
  14. eblcSub = Element("eblc_index_sub_table_1", { "imageFormat": "17" #TODO: Do something about image format nums.
  15. , "firstGlyphIndex": str(self.glyphs[0]["id"])
  16. , "lastGlyphIndex": str(self.glyphs[-1]["id"])
  17. })
  18. for g in self.glyphs:
  19. eblcSub.append(Element("glyphLoc", {"id": str(g["id"]), "name": g["name"] }))
  20. return eblcSub