googlefonts / ufo2ft

A bridge from UFOs to FontTools objects (and therefore, OTFs and TTFs).
MIT License
151 stars 43 forks source link

Kern feature writer: Add option to support mark filtering sets #587

Open simoncozens opened 2 years ago

simoncozens commented 2 years ago

When kerning a base to a mark, one might need to skip over certain irrelevant marks to make the kerning work. Currently there's no way to tell the kern feature writer to set a mark filtering set for base-mark kerning. I don't think this is hard to do but I don't know what a good interface to it would look like. (For example, assuming you have a Glyphs source...)

anthrotype commented 2 years ago

assuming you have a Glyphs source...

if Glyphs provide a built-in way to encode that information, then we can translate that to our own. Do they?

For the UFO/ufo2ft side, it could be a new option to KernFeatureWriter (stored in its lib key) that takes an array of glyph names to make desired set.

Next question that complicate matters is, would it be applied to all the kern pairs, or only to some lookups, and how to specificy which one.

If this becomes too complicated, it may be best to simply write these kerning pairs in the features.fea and avail oneself of the MarkFilteringSet statement.

simoncozens commented 2 years ago

if Glyphs provide a built-in way to encode that information, then we can translate that to our own. Do they?

I don't believe so. It's a bit of an advanced user feature...

Next question that complicate matters is, would it be applied to all the kern pairs, or only to some lookups, and how to specificy which one.

Right, this gets very complicated. I don't think there's a generic way to automatically do the right thing here.

If this becomes too complicated, it may be best to simply write these kerning pairs in the features.fea and avail oneself of the MarkFilteringSet statement.

This is fine until you have fonts with more than one master, particularly in a multi-master (Glyphs) file. Would be fine for UFO. But of course it makes it hard for the designer to maintain the kern pairs.

Ah well, this is why we have FEZ. ;-)

schriftgestalt commented 1 year ago

if Glyphs provide a built-in way to encode that information, then we can translate that to our own. Do they?

I have an idea how that could be done.

anthrotype commented 1 year ago

please don't make it too "smart" thanks ;)

schriftgestalt commented 1 year ago

Glyphs will already add a lookupflag IgnoreMarks; flag to most scripts. But that will not help with the base+mark case.

But what would be a desirable output? Wouldn’t that mean that for each kerned mark, it would need an individual lookup? Something like this:

lookup base {
    lookupflag IgnoreMarks;
    pos a b 10;
    pos b c -10;
} base;
lookup baseDieresis {
    lookupflag UseMarkFilteringSet [dieresiscomb];
    pos a dieresiscomb 20;
} baseDieresis;
lookup baseAcute {
    lookupflag UseMarkFilteringSet [acutecomb];
    pos a acutecomb 20;
    pos b acutecomb -10;
} baseAcute;