How to use the ufo2ft.featureWriters.ast.LookupBlock 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 _makeMarkToMarkLookup(
        self, anchorName, attachments, include, marksFilter=None, featureTag=None
    ):
        attachments = list(self._iterAttachments(attachments, include, marksFilter))
        if not attachments:
            return
        prefix = (featureTag + "_") if featureTag is not None else ""
        lookupName = "%smark2mark_%s" % (prefix, anchorName)
        filteringClass = self._makeMarkFilteringSetClass(
            lookupName,
            attachments,
            markClass=self.context.markClasses[anchorName],
            include=include,
        )
        lkp = ast.LookupBlock(lookupName)
        lkp.statements.append(filteringClass)
        lkp.statements.append(ast.makeLookupFlag(markFilteringSet=filteringClass))
        lkp.statements.extend(pos.asAST() for pos in attachments)
        return lkp
github googlefonts / ufo2ft / Lib / ufo2ft / featureWriters / kernFeatureWriter.py View on Github external
def _makeKerningLookup(
        self, name, pairs, exclude=None, rtl=False, ignoreMarks=True
    ):
        assert pairs
        rules = []
        for pair in pairs:
            if exclude is not None and exclude(pair):
                self.log.debug("pair excluded from '%s' lookup: %r", name, pair)
                continue
            rules.append(self._makePairPosRule(pair, rtl=rtl))
        if rules:
            lookup = ast.LookupBlock(name)
            if ignoreMarks and self.options.ignoreMarks:
                lookup.statements.append(ast.makeLookupFlag("IgnoreMarks"))
            lookup.statements.extend(rules)
            return lookup
github googlefonts / ufo2ft / Lib / ufo2ft / featureWriters / markFeatureWriter.py View on Github external
def _makeMarkLookup(self, lookupName, attachments, include, marksFilter=None):
        statements = [
            pos.asAST()
            for pos in self._iterAttachments(attachments, include, marksFilter)
        ]
        if statements:
            lkp = ast.LookupBlock(lookupName)
            lkp.statements.extend(statements)
            return lkp
github alif-type / reem-kufi / tools / markFeatureWriter / __init__.py View on Github external
mkAttachMembers.extend(
                g[0] for g in baseGlyphs if g[0] not in mkAttachMembers
            )
            mkAttachCls = ast.makeGlyphClassDefinition(
                lookupName + "MkAttach", mkAttachMembers
            )
            statements.append(mkAttachCls)
            statements.append(ast.makeLookupFlag(markFilteringSet=mkAttachCls))

        for baseName, x, y in baseGlyphs:
            statements.append(
                self._makeMarkPosRule(ruleType, baseName, x, y, markClass)
            )

        if statements:
            lookup = ast.LookupBlock(lookupName)
            lookup.statements.extend(statements)
            return lookup
github alif-type / reem-kufi / tools / markFeatureWriter / __init__.py View on Github external
""" Return a mark lookup containing mark-to-ligature position rules
        for the given anchor pairs, or None if there are no glyphs with
        those anchors.
        """
        baseGlyphs = self._createLigaGlyphList(anchorNames)
        if not baseGlyphs:
            return

        statements = []
        for baseName, points in baseGlyphs:
            statements.append(
                self._makeMarkLigPosRule(baseName, points, markClass)
            )

        if statements:
            lookup = ast.LookupBlock(lookupName)
            lookup.statements.extend(statements)
            return lookup