<i18n dev> Problems drawing supplemental characters in Java.

Naoto Sato naoto.sato at oracle.com
Wed Apr 9 16:17:06 UTC 2014


Hi Mark,

On 4/9/14, 3:11 AM, Mark Davis ☕️ wrote:
> I'm having some trouble with drawing supplemental characters in Java. It
> appears to be due to bugs in Java.
>
> *First, how do I report this? And second, can anyone think of a
> work-around?*

Here is the link to report an issue against JDK:

http://bugreport.java.com/bugreport/

Please choose "classes_2d" as the subcategory.

>
> This is on a Mac OS 10.9.2, JDK 7, and I am rendering a number of
> characters in a loop.
>
> When I call
>
>                  graphics.drawString(s, xStart, ascent);
>
> Each supplemental character that shares the same first char (high
> surrogate) gets the same image (see attachments).
>
> It appears that it is caching by char instead of by code point.
>
>
> To work around the problem, I tried changing the code to draw glyph
> vectors instead.
>
>                  FontRenderContext frc = graphics.getFontRenderContext();
>
>                  GlyphVector gv = myFont.createGlyphVector(frc, s);
>
>                  ...
>
>                  Shape shape = gv.getOutline(xStart, ascent);
>
>                  graphics.draw(shape);
>
> To my surprise, it got even worse: I get an unknown glyph after each
> image. See attachments.
>
> It appears that when it is advancing through the string to get the
> glyphs, it is picking up the glyph ID for the code point, but then it is
> only advancing by 1, so it is always picking up garbage after each
> character.

Yeah, your explanation does sound like what's happening in the font 
rendering on MacOSX. Phil/Mike, do you have any idea what's going on?

Naoto


More information about the i18n-dev mailing list