def _makeMarkLookup(self, lookupName, isMkmk, anchorName, accentAnchorName, markClass): """ Create a mark (or mkmk) lookup for one anchor pair in the writer's anchor list, or None if there are no glyphs with given anchor. """ baseGlyphs = self._createBaseGlyphList(anchorName, isMkmk) if not baseGlyphs: return ruleType = "mark" if isMkmk else "base" statements = [] if isMkmk: mkAttachMembers = list(markClass.glyphs) 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
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
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
def _makeKerningLookup(self, name, pairs, exclude=None, rtl=False): 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 self.options.ignoreMarks: lookup.statements.append(ast.makeLookupFlag("IgnoreMarks")) lookup.statements.extend(rules) return lookup
def _makeMarkToLigaLookup(self, lookupName, anchorNames, accentAnchorName, markClass): """ 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