--- old/src/java.desktop/share/classes/javax/swing/text/GlyphPainter1.java 2017-11-14 12:43:51.631783500 +0530 +++ new/src/java.desktop/share/classes/javax/swing/text/GlyphPainter1.java 2017-11-14 12:43:50.796616500 +0530 @@ -58,8 +58,9 @@ TabExpander e, float x) { sync(v); Segment text = v.getText(p0, p1); - int[] justificationData = getJustificationData(v); - int width = Utilities.getTabbedTextWidth(v, text, metrics, (int) x, e, p0, + int[] justificationData = getJustificationData(v); + + float width = Utilities.getTabbedTextWidth(v, text, metrics, x, e, p0, justificationData); SegmentCache.releaseSharedSegment(text); return width; @@ -222,10 +223,15 @@ @SuppressWarnings("deprecation") void sync(GlyphView v) { Font f = v.getFont(); - if ((metrics == null) || (! f.equals(metrics.getFont()))) { + FontMetrics fm = null; + Container c = v.getContainer(); + if (c != null) { + fm = c.getFontMetrics(f); + } + if ((metrics == null) || (! f.equals(metrics.getFont())) + || (! metrics.equals(fm))) { // fetch a new FontMetrics - Container c = v.getContainer(); - metrics = (c != null) ? c.getFontMetrics(f) : + metrics = (c != null) ? fm : Toolkit.getDefaultToolkit().getFontMetrics(f); } }