8353230: Emoji rendering regression after JDK-8208377 #24412
+278
−76
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It looks like this regression actually fits into a longer series of fixes / regressions in this area:
We have two different types of use cases pulling
CharToGlyphMapper
in two different directions: the users who need raw, untransformed glyph info, and the users who need normalized / transformed glyph info.It looks to me like, in the current code base, the only
CharToGlyphMapper
user which requires raw font data is HarfBuzz (explicitly confirmed with the HarfBuzz team here: harfbuzz/harfbuzz#5234).The regression mechanism at play here is that the HarfBuzz font callbacks are currently providing HarfBuzz with transformed glyph info (e.g. ZWJ -> INVISIBLE_GLYPH_ID), which prevents HarfBuzz from recognizing and applying the correct font GSUB substitutions (which involve ZWJ).
In order to fix this without (yet again) breaking metrics and display behavior elsewhere, I've added two methods to
CharToGlyphMapper
which provide access to raw glyph info, to be used by the HarfBuzz font callbacks:charToGlyphRaw(int)
andcharToVariationGlyphRaw(int)
.Note two intricacies related to
CompositeGlyphMapper
:CompositeGlyphMapper.SLOTMASK
to check glyph slots (e.g.FontRunIterator
andCTextPipe
) will "see" invisible glyphs as having come from slot 0. This isn't new, and I think it's OK, but something to be aware of.The glyph cache handling in
CCharToGlyphMapper
(for macOS) also requires care to avoid mixing value types.Please also note that I'm not sure if the tweak to
sunFont.c
is being tested, since FFM is being used by default for HarfBuzz integration. (Is there a plan to remove the JNI version soon?)This PR includes a self-contained regression test. It includes a small font created just for this test, which exercises the ligature / glyph substitution infrastructure. The font tests, including the new regression test, all pass locally on Linux, Windows and macOS (
make test TEST="jtreg:test/jdk/java/awt/font"
).Interestingly, the changes for JDK-7017058 (mentioned above) included a test (
ZWJLigatureTest
) which I think would have caught this last regression, but it depends on optional Windows fonts which I guess do not exist on any commonly-used test infrastructure. This should not be an issue with the new test, since it does not depend on any external fonts.Progress
Issue
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/24412/head:pull/24412
$ git checkout pull/24412
Update a local copy of the PR:
$ git checkout pull/24412
$ git pull https://git.openjdk.org/jdk.git pull/24412/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 24412
View PR using the GUI difftool:
$ git pr show -t 24412
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/24412.diff
Using Webrev
Link to Webrev Comment