How to use the ufo2ft.featureWriters.ast function in ufo2ft

To help you get started, we’ve selected a few ufo2ft examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github googlefonts / ufo2ft / Lib / ufo2ft / featureWriters / markFeatureWriter.py View on Github external
def __str__(self):
        return self.asAST().asFea()  # pragma: no cover

    def filter(self, include):
        marks = self._filterMarks(include)
        return self.__class__(self.name, marks) if any(marks) else None


class MarkToBasePos(AbstractMarkPos):

    Statement = ast.MarkBasePosStatement


class MarkToMarkPos(AbstractMarkPos):

    Statement = ast.MarkMarkPosStatement


class MarkToLigaPos(AbstractMarkPos):

    Statement = ast.MarkLigPosStatement

    def _filterMarks(self, include):
        return [
            [anchor for anchor in component if include(anchor)]
            for component in self.marks
        ]

    def _marksAsAST(self):
        return [
            [
                (ast.Anchor(x=otRound(anchor.x), y=otRound(anchor.y)), anchor.markClass)
github alif-type / reem-kufi / tools / markFeatureWriter / __init__.py View on Github external
def _makeMarkPosRule(cls, ruleType, baseName, x, y, markClass):
        """ Return a MarkBasePosStatement for given rule type (either "base" or
        "mark"), glyph name, anchor and markClass name.
        """
        base = ast.GlyphName(baseName)
        anchor = cls._makeAnchorFormatA(x, y)
        marks = [(anchor, markClass)]
        if ruleType == "base":
            return ast.MarkBasePosStatement(base, marks)
        elif ruleType == "mark":
            return ast.MarkMarkPosStatement(base, marks)
        else:
            raise AssertionError(ruleType)
github googlefonts / ufo2ft / Lib / ufo2ft / featureWriters / kernFeatureWriter.py View on Github external
def __init__(self, side1, side2, value, directions=None, bidiTypes=None):
        if isinstance(side1, basestring):
            self.side1 = ast.GlyphName(side1)
        elif isinstance(side1, ast.GlyphClassDefinition):
            self.side1 = ast.GlyphClassName(side1)
        else:
            raise AssertionError(side1)

        if isinstance(side2, basestring):
            self.side2 = ast.GlyphName(side2)
        elif isinstance(side2, ast.GlyphClassDefinition):
            self.side2 = ast.GlyphClassName(side2)
        else:
            raise AssertionError(side2)

        self.value = value
        self.directions = directions or set()
        self.bidiTypes = bidiTypes or set()