On Thu, 6 Apr 2023 20:00:01 GMT, Phil Race <p...@openjdk.org> wrote:

> This fixes a problem with mixing Emoji and regular text in Webview.
> The Prism implementation expects that Emoji will not be in the same call to 
> drawString as regular glyphs,
> since they need very different handling.
> This fix breaks up the runs webview hands to Prism.
> The test program in the bug report now renders properly (which it never did 
> before in any release)

The intent is to split up the runs passed into 
`WCGraphicsPrismContext::drawString` into separate drawString calls in the same 
way that they would be split if they were drawn in a Label or Text node. It now 
works correctly for text mixed with simple emojis. For emojis with modifiers, 
it is better than it was, but is still not equivalent to the same string drawn 
in a Text node or Label in all cases. I ran the test case attached to 
[JDK-8303494](https://bugs.openjdk.org/browse/JDK-8303494), and the skin tone 
modifiers are now displayed in WebView (just like they are in a Label), but the 
male modifiers are not displayed in WebView (whereas they are in a Label).

If I modify your patch to force splitting the string on each character 
(regardless of whether it is a color glyph or not), then it produces expected 
result, meaning it is then equivalent to drawing the same string in a Label.

Current code (without your fix) produces the following output:

<img width="780" alt="emoji-orig" 
src="https://user-images.githubusercontent.com/34689748/230724098-d91b0d10-b223-4a7b-b6cc-b3a8db0ed491.png";>

This PR produces the following output:

<img width="808" alt="emoji-fix" 
src="https://user-images.githubusercontent.com/34689748/230724107-4b28eef3-ec4c-4c65-a9a0-bfc6cedc5a3f.png";>

Drawing that same string in a Label produces the following output, as does a 
modified version of your patch that forces each character into its own string:

<img width="823" alt="emoji-label" 
src="https://user-images.githubusercontent.com/34689748/230724116-00a2b00b-90ee-4679-9f9b-caa1aef8da8c.png";>

Maybe you need to check something other than (or in addition to) 
"isColorGlyph()" to determine where to split the string?

-------------

PR Comment: https://git.openjdk.org/jfx/pull/1083#issuecomment-1500894519

Reply via email to