Skip to content

Instantly share code, notes, and snippets.

@rdp
Created March 7, 2014 18:40
Show Gist options
  • Save rdp/9417231 to your computer and use it in GitHub Desktop.
Save rdp/9417231 to your computer and use it in GitHub Desktop.
java doesn't render two combining diacriticals in thai right
import java.awt.*;
import java.awt.image.BufferedImage;
/**
*/
public class JavaBug {
public static void main(String[] args) {
BufferedImage image = new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB);
Graphics2D graphics2D = image.createGraphics();
StringBuilder text = new StringBuilder();
text.appendCodePoint(3588);
text.appendCodePoint(3640); // combining diacritic mark, should combine with previous character (3588) ??
text.appendCodePoint(3633); // combining diacritic mark, should combine with previous character (3588) ??
System.out.println("size should be one character long, like:" + graphics2D.getFontMetrics().charWidth(3588) + " but instead is:" + graphics2D.getFontMetrics().stringWidth(text.toString()));
System.out.println("this should show one character, and no dash circles;" + text.toString());
}
}
// outputs "expected 8, got size 14"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment