getVisualBounds()返回一个全0的维度

时间:2015-12-14 05:19:19

标签: java

以下代码无法读取给定韩语文本的边界矩形& font(NotoSansCJKKr-Regular.otf字体),尽管它在其他Google字体上运行良好。无论如何,这里有什么问题?

String text = "안녕하세요";
BufferedImage buf = new BufferedImage(1, 1 , BufferedImage.TYPE_INT_ARGB);
Graphics2D g2 = (Graphics2D)buf.getGraphics();
setRenderingHints(g2);
FontRenderContext frc = g2.getFontRenderContext();
GlyphVector glyph = g2.getFont().createGlyphVector(frc, text);
Rectangle rect = glyph.getVisualBounds().getBounds();

结果rect:

java.awt.Rectangle[x=0,y=0,width=0,height=0]

0 个答案:

没有答案