我目前需要得到一个角色的真实身高。我知道 getDecsent()、getAscent()、...等函数,但它们只允许获取有关孔字体的值(在其上下文中)。我也尝试了使用 getStringBounds() 的方式,但这是同一个故事。
正如标题所说,我正在寻找一种方法来一次只获取一个字符的高度值。
例如'N'比'n'高,'I'比'i'高一点等等
谢谢你的时间
我目前需要得到一个角色的真实身高。我知道 getDecsent()、getAscent()、...等函数,但它们只允许获取有关孔字体的值(在其上下文中)。我也尝试了使用 getStringBounds() 的方式,但这是同一个故事。
正如标题所说,我正在寻找一种方法来一次只获取一个字符的高度值。
例如'N'比'n'高,'I'比'i'高一点等等
谢谢你的时间
用这个
Rectangle2D bounds = font.getStringBounds("put your string here", context);
//font can be set to whatever you want
//my suggestion is that you use the same font for both characters
//context is a object of FontRenderContext
System.out.println(bounds.getHeight());
//Instead of just printing it you could do this a second time and compare the 2 strings