假设你用 Arial 18 字型:
new BufferedImage(1,1,BufferedImage.TYPE_INT_ARGB).getGraphics().getFontMetrics(Font.decode("Arial").deriveFont(18.0f)).stringWidth( "java8" )
new BufferedImage(1,1,BufferedImage.TYPE_INT_ARGB).getGraphics().getFontMetrics(Font.decode("Arial").deriveFont(18.0f)).stringWidth( "java8" )