Skip to content

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