Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format not yet supported error when trying to render Noto Nastaliq Urdu #627

Open
bennlich opened this issue Oct 20, 2023 · 7 comments
Open
Labels
font features Spec Related to the implementation of the Opentype specification

Comments

@bennlich
Copy link

I'm trying to generate a font path with Noto Nastaliq Urdu for some Urdu text: اردو

let chars = 'اردو'
parsedFont.getPath(chars, 0, 0, 1200)

But I get the following error:

Uncaught (in promise) Error: lookupType: 7 - substFormat: 1 is not yet supported
    at FeatureQuery.getLookupMethod (opentype.js:12342:20)
    at FeatureQuery.lookupFeature (opentype.js:12396:32)
    at opentype.js:12753:43
    at Array.forEach (<anonymous>)
    at Bidi.arabicRequiredLigatures (opentype.js:12751:28)
    at opentype.js:12993:34
    at Array.forEach (<anonymous>)
    at Bidi.applyArabicRequireLigatures (opentype.js:12992:13)
    at Bidi.applyFeaturesToContexts (opentype.js:13028:38)
    at Bidi.processText (opentype.js:13046:15)

I'd be happy to try to contribute to fix this, but I'm not sure what this means / where to begin :)

Your Environment

  • Version used: opentype v1.3.4
  • Font used: Noto Nastaliq Urdu
  • Browser Name and version: Chrome 118.0.5993.70
  • Operating System and version (desktop or mobile): mac os 13.4
@Connum
Copy link
Contributor

Connum commented Oct 20, 2023

Type 7 format 1 support has been added with #486, but there hasn't been a new release since then. Please try with the state of the current master.

@bennlich
Copy link
Author

bennlich commented Oct 21, 2023

Aha. Using master, I get a different error. This time it's Type 5 format 1:

Uncaught (in promise) Error: lookupType: 5 - substFormat: 1 is not yet supported
    at FeatureQuery.getLookupMethod (opentype.js:11871:15)
    at FeatureQuery.lookupFeature (opentype.js:11898:25)
    at Bidi.arabicRequiredLigatures (opentype.js:12194:38)
    at Bidi.applyArabicRequireLigatures (opentype.js:12510:39)
    at Bidi.applyFeaturesToContexts (opentype.js:12549:35)
    at Bidi.processText (opentype.js:12571:12)
    at Bidi.getTextGlyphs (opentype.js:12579:10)
    at Font.stringToGlyphIndexes (opentype.js:12688:17)
    at Font.stringToGlyphs (opentype.js:12691:26)
    at Font.forEachGlyph (opentype.js:12744:25)

@Connum
Copy link
Contributor

Connum commented Oct 21, 2023

Congratulations, you found another not yet supported feature. 😉

@Connum Connum added Spec Related to the implementation of the Opentype specification font features labels Oct 21, 2023
@bennlich
Copy link
Author

If I wanted to work on adding support for this, how would I start? Can you outline the path?

@Connum
Copy link
Contributor

Connum commented Oct 21, 2023

More helping hands would be great!
In your case the message stems from src/features/featureQuery.js

All in all it's "just" a matter of reading the OpenType specification and handling the binary font data and the information within according to it. Mind you though that font feature implementation is probably the most complicated place to get your hands dirty.

I would take a look at how other features are implemented, comparing that to the specification in parallel. Sometimes it's also helpful to write the test cases first and work your way back from that.

@bennlich
Copy link
Author

Thank you! I've been poking around today on a long train ride. Keeping track here of what I've learned so far.

The substitution spec is here: https://learn.microsoft.com/en-us/typography/opentype/spec/gsub

I need to implement lookup type 5.1 Contextual Substitution Format 1

I think the steps are something like:

  • add a contextSubstitutionFormat1 to featureQuery.js. This piece is responsible for determining which glyphs in which positions get substituted or deleted
  • add case 51 to getLookupMethod() (referencing the contextSubstitutionFormat1 above)
  • add case 51 to lookupFeature() (seems to be mostly boilerplate)
  • add case 51 to applySubstitution.js for actually executing the substitution

This substitution uses a Sequence Context Format 1. I don't think this format has been implemented anywhere else yet (I haven't come across it anywhere in the code). It is the same format used in GPOS 7.1, but I don't think that's implemented either.

I'm going to look into what the tests look like next.

@Connum
Copy link
Contributor

Connum commented Oct 21, 2023

So great seeing someone new getting involved! You could also have a look at the outstanding PRs, some things might already have been implemented. Let us know if you have any questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
font features Spec Related to the implementation of the Opentype specification
Projects
None yet
Development

No branches or pull requests

2 participants