-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8270265: LineBreakMeasurer calculates incorrect line breaks with zero-width characters #23603
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
Conversation
|
👋 Welcome back dgredler! A progress list of the required criteria for merging this PR into |
|
@gredler This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be: You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 307 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@alisenchung, @prrace) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
Webrevs
|
|
Early days but the test fails on macOS |
|
Interesting, I've been testing on Linux. I'll break out the Mac to see what's going on. |
|
@prrace Two findings here: First, it looks like macOS needs an extra pixel of wiggle room in the max string width that we measure; I've given it two pixels, just to be extra sure that the test is stable. Second, the combination of (macOS Dialog font + chars U+200F or U+2067) has HarfBuzz removing the zero-width chars instead of replacing them with the invisible glyph. I think it has something to do with the font tables in that specific macOS font. It looks like in this scenario |
Should you add only these pixels when running the test on macos? Or do these pixels not matter on other platforms? |
alisenchung
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, update copyright years on changed files
It doesn't matter on other platforms, since it's just a little bit of extra leniency. I'm relatively new to the codebase, but the other tests I've seen that run similar checks just add the necessary leniency across the board.
Done, thanks! |
|
@prrace This one is also ready for a second review, if you have time. |
I need to look again at the changes, but I'm going to start by submitting a new build/test job for the latest version. |
|
I just deleted a comment added to the wrong PR! |
|
@prrace Did you get a chance to submit that test job for this PR? If so, were there any failures? Thanks! |
prrace
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Testing passed. And I can't see a specific fault here, but have a sense of not being sure we have enough test coverage. Fingers crossed.
|
/integrate |
|
This PR is ready to be sponsored. Thanks! |
|
/sponsor |
|
Going to push as commit 7fc776e.
Your commit was automatically rebased without conflicts. |
When a string contains zero-width characters,
LineBreakMeasurercalculates line breaks incorrectly.The root cause appears to be that
LineBreakMeasurereventually calls intoStandardGlyphVector.getGlyphInfo(), which derives the glyph advances from the glyph IDs. However, HarfBuzz's default treatment of zero-width characters is to provide the glyph ID of the space character (U+0020) combined with an artificial zero advance (not the font's space glyph advance). Unaware of HarfBuzz's sleight of hand,StandardGlyphVector.getGlyphInfo()retrieves the actual advances of the space glyph (since that was the glyph ID returned) and provides these back up the call chain toLineBreakMeasureret al.I think the correct fix is to use
hb_buffer_set_invisible_glyphto register0xFFFFas the invisible glyph ID with HarfBuzz (matchingCharToGlyphMapper.INVISIBLE_GLYPH_ID).I haven't seen any unwanted side effects, but there is a risk, since this is changing the global HarfBuzz configuration.
For more information on HarfBuzz's behavior in this area, see: https://harfbuzz.github.io/setting-buffer-properties.html
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/23603/head:pull/23603$ git checkout pull/23603Update a local copy of the PR:
$ git checkout pull/23603$ git pull https://git.openjdk.org/jdk.git pull/23603/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 23603View PR using the GUI difftool:
$ git pr show -t 23603Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/23603.diff
Using Webrev
Link to Webrev Comment