--- old/src/java.desktop/share/classes/sun/swing/SwingUtilities2.java 2017-12-07 12:22:09.688742503 -0800 +++ new/src/java.desktop/share/classes/sun/swing/SwingUtilities2.java 2017-12-07 12:22:09.516742508 -0800 @@ -890,8 +890,17 @@ FontMetrics fm, boolean useFPAPI) { - return len == 0 ? 0 : getFontStringWidth(new String(data, offset, len), - fm, useFPAPI); + if (len == 0) { + return 0; + } + if (useFPAPI) { + Rectangle2D bounds = fm.getFont(). + getStringBounds(data, offset, offset + len, + fm.getFontRenderContext()); + return (float) bounds.getWidth(); + } else { + return fm.charsWidth(data, offset, len); + } } public static float getFontStringWidth(String data, FontMetrics fm,