[OpenJDK 2D-Dev] [PATCH] Make automatic font substitution on macOS work for surrogate pairs
dmitry.batrak at jetbrains.com
Wed Oct 26 13:28:58 UTC 2016
I'd like to propose a patch to make automatic font substitution on macOS
work for surrogate pairs.
I have a Contributor status via agreement signed by JetBrains, hope someone
can sponsor the patch.
Currently, if requested font cannot render a Unicode character represented
by a surrogate pair,
no substitution is performed - Font.canDisplay will return false, and the
character will be
rendered as a 'missing' glyph. This behaviour doesn't violate any
specification, but it looks like
it can be easily improved, as underlying OS framework used under the hood
does support surrogate pairs.
The proposed change consists of two parts. First part is adjusting the code
to handle surrogate pairs while performing char-to-glyph mapping, by
surrogate pairs using negative values of the codepoint, similar to how
non-displayable BMP characters
are encoded. Second part is fixing the rendering code (in CGGlyphImages.m),
where wrong type was used
to pass character values around, so that code for surrogate pairs handling,
already present there,
I didn't include a test for this change, as it would depend on OS-specific
font fallback mechanism
and fonts installed, but I can create one that will work on a latest
version of macOS with default
fonts, if needed.
Webrev for the fix is available at
(kindly posted by my colleague, having access to cr.openjdk.java.net).
To my knowledge, there's no ticket in OpenJDK issue tracker for the
I can submit it via http://bugs.java.com/, if that's an obstacle.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the 2d-dev