question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[feaLib] handling of mixed single and multiple or ligature substitutions

See original GitHub issue

If I have a feature like this:

feature isol {
 sub a by A;
 sub b by B C;
} isol;

feaLib will generate two lookups, a single substitution lookup and a multiple substitution one. But IMO it should have been a single multiple substitution lookup, as the first rule can be seen as a multiple substitution lookup with just one replacement glyph. The same happens when mixing single substitutions with ligature substitutions.

In many of my fonts this results in 10s of lookups which can slow the OpenType layout processing in some implementations. It does not help that the feature syntax does not provide any way to make this explicit, since the three different substitution subtypes use the same syntax.

It gets even worse with named lookups, a lookup like this will not even compile:

lookup isol0 {
 sub a by A;
 sub b by B C;
} isol0;

FontForge used to handle this gracefully and guess the right lookup type in these situations. I didn’t check with FDK does here.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:23 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
khaledhosnycommented, Dec 21, 2017

I don’t see where is all the magic that is hidden from the user here:

feature foo {
sub a by A;
sub b by B A;
sub c by C;
sub d by D B A;
} foo;

The lookup above is clearly a multiple substitution lookup, with some entries substituting to a single glyph. There is no more magic here than FDK deciding to split this into 4 lookups behind the type designer’s back. IMO the fact that FDK does not support such multiple substitution lookups is a bug/limitation since it does not provide any other way to have such a perfectly legit OpenType lookup.

2reactions
miguelsousacommented, Jun 9, 2016

The font designer doesn’t care how the substitution is done as long as it does exactly what they specify.

Some font designers do care, and not being informed that something was changed or implemented in a certain way behind the scenes can lead to a lot of frustration when differences arise between what the designer/developer expected from the code and what results they’re getting (on e.g. an app).

I’m all for un-complicating things that are simple, but I’m leery of tools that are too helpful because there will be times when they make the wrong assumptions/decisions and if the designer/developer grows accustomed to being shielded from understanding what and how the tool is doing for him/her, it will eventually become an unwieldy tool.

Read more comments on GitHub >

github_iconTop Results From Across the Web

feaLib: Read/write OpenType feature files - fontTools
A multiple substitution statement. Parameters. prefix – a list of glyph-containing objects. glyph – a single glyph-containing object.
Read more >
Diff - platform/external/fonttools - Google Git
colorLib`: Module for handling colors in CPAL/COLR fonts +- :py:mod:`fontTools.cu2qu`: ... ``glyphs`` and ``replacements`` should + be one-item lists.
Read more >
fonttools [python-library] - Occam :: Details
[feaLib] Fixed bug with mixed single/multiple substitutions. If a single substitution involved a glyph class, we were incorrectly using only the first glyph ......
Read more >
fonttools - Python Package Health Analysis - Snyk
A good and healthy external contribution signal for fonttools project, which invites more than one hundred open source maintainers to collaborate on the ......
Read more >
Introduction to OpenType Programming
The Adobe feature language; Basic feature coding - substitutions and ligatures; Glyph Classes and Named Classes; Features and lookups; Scripts and languages ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found