<i18n dev> Problems drawing supplemental characters in Java.

Mark Davis ☕️ mark at macchiato.com
Wed Apr 9 10:11:08 UTC 2014


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?*

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.


More information about the i18n-dev mailing list