googlefonts/ufo2ft

Alternate layers / FeatureVariations glyphs not taking part in mark attachment

Closed this issue · 1 comments

I just noticed that although my base layers in a variable Oriya font were attaching nicely in a blwm mark-to-mark feature, alternate layers were not:

oriya

This turns out to be because we build a mark filtering class for mark features like so:

def _makeMarkFilteringSetClass(self, lookupName, attachments, markClass, include):
markGlyphs = (glyphName for glyphName in markClass.glyphs if include(glyphName))

where include is something like this:

abvmGlyphs, notAbvmGlyphs = self._getAbvmGlyphs()
def isAbvm(glyphName):
return glyphName in abvmGlyphs

However:

In [10]: lookupName
Out[10]: 'blwm_mark2mark_bottom'

In [11]: include
Out[11]: <function ufo2ft.featureWriters.markFeatureWriter.MarkFeatureWriter._makeFeatures.<locals>.isAbvm(glyphName)>

In [12]: include("lVocalicMatra-oriya")
Out[12]: True

In [13]: include("lVocalicMatra-oriya.BRACKET.varAlt01")
Out[13]: False

lVocalicMatra-oriya is included in the glyph set because it has a Unicode encoded codepoint pointing to an abvm-using script; and anything reachable by GSUB substitutions from that codepoint is also included:

gsub = self.compileGSUB()
glyphGroups = classifyGlyphs(unicodeIsAbvm, cmap, gsub)
# the 'glyphGroups' dict is keyed by the return value of the
# classifying include, so here 'True' means all the
# Indic/USE/Khmer glyphs
abvmGlyphs = glyphGroups.get(True, set())

But (and here I'm guessing slightly but it's a reasonable guess) lVocalicMatra-oriya.BRACKET.varAlt01 is only reachable by feature variations, so is not included, so does not take part in mark attachment.

I think the fix here is that either compileGSUB or classifyGlyphs or both need to know more about feature variations.

Oh wait. That's not possible, because feature variations only exist in the designspace and we're compiling UFOs; there's no link between lVocalicMatra-oriya and lVocalicMatra-oriya.BRACKET.varAlt01 in the UFO.

Score another one for "you can't build a variable font by treating UFOs as independent fonts".