opentype.js
opentype.js copied to clipboard
Consider adding support to more GSUB tags?
Expected Behavior
Support to more GSUB features than the current liga and hlig.
Current Behavior
Only supports [liga, hlig] for latn, and [init, medi, fina, rlig] for arab.
Possible Solution
Maybe we can start from the simple ones that doesn’t require additional params like calt, swsh, ccmp, fwid, hwid, pwid etc. Then move on to those that depends on languages and scripts, etc. like locl and vert.
If possible, it would be great to also have support to palt (which relies on GPOS table instead of GSUB).
Context
I was trying to make some Japanese text animations which relies on converting text into paths. The design style of my project strongly relies on the pwid and palt OpenType features, which are exceptionally well supported on the Source Han / Noto CJK font family. I therefore would like to seek possibilities of supporting these features.
+1 - especially for calt. There isn't much out there in terms of tooling with good support for contextual alternates, especially open-source wise. FontForge's implementation is not intuitive (and of course buggy) and in the realm of JS, there seems to exist nothing at all. Even many commercial solutions (Fontself, Glyphr) are relying on opentype.js under the hood and don't support contextual alternates for that reason. It's even in the "Planned" section of the README, so that's good. Let's hope that someone with the skill to do so can make it happen some time soon! 😉
Really wanting to see calt implemented in this library, I dug into the OpenType specs and played around with the code a little. I found that writing support for multiple substitution lookup tables (lookup type 2) needed to be implemented first, before we can write contextual lookup (because those can be referenced). And indeed I managed to do that in PR #449. You can use Substitution.add() and Substitution.getFeature() to add or get the two features ccmp and stch.
If I'm not totally wrong, we should be able to add all the features that are listed with the flags gsub_single_mask and/or gsub_multiple_mask (and only those) in this file from FontForge https://github.com/fontforge/fontforge/blob/8d961b97d76a424c4bec3c4fc6298c200a6ebcc4/fontforge/lookups.c by simply adding them to those two functions.
Testing of and feedback on my branch https://github.com/Connum/opentype.js/tree/add-gsub-lookup-type-2-multiple-sub is encouraged!
+1 absolutely essential!
@Connum have you managed to make any progress on the calt implementation? Really want to see that feature as well.
Let's wait for the outstanding feature PRs, one of them introduces the groundwork for correct handling of feature execution order.
Has there been any progress toward feature execution handling and/or calt implementation? +1 on that feature
It seems like most of the maintainers are currently busy with other projects and work. Also, the users who provided the PRs have often not yet replied to reviews and change requests. So it doesn't look like there will be any progress soon.