Contextual removal of some ligatures using fonts.handlers.otf.addfeature (LuaTeX 1.13.2)
Hello, dear list ! In order to fix a few bugs in some OpenType features included in EB Garamond font provided by Google Fonts, I am trying to remove some ligatures (erroneous in some contexts) with fonts.handlers.otf.addfeature. I must be missing something, because I can't get it to work. Here is a minimal —non working—example :-) (The attempted removal (“f_i” → “fi” only before “o”) is of course irrelevant. I chose it just for the sole purpose of this test, to provide a simple example. What I am trying to achieve is more complex, with other ligatures.) fonts.handlers.otf.addfeature{ name = "unfio", type = "chainsubstitution", lookups = { { type = "multiple", data = { [ "f_i" ] = { "f", "i" } } } } rules = { { after = { { "o" } }, current = { { "f_i" } }, lookups = { 1 } } } } } Could someone please explain to me what I did wrong ? Thomas Savary 1 le Grand-Plessis F-85340 L’Île-d’Olonne Tél. 06 22 82 61 34 https://compo85.fr/
On 24 Dec 2021, at 18:34, Thomas Savary via ntg-context
wrote: Hello, dear list !
In order to fix a few bugs in some OpenType features included in EB Garamond font provided by Google Fonts, I am trying to remove some ligatures (erroneous in some contexts) with fonts.handlers.otf.addfeature.
I must be missing something, because I can't get it to work.
Here is a minimal —non working—example :-) (The attempted removal (“f_i” → “fi” only before “o”) is of course irrelevant. I chose it just for the sole purpose of this test, to provide a simple example. What I am trying to achieve is more complex, with other ligatures.)
fonts.handlers.otf.addfeature{ name = "unfio", type = "chainsubstitution", lookups = { { type = "multiple", data = { [ "f_i" ] = { "f", "i" } } } } rules = { { after = { { "o" } }, current = { { "f_i" } }, lookups = { 1 } } } } }
Could someone please explain to me what I did wrong ?
Firstly, you have an extra } in the example above. Secondly, rules need to come inside a data section. Thus (untested): fonts.handlers.otf.addfeature{ name = "unfio", type = "chainsubstitution", lookups = { { type = "substitution", data = { [ "f_i" ] = { "f", "i" } } } }, data = { rules = { { after = { { "o" } }, current = { { "f_i" } }, lookups = { 1 } } } } } Regards, — Bruce Horrocks Hampshire, UK
On 12/25/2021 12:04 AM, Bruce Horrocks via ntg-context wrote:
On 24 Dec 2021, at 18:34, Thomas Savary via ntg-context
wrote: Hello, dear list !
In order to fix a few bugs in some OpenType features included in EB Garamond font provided by Google Fonts, I am trying to remove some ligatures (erroneous in some contexts) with fonts.handlers.otf.addfeature.
I must be missing something, because I can't get it to work.
Here is a minimal —non working—example :-) (The attempted removal (“f_i” → “fi” only before “o”) is of course irrelevant. I chose it just for the sole purpose of this test, to provide a simple example. What I am trying to achieve is more complex, with other ligatures.)
fonts.handlers.otf.addfeature{ name = "unfio", type = "chainsubstitution", lookups = { { type = "multiple", data = { [ "f_i" ] = { "f", "i" } } } } rules = { { after = { { "o" } }, current = { { "f_i" } }, lookups = { 1 } } } } }
Could someone please explain to me what I did wrong ?
Firstly, you have an extra } in the example above.
Secondly, rules need to come inside a data section. Thus (untested):
fonts.handlers.otf.addfeature{ name = "unfio", type = "chainsubstitution", lookups = { { type = "substitution", data = { [ "f_i" ] = { "f", "i" } } } }, data = { rules = { { after = { { "o" } }, current = { { "f_i" } }, lookups = { 1 } } } } }
the problem with this approach is that in a feature rich font like eb you never know where to kick this into the sequence and you even don't know how many variants of fi ligatures are there Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
On 12/25/2021 12:04 AM, Bruce Horrocks via ntg-context wrote:
On 24 Dec 2021, at 18:34, Thomas Savary via ntg-context
wrote: Hello, dear list !
In order to fix a few bugs in some OpenType features included in EB Garamond font provided by Google Fonts, I am trying to remove some ligatures (erroneous in some contexts) with fonts.handlers.otf.addfeature.
I must be missing something, because I can't get it to work.
Here is a minimal —non working—example :-) (The attempted removal (“f_i” → “fi” only before “o”) is of course irrelevant. I chose it just for the sole purpose of this test, to provide a simple example. What I am trying to achieve is more complex, with other ligatures.)
fonts.handlers.otf.addfeature{ name = "unfio", type = "chainsubstitution", lookups = { { type = "multiple", data = { [ "f_i" ] = { "f", "i" } } } } rules = { { after = { { "o" } }, current = { { "f_i" } }, lookups = { 1 } } } } }
Could someone please explain to me what I did wrong ?
Firstly, you have an extra } in the example above.
Secondly, rules need to come inside a data section. Thus (untested):
fonts.handlers.otf.addfeature{ name = "unfio", type = "chainsubstitution", lookups = { { type = "substitution", data = { [ "f_i" ] = { "f", "i" } } } }, data = { rules = { { after = { { "o" } }, current = { { "f_i" } }, lookups = { 1 } } } } }
A better an dmore reliable approach is this: \startluacode local demo = { name = "demo", options = { { patterns = { fio = "f|io", }, words = [[ fioot fiots ]], }, }, } table.save("oeps-fixes.llg",demo) \stopluacode \setuplanguage[en][goodies={oeps-fixes.llg}] \setupbodyfont[ebgaramond] \starttext fiets fiots fiats fioot \stoptext because you want to block certain ligatures but keep kerning etc (see older posts for more extensive examples) Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
Hi Bruce and Hans ! Thank you very much for your answers, that helped me a lot. In fact, though I would love to switch to ConTeXt one day, I am still using LuaLaTeX — I am a slow learner and I know it will take me months to be able to achieve what I need for my job with ConTeXt and can do with LuaLaTeX and the Memoir class for the time being (despite sometimes being irritated by LaTeX limitations or oddities). I need the EB Garamond variable font for future jobs, but this font, provided by Google Fonts, is such a mess : kerning problems, unusable OpenType features that have to be rewritten from scratch, shifts in glyphs table… For sure, the original font by Georg Duffner was much better, but I need the variable version. Lots of fixing necessary, but thanks to fonts.handlers.otf.addfeature I have almost succeeded to make it a usable Garamond. Of course, it would be best to help Google improving this font, but I don’t have time yet. The actual problem was with the italic ligatures "a_s", "e_s", "é_s", "i_s" and "u_s", that should occur only at the end of words and not everywhere. Instead of removing the unwanted ligatures, I chose another way as soon as I understood how to fully use “current” to describe not only a single glyph, but a string if necessary — for instance, current={ { "a", "e", "eacute", "i", "u"}, {"s"} } Thanks for this wonderful tool ! Thomas Savary 1 le Grand-Plessis F-85340 L’Île-d’Olonne Tél. 06 22 82 61 34 https://compo85.fr/ Le samedi 25 décembre 2021, 00:04:51 CET Bruce Horrocks a écrit :
On 24 Dec 2021, at 18:34, Thomas Savary via ntg-context
wrote: Hello, dear list !
In order to fix a few bugs in some OpenType features included in EB Garamond font provided by Google Fonts, I am trying to remove some ligatures (erroneous in some contexts) with fonts.handlers.otf.addfeature.
I must be missing something, because I can't get it to work.
Here is a minimal —non working—example :-) (The attempted removal (“f_i” → “fi” only before “o”) is of course irrelevant. I chose it just for the sole purpose of this test, to provide a simple example. What I am trying to achieve is more complex, with other ligatures.)
fonts.handlers.otf.addfeature{
name = "unfio", type = "chainsubstitution", lookups = {
{ type = "multiple", data = { [ "f_i" ] = { "f", "i" } } }
} rules = {
{ after = { { "o" } }, current = { { "f_i" } }, lookups = { 1 } }
}
}
}
Could someone please explain to me what I did wrong ?
Firstly, you have an extra } in the example above.
Secondly, rules need to come inside a data section. Thus (untested):
fonts.handlers.otf.addfeature{ name = "unfio", type = "chainsubstitution", lookups = { { type = "substitution", data = { [ "f_i" ] = { "f", "i" } } } }, data = { rules = { { after = { { "o" } },
On 12/25/2021 11:52 PM, Thomas Savary via ntg-context wrote:
Hi Bruce and Hans !
Thank you very much for your answers, that helped me a lot.
In fact, though I would love to switch to ConTeXt one day, I am still using LuaLaTeX — I am a slow learner and I know it will take me months to be able to achieve what I need for my job with ConTeXt and can do with LuaLaTeX and the Memoir class for the time being (despite sometimes being irritated by LaTeX limitations or oddities).
keep in mind that context font handling and latex font handling can differ (and not all that is possible in context is in the generic font loader code); also, in (esp in lmtx) some solutions are not bound to fonts
I need the EB Garamond variable font for future jobs, but this font, provided by Google Fonts, is such a mess : kerning problems, unusable OpenType features that have to be rewritten from scratch, shifts in glyphs table… For sure, the original font by Georg Duffner was much better, but I need the variable version. Lots of fixing necessary, but thanks to fonts.handlers.otf.addfeature I have almost succeeded to make it a usable Garamond.
a probably more reliable solution is to 'remove bad stuff' from the loaded font by running over the features and removing bad matches (which is less sensitive for order)
Of course, it would be best to help Google improving this font, but I don’t have time yet.
is that really a google font? afaik it doesn't originate there (unless it among those things that google grabs - and at some point possible discards)
The actual problem was with the italic ligatures "a_s", "e_s", "é_s", "i_s" and "u_s", that should occur only at the end of words and not everywhere. Instead of removing the unwanted ligatures, I chose another way as soon as I understood how to fully use “current” to describe not only a single glyph, but a string if necessary — for instance, current={ { "a", "e", "eacute", "i", "u"}, {"s"} }
ok, good that you got it working Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
Thanks, Hans, for your advice.
a probably more reliable solution is to 'remove bad stuff' from the loaded font by running over the features and removing bad matches (which is less sensitive for order)
I could edit the font features, indeed, but I run a GNU/Linux OS, and Fontforge cannot edit nor generate variable fonts. There seems to be a solution (https://www.youtube.com/watch? v=xoQuWARCUWI[1] ), but so far beyond my technical capabilities that I cannot consider it.
is that really a google font? afaik it doesn't originate there (unless it among those things that google grabs - and at some point possible discards)
Yes, it is, but not from the beginning. A great Garamond, the original font was designed by Georg Duffner. A few years ago, Google decided to make it a more complete font family : Octavio Pardo has done an excellent job with the bolder versions of EB Garamond and its conversion to a variable font. However, for whatever reasons, he did quite a rush job with the OpenType features ! Many essential features are lacking (despite the needed glyphs still being there), and most present features are poorly implemented, with a lot of typographic nonsense (concerning long s and long Q or the mentioned italic ligatures, for instance). https://fonts.google.com/specimen/EB+Garamond[2] I will contact Google Fonts shortly to report on the dozens of problems I have encountered that make the unfixed new version of EB Garamond unusable for anything but the most basic uses. Fortunately, my significantly more demanding needs for a client were met with the invaluable help from LuaTeX, but that won't be enough for my own projects, much more complex (facsimile of ancient editions), until Google improves this font. Thomas Savary 1 le Grand-Plessis F-85340 L’Île-d’Olonne Tél. 06 22 82 61 34 https://compo85.fr/ -------- [1] https://www.youtube.com/watch?v=xoQuWARCUWI [2] https://fonts.google.com/specimen/EB+Garamond
On 12/27/2021 9:27 PM, Thomas Savary via ntg-context wrote:
Thanks, Hans, for your advice.
a probably more reliable solution is to 'remove bad stuff' from the loaded font by running over the features and removing bad matches (which is less sensitive for order)
I could edit the font features, indeed, but I run a GNU/Linux OS, and Fontforge cannot edit nor generate variable fonts. There seems to be a solution (https://www.youtube.com/watch?v=xoQuWARCUWI https://www.youtube.com/watch?v=xoQuWARCUWI ), but so far beyond my technical capabilities that I cannot consider it.
is that really a google font? afaik it doesn't originate there (unless it among those things that google grabs - and at some point possible discards)
Yes, it is, but not from the beginning. A great Garamond, the original font was designed by Georg Duffner. A few years ago, Google decided to make it a more complete font family : Octavio Pardo has done an excellent job with the bolder versions of EB Garamond and its conversion to a variable font. However, for whatever reasons, he did quite a rush job with the OpenType features ! Many essential features are lacking (despite the needed glyphs still being there), and most present features are poorly implemented, with a lot of typographic nonsense (concerning long s and long Q or the mentioned italic ligatures, for instance).
https://fonts.google.com/specimen/EB+Garamond https://fonts.google.com/specimen/EB+Garamond
I will contact Google Fonts shortly to report on the dozens of problems I have encountered that make the unfixed new version of EB Garamond unusable for anything but the most basic uses.
Fortunately, my significantly more demanding needs for a client were met with the invaluable help from LuaTeX, but that won't be enough for my own projects, much more complex (facsimile of ancient editions), until Google improves this font. So actually the old pre-google fonts from GD are better? Hopefully they
Strange, so basically only the shapes were taken an not the (in this case closely related features)? then stay available someplace. Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
participants (3)
-
Bruce Horrocks
-
Hans Hagen
-
Thomas Savary