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

Feature/ccmp #688

Merged
merged 22 commits into from Apr 10, 2024
Merged

Feature/ccmp #688

merged 22 commits into from Apr 10, 2024

Conversation

TonyJR
Copy link
Contributor

@TonyJR TonyJR commented Mar 22, 2024

Support noto-emoji

Description

add a new contextChecker for ccmp table in tokenizeText()
add a new substitutionFormat for 'lookup sub_5'

Motivation and Context

This PR resoved multi-character emoji #511.
noto-emoji uses the 'ccmp' table to solve the 'multi-character for one emoji' problem, which is a 'Language forms' feature that should be executed before all other features. When parsing the noto-emoji font, I found that 'lookup sub_5' could not be parsed correctly, so I added a substitutionFormat to handle this issue.

How Has This Been Tested?

The unit tests passed and I added a test case for this feature.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I did npm run test and all tests passed green (including code styling checks).
  • I have added tests to cover my changes.
  • My change requires a change to the documentation.
  • I have updated the README accordingly.
  • I have read the CONTRIBUTING document.

@Connum
Copy link
Contributor

Connum commented Mar 22, 2024

This looks like a great addition! Please check why the build is failing: https://github.com/opentypejs/opentype.js/actions/runs/8388243929/job/22972963564?pr=688
This PR also implements some additional substitution formats/types, which might conflict with some other outstanding PRs, but we'll have to check.

test/emoji.js Outdated Show resolved Hide resolved
@TonyJR
Copy link
Contributor Author

TonyJR commented Mar 22, 2024

okay, i removed the file header and fixed a code error.

@Connum
Copy link
Contributor

Connum commented Mar 23, 2024

There are still some lining issues, can you please resolve them? Then you can run npm run lint locally before committing in order to check if everything is OK.

@Connum
Copy link
Contributor

Connum commented Mar 24, 2024

Please also add tests for the ligature substitution format 3 and the substitution type 21 (which should catch the mistake I mentioned in the comment I just added to the associated code)

@TonyJR
Copy link
Contributor Author

TonyJR commented Mar 25, 2024

Please also add tests for the ligature substitution format 3 and the substitution type 21 (which should catch the mistake I mentioned in the comment I just added to the associated code)

I'm trying to add tests for ligature with sub_5, it doesn't work. Maybe I need a few days to fix it. This may modify the code related to "liga" and "rlig".
Any suggestions?

Add a new case in chainingSubstitutionFormat3.
Removed substitutionType 21, it's no longer used
@TonyJR
Copy link
Contributor Author

TonyJR commented Mar 26, 2024

Please also add tests for the ligature substitution format 3 and the substitution type 21 (which should catch the mistake I mentioned in the comment I just added to the associated code)

I removed substitution type 21 and ligatureSubstitutionFormat3. As an alternative, use chainSubstitutionFormat3 to process the sub5 table. Sub5 may exist in liga and ccmp, both of which are processed using ligatureSubstitutionFormat3. I added test code to ensure they work properly.

@Connum
Copy link
Contributor

Connum commented Mar 26, 2024

Thanks for your work! Two more things, then we'll hopefully be ready for review:

  1. please add the information for the newly added test fonts to the test/fonts/LICENSE file (alphabetic order)
  2. Instead of adding a new liga.js test file, please add the tests for the two new lookup formats to test/featureQuery.js in analog form as the existing tests.

Big thanks again!

removed test/liga.js
added new test in test/featureQuery.js
@TonyJR
Copy link
Contributor Author

TonyJR commented Mar 27, 2024

image
@Connum Do you have a todo list of the LookupTypes? I want to implement this part of the code, but I am concerned that it may overlap with your work. So, do you have any suggestions?

@Connum
Copy link
Contributor

Connum commented Mar 27, 2024

Great to see someone being interested in contributing! There is an issue with an overview of TODOs: #374
It might not be up to date, so some things might have been implemented meanwhile. You could also search the code base for instances of "not supported" or "not yet supported".

@TonyJR
Copy link
Contributor Author

TonyJR commented Mar 28, 2024

Great to see someone being interested in contributing! There is an issue with an overview of TODOs: #374 It might not be up to date, so some things might have been implemented meanwhile. You could also search the code base for instances of "not supported" or "not yet supported".

Thanks for your suggestion. I'll finsh the format 5.1,5.2,5.3 in this PR, please merge them later.

@TonyJR
Copy link
Contributor Author

TonyJR commented Apr 2, 2024

@Connum ,

I have added support for 5.1.
For 5.2, I encountered difficulties. I can't find the relevant font, and besides that, I need to read the code related to GlyphClass first. So I'm not sure when I can finish it.
Can you review and merge the current modifications first?

@TonyJR
Copy link
Contributor Author

TonyJR commented Apr 2, 2024

By the way, 5.1 and 5.3 are currently only effective in the 'ccmp' table and cannot be recognized in the 'liga' table. I have tested their performance in Figma (halfbuzz+freetype) and they can take effect anywhere. I think this is caused by an error in the 'language tag', and I will describe it in the issues later

@TonyJR TonyJR requested a review from Connum April 8, 2024 06:39
Copy link
Contributor

@Connum Connum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a few comments for things that need clarification or fixing.

src/features/ccmp/ccmpReplacementLigatures.js Outdated Show resolved Hide resolved
src/features/applySubstitution.js Show resolved Hide resolved
src/features/applySubstitution.js Outdated Show resolved Hide resolved
* @param {ContextRange} range a range of tokens
*/
function ccmpReplacementLigatures(range) {
const script = 'delf';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this should be 'DFLT'?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only place in the codebase with 'delf'.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry this made it through the review process, I didn't follow up because it was marked as resolved. Good catch, thanks!

@TonyJR could you comment on this please? I think it should be DFLT for the default script. And for the future, please let reviewers resolve the conversations. :)

src/features/featureQuery.js Outdated Show resolved Hide resolved
src/features/featureQuery.js Show resolved Hide resolved
src/features/featureQuery.js Show resolved Hide resolved
test/emoji.js Outdated Show resolved Hide resolved
@Connum
Copy link
Contributor

Connum commented Apr 8, 2024

Another thing I noticed: The 'ccmp' tag was already present in the requiredThaiFeatures:

tags: ['liga', 'rlig', 'ccmp']

Should this be present in requiredArabicFeatures and latinFeatures as well?

tags: ['init', 'medi', 'fina', 'rlig']

tags: ['liga', 'rlig']

Or is it maybe not needed at all, because the 'ccmp' is always applied? And if so, does the code make sure of that?

This might also relate to your comment #688 (comment) ? I think you forgot to describe the issue with the language tag for us. Could it be related to the wrong 'delf' script tag I hinted at in the review comment?

@TonyJR TonyJR requested a review from Connum April 10, 2024 07:06
@Connum Connum linked an issue Apr 10, 2024 that may be closed by this pull request
@Connum Connum merged commit be0d441 into opentypejs:master Apr 10, 2024
1 check passed
@Connum Connum added this to the Release 2.0.0 milestone Apr 11, 2024
@Connum Connum self-assigned this Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support multi-character emoji
3 participants