How to use the ufo2ft.featureWriters.ast.makeFeaClassName 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 alif-type / reem-kufi / tools / markFeatureWriter / __init__.py View on Github external
markClass = ast.MarkClass(className)
            markClasses[className] = markClass
        else:
            if accentName in markClass.glyphs:
                mcdef = markClass.glyphs[accentName]
                if cls._anchorsAreEqual(anchor, mcdef.anchor):
                    logger.debug(
                        "Glyph %s already defined in markClass @%s",
                        accentName,
                        className,
                    )
                    return None
                else:
                    # same accent glyph defined with different anchors for the
                    # same markClass; make a new unique markClass definition
                    newClassName = ast.makeFeaClassName(className, markClasses)
                    markClass = ast.MarkClass(newClassName)
                    markClasses[newClassName] = markClass
        mcdef = ast.MarkClassDefinition(markClass, anchor, glyphs)
        markClass.addDefinition(mcdef)
        return mcdef
github alif-type / reem-kufi / tools / markFeatureWriter / __init__.py View on Github external
def _makeMarkClass(cls, markClasses, accentName, x, y, className):
        """ Make a MarkClassDefinition statement given the accent name,
        position, class name, and pre-existing mark classes.
        Return None if a mark class with the same name and anchor already
        exists. Or create new mark class with unique name when different.
        """
        glyphs = ast.GlyphName(accentName)
        anchor = cls._makeAnchorFormatA(x, y)
        className = ast.makeFeaClassName(className)
        markClass = markClasses.get(className)
        if markClass is None:
            markClass = ast.MarkClass(className)
            markClasses[className] = markClass
        else:
            if accentName in markClass.glyphs:
                mcdef = markClass.glyphs[accentName]
                if cls._anchorsAreEqual(anchor, mcdef.anchor):
                    logger.debug(
                        "Glyph %s already defined in markClass @%s",
                        accentName,
                        className,
                    )
                    return None
                else:
                    # same accent glyph defined with different anchors for the
github googlefonts / ufo2ft / Lib / ufo2ft / featureWriters / markFeatureWriter.py View on Github external
markClass = ast.MarkClass(className)
            markClasses[className] = markClass
        else:
            if glyphName in markClass.glyphs:
                mcdef = markClass.glyphs[glyphName]
                if self._anchorsAreEqual(anchor, mcdef.anchor):
                    self.log.debug(
                        "Glyph %s already defined in markClass @%s",
                        glyphName,
                        className,
                    )
                    return None
                else:
                    # same mark glyph defined with different anchors for the
                    # same markClass; make a new unique markClass definition
                    newClassName = ast.makeFeaClassName(className, markClasses)
                    markClass = ast.MarkClass(newClassName)
                    markClasses[newClassName] = markClass
        glyphName = ast.GlyphName(glyphName)
        mcdef = ast.MarkClassDefinition(markClass, anchor, glyphName)
        markClass.addDefinition(mcdef)
        return mcdef
github googlefonts / ufo2ft / Lib / ufo2ft / featureWriters / markFeatureWriter.py View on Github external
def _makeMarkClassDefinitions(self):
        markGlyphSets = self._groupMarkGlyphsByAnchor()
        currentClasses = self.context.feaFile.markClasses
        allMarkClasses = self.context.markClasses = {}
        classPrefix = self.markClassPrefix
        newDefs = []
        for markAnchorName, glyphAnchorPairs in sorted(markGlyphSets.items()):
            className = ast.makeFeaClassName(classPrefix + markAnchorName)
            for glyphName, anchor in glyphAnchorPairs.items():
                mcd = self._defineMarkClass(
                    glyphName, anchor.x, anchor.y, className, currentClasses
                )
                if mcd is not None:
                    newDefs.append(mcd)
                    # this may be different because of name clashes
                    className = mcd.markClass.name
                allMarkClasses[anchor.key] = currentClasses[className]
        return newDefs