[prev in list] [next in list] [prev in thread] [next in thread]
List: openjdk-2d-dev
Subject: Re: [OpenJDK 2D-Dev] [PATCH] Make automatic font substitution on macOS work for surrogate pairs
From: Phil Race <philip.race () oracle ! com>
Date: 2016-11-03 17:12:56
Message-ID: bedb364c-5d04-2eb0-5b33-983cab07b54e () oracle ! com
[Download RAW message or body]
I have submitted https://bugs.openjdk.java.net/browse/JDK-8169202
Can you restart this thread with the proper format for a review request
as the subject
"RFR: 8169202: macos] Font substitution does not work for supplementary
characters"
-phil.
On 11/03/2016 07:23 AM, Dmitry Batrak wrote:
> Added an automated version of the test to the webrev -
> http://cr.openjdk.java.net/~avu/rfe_surrogates/webrev.01/
> <http://cr.openjdk.java.net/%7Eavu/rfe_surrogates/webrev.01/>
>
> Best regards,
> Dmitry Batrak
>
> On Tue, Nov 1, 2016 at 5:40 PM, Sergey Bylokhov
> <Sergey.Bylokhov@oracle.com <mailto:Sergey.Bylokhov@oracle.com>> wrote:
>
> Looks fine to me, but the jtreg test will be helpful.
>
> On 27.10.16 11:56, Dmitry Batrak wrote:
>
> Sure, here's the simplest test, that can be used for visual
> inspection:
>
> import javax.swing.*;
> import java.awt.*;
>
> public class SurrogatesFallbackTest {
> public static void main(String[] args) {
> SwingUtilities.invokeLater(() -> {
> JFrame frame = new JFrame();
> JLabel label = new JLabel(new
> String(Character.toChars(0x1d400))); // MATHEMATICAL BOLD
> CAPITAL A
> label.setFont(new Font("Menlo", Font.PLAIN, 36)); //
> expected to fallback to STIXGeneral
> frame.add(label);
> frame.pack();
>
> frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
> frame.setLocationRelativeTo(null);
> frame.setVisible(true);
> });
> }
> }
>
> I can convert it to an automatic test (rendering to a bitmap and
> comparing the result to rendering of 'missing' glyph), and add
> it to the
> webrev, if that makes sense.
>
> Best regards,
> Dmitry Batrak
>
> On Thu, Oct 27, 2016 at 2:17 AM, Philip Race
> <philip.race@oracle.com <mailto:philip.race@oracle.com>
> <mailto:philip.race@oracle.com
> <mailto:philip.race@oracle.com>>> wrote:
>
> Hi,
>
> I can file a bug on this if I can't find one.
> If you can email me the test it will help even if it is
> not checked in.
>
> -phil.
>
> On 10/26/16, 6:28 AM, Dmitry Batrak wrote:
>
> Hello,
>
> 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 in CoreTextSupport.m
> to handle surrogate pairs while performing
> char-to-glyph mapping,
> by encoding non-displayable
> 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,
> could work.
>
> 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
> http://cr.openjdk.java.net/~avu/rfe_surrogates/webrev.00/
> <http://cr.openjdk.java.net/%7Eavu/rfe_surrogates/webrev.00/>
>
> <http://cr.openjdk.java.net/%7Eavu/rfe_surrogates/webrev.00/
> <http://cr.openjdk.java.net/%7Eavu/rfe_surrogates/webrev.00/>>
> (kindly posted by my colleague, having access to
> cr.openjdk.java.net <http://cr.openjdk.java.net>
> <http://cr.openjdk.java.net>).
>
> To my knowledge, there's no ticket in OpenJDK issue
> tracker for
> the proposed enhancement.
> I can submit it via http://bugs.java.com/, if that's
> an obstacle.
>
> Best regards,
> Dmitry Batrak
>
>
>
>
>
> --
> Dmitry Batrak
> Senior Software Developer
> JetBrains
> http://www.jetbrains.com
> The Drive to Develop
>
>
>
> --
> Best regards, Sergey.
>
>
>
>
> --
> Dmitry Batrak
> Senior Software Developer
> JetBrains
> http://www.jetbrains.com
> The Drive to Develop
[Attachment #3 (text/html)]
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
I have submitted <a class="moz-txt-link-freetext" \
href="https://bugs.openjdk.java.net/browse/JDK-8169202">https://bugs.openjdk.java.net/browse/JDK-8169202</a><br>
<br>
Can you restart this thread with the proper format for a review
request<br>
as the subject<br>
<br>
"RFR: 8169202: macos] Font substitution does not work for
supplementary characters"<br>
<br>
-phil.<br>
<br>
<div class="moz-cite-prefix">On 11/03/2016 07:23 AM, Dmitry Batrak
wrote:<br>
</div>
<blockquote
cite="mid:CAET5FPsEZG5kXt98+feoMnaLZfRDOeczai_nkbrAs=axnd-kdw@mail.gmail.com"
type="cite">
<div dir="ltr">
<div>
<div>Added an automated version of the test to the webrev - <a
moz-do-not-send="true"
href="http://cr.openjdk.java.net/%7Eavu/rfe_surrogates/webrev.01/"
rel="noreferrer" \
target="_blank">http://cr.openjdk.java.net/~av<wbr>u/rfe_surrogates/webrev.01/</a><br>
<br>
</div>
Best regards,<br>
</div>
Dmitry Batrak<br>
<div>
<div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Tue, Nov 1, 2016 at 5:40 PM,
Sergey Bylokhov <span dir="ltr"><<a
moz-do-not-send="true"
href="mailto:Sergey.Bylokhov@oracle.com"
target="_blank">Sergey.Bylokhov@oracle.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">Looks
fine to me, but the jtreg test will be helpful.<br>
<br>
On 27.10.16 11:56, Dmitry Batrak wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
Sure, here's the simplest test, that can be used for
visual inspection:<br>
<br>
import javax.swing.*;<br>
import java.awt.*;<br>
<br>
public class SurrogatesFallbackTest {<br>
public static void main(String[] args) {<br>
SwingUtilities.invokeLater(() -> {<br>
JFrame frame = new JFrame();<br>
JLabel label = new JLabel(new<br>
String(Character.toChars(0x1d4<wbr>00))); //
MATHEMATICAL BOLD CAPITAL A<br>
label.setFont(new Font("Menlo",
Font.PLAIN, 36)); //<br>
expected to fallback to STIXGeneral<br>
frame.add(label);<br>
frame.pack();<br>
\
frame.setDefaultCloseOperation<wbr>(WindowConstants.EXIT_ON_CLOSE<wbr>);<br>
frame.setLocationRelativeTo(nu<wbr>ll);<br>
frame.setVisible(true);<br>
});<br>
}<br>
}<br>
<br>
I can convert it to an automatic test (rendering to
a bitmap and<br>
comparing the result to rendering of 'missing'
glyph), and add it to the<br>
webrev, if that makes sense.<br>
<br>
Best regards,<br>
Dmitry Batrak<br>
<br>
On Thu, Oct 27, 2016 at 2:17 AM, Philip Race <<a
moz-do-not-send="true"
href="mailto:philip.race@oracle.com"
target="_blank">philip.race@oracle.com</a><br>
<mailto:<a moz-do-not-send="true"
href="mailto:philip.race@oracle.com"
target="_blank">philip.race@oracle.com</a><wbr>>>
wrote:<br>
<br>
Hi,<br>
<br>
I can file a bug on this if I can't find one.<br>
If you can email me the test it will help even
if it is not checked in.<br>
<br>
-phil.<br>
<br>
On 10/26/16, 6:28 AM, Dmitry Batrak wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello,<br>
<br>
I'd like to propose a patch to make automatic
font substitution on<br>
macOS work for surrogate pairs.<br>
I have a Contributor status via agreement
signed by JetBrains,<br>
hope someone can sponsor the patch.<br>
<br>
Currently, if requested font cannot render a
Unicode character<br>
represented by a surrogate pair,<br>
no substitution is performed - Font.canDisplay
will return false,<br>
and the character will be<br>
rendered as a 'missing' glyph. This behaviour
doesn't violate any<br>
specification, but it looks like<br>
it can be easily improved, as underlying OS
framework used under<br>
the hood does support surrogate pairs.<br>
<br>
The proposed change consists of two parts.
First part is adjusting<br>
the code in CoreTextSupport.m<br>
to handle surrogate pairs while performing
char-to-glyph mapping,<br>
by encoding non-displayable<br>
surrogate pairs using negative values of the
codepoint, similar to<br>
how non-displayable BMP characters<br>
are encoded. Second part is fixing the
rendering code (in<br>
CGGlyphImages.m), where wrong type was used<br>
to pass character values around, so that code
for surrogate pairs<br>
handling, already present there,<br>
could work.<br>
<br>
I didn't include a test for this change, as it
would depend on<br>
OS-specific font fallback mechanism<br>
and fonts installed, but I can create one that
will work on a<br>
latest version of macOS with default<br>
fonts, if needed.<br>
<br>
Webrev for the fix is available at<br>
<a moz-do-not-send="true"
\
href="http://cr.openjdk.java.net/%7Eavu/rfe_surrogates/webrev.00/"
rel="noreferrer" \
target="_blank">http://cr.openjdk.java.net/~av<wbr>u/rfe_surrogates/webrev.00/</a><br>
<<a moz-do-not-send="true"
\
href="http://cr.openjdk.java.net/%7Eavu/rfe_surrogates/webrev.00/"
rel="noreferrer" \
target="_blank">http://cr.openjdk.java.net/%7<wbr>Eavu/rfe_surrogates/webrev.00/</a><wbr>><br>
(kindly posted by my colleague, having access
to<br>
<a moz-do-not-send="true"
href="http://cr.openjdk.java.net"
rel="noreferrer" target="_blank">cr.openjdk.java.net</a>
<<a moz-do-not-send="true"
href="http://cr.openjdk.java.net"
rel="noreferrer" \
target="_blank">http://cr.openjdk.java.net</a>>).<br> <br>
To my knowledge, there's no ticket in OpenJDK
issue tracker for<br>
the proposed enhancement.<br>
I can submit it via <a moz-do-not-send="true"
href="http://bugs.java.com/" rel="noreferrer"
target="_blank">http://bugs.java.com/</a>, if
that's an obstacle.<br>
<br>
Best regards,<br>
Dmitry Batrak<br>
</blockquote>
<br>
<br>
<br>
<span class="m_5886191096003718632HOEnZb"><font
color="#888888">
<br>
--<br>
Dmitry Batrak<br>
Senior Software Developer<br>
JetBrains<br>
<a moz-do-not-send="true"
href="http://www.jetbrains.com"
rel="noreferrer" \
target="_blank">http://www.jetbrains.com</a><br> The Drive to Develop<br>
</font></span></blockquote>
<span class="m_5886191096003718632HOEnZb"><font
color="#888888">
<br>
<br>
-- <br>
Best regards, Sergey.<br>
</font></span></blockquote>
</div>
<br>
<br clear="all">
<br>
-- <br>
<div class="m_5886191096003718632gmail_signature"
data-smartmail="gmail_signature">
<div dir="ltr">
<div>
<div dir="ltr">Dmitry Batrak<br>
Senior Software Developer<br>
JetBrains<br>
<a moz-do-not-send="true"
href="http://www.jetbrains.com" \
target="_blank">http://www.jetbrains.com</a><br> The Drive to Develop<br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
<br>
</body>
</html>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic