Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 _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
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
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
""" 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