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

Work around combining characters being handled as 0-width automatically by some browsers #885

Merged
merged 1 commit into from
Feb 23, 2023

Conversation

dpvc
Copy link
Member

@dpvc dpvc commented Jan 21, 2023

This PR fixes a problem where some accents are misplaced. Combining accents like U+0302 are handled in some fonts by making zero-width characters that have negative left bearing (so they extend to the left over the character that precedes them). Modern browser will position combining characters automatically, whether they are zero-width or not (and they do vertical positioning so that accents are placed over both lower-case and capital letters properly).

MathJax expects the browser to respect the widths of the characters in the font, so when the browser makes it zero-width automatically, MathJax misplaces the accent. This PR makes sure that the accents are properly placed regardless of whether the character is zero-width or not, and regardless of whether the browser forces zero-width for ones that are non-zero in the font itself. This is done by setting the width of the <mjx-c> to the expected width of the character (and removing the padding that used to make it that wide), and using text-align: right so that a zero-width character will move to the right and so be placed properly, while a full-width character will be placed in the right place to begin with.

@dpvc dpvc requested a review from zorkow January 21, 2023 20:54
@dpvc dpvc added this to the v4.0 milestone Jan 21, 2023
Copy link
Member

@zorkow zorkow left a comment

Choose a reason for hiding this comment

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

lgtm.

@dpvc dpvc merged commit 72b33bf into new-default-font Feb 23, 2023
@dpvc dpvc deleted the fix-accents branch February 23, 2023 23:07
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.

None yet

2 participants