I am using java to draw some text, but it is hard for me to calculate the string\'s width. for example: zheng中国... How long will this string occupy?
You can find it from Font.getStringBounds():
String string = "Hello World"; // Passing or initializing an instance of Font. Font font = ...; int width = (int) font.getStringBounds(string, new FontRenderContext(font.getTransform(), false, false)).getBounds().getWidth();