Ejemplo n.º 1
0
    def build(self):
        # TODO: Consider emitting multiple subtables to save space.
        # Partition the marks and bases into disjoint subsets, so that
        # MarkBasePos rules would only access glyphs from a single
        # subset. This would likely lead to smaller mark/base
        # matrices, so we might be able to omit many of the empty
        # anchor tables that we currently produce. Of course, this
        # would only work if the MarkBasePos rules of real-world fonts
        # allow partitioning into multiple subsets. We should find out
        # whether this is the case; if so, implement the optimization.

        st = otTables.MarkBasePos()
        st.Format = 1
        st.MarkCoverage = \
            self.buildCoverage_(self.marks, otTables.MarkCoverage)
        markClasses = self.buildMarkClasses_(self.marks)
        st.ClassCount = len(markClasses)
        self.setMarkArray_(self.marks, markClasses, st)

        st.BaseCoverage = \
            self.buildCoverage_(self.bases, otTables.BaseCoverage)
        st.BaseArray = otTables.BaseArray()
        st.BaseArray.BaseCount = len(st.BaseCoverage.glyphs)
        st.BaseArray.BaseRecord = []
        for base in st.BaseCoverage.glyphs:
            baserec = otTables.BaseRecord()
            st.BaseArray.BaseRecord.append(baserec)
            baserec.BaseAnchor = []
            for markClass in sorted(markClasses.keys(), key=markClasses.get):
                baserec.BaseAnchor.append(self.bases[base].get(markClass))

        return self.buildLookup_([st])
Ejemplo n.º 2
0
def buildBaseArray(bases, numMarkClasses, glyphMap):
    self = ot.BaseArray()
    self.BaseRecord = []
    for base in sorted(bases, key=glyphMap.__getitem__):
        b = bases[base]
        anchors = [b.get(markClass) for markClass in range(numMarkClasses)]
        self.BaseRecord.append(buildBaseRecord(anchors))
    self.BaseCount = len(self.BaseRecord)
    return self