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

Fix the Variation Selector handling #278

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

KojiAndoJC
Copy link

Fix the problem that the variable i was overwritten and the non-default UVS wasn't used when the default UVS exists.

Fix the problem that the variable `i` was overwritten and the non-default UVS wasn't used when the default UVS exists.
Copy link
Member

@devongovett devongovett left a comment

Choose a reason for hiding this comment

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

Thanks. Alternatively, you could make i within the if statement block scoped (via let), so it isn't overwritten?

i = binarySearch(sel.defaultUVS, x =>
codepoint < x.startUnicodeValue ? -1 : codepoint > x.startUnicodeValue + x.additionalCount ? +1 : 0
);
if (i !== -1) {
Copy link
Member

Choose a reason for hiding this comment

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

Should this be the opposite, i.e. i === -1?

Copy link
Author

Choose a reason for hiding this comment

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

I'm sorry I didn't make it clear enough. My pull request fixes two problems.

  1. When the default UVS table exists and its entry not exists (i === -1), the variable i was overwriten and the non-default UVS isn't used.
  2. When the default entry exists ( i !== -1 ), it means "the default glyph (the same glyph as base character) should be used" and checking the non-default UVS is unnecessary. By returning 0, the Variation Selector is ignored correctly here.

Copy link
Member

Choose a reason for hiding this comment

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

A test would help understanding the issue and ensuring the fix is correct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants