See the discussion: http://mail.openjdk.java.net/pipermail/swing-dev/2016-March/005622.html
-----------------
i.e what about attributes on the font such as "tracking" ?
or on the graphics such as FRACTIONALMETRICS
It looks like Swing might already fail if that were used.
Look at this code :-
public static int stringWidth(JComponent c, FontMetrics fm, String string){
if (string == null || string.equals("")) {
return 0;
}
boolean needsTextLayout = ((c != null) &&
(c.getClientProperty(TextAttribute.NUMERIC_SHAPING) != null));
if (needsTextLayout) {
synchronized(charsBufferLock) {
int length = syncCharsBuffer(string);
needsTextLayout = isComplexLayout(charsBuffer, 0, length);
}
}
if (needsTextLayout) {
TextLayout layout = createTextLayout(c, string,
fm.getFont(), fm.getFontRenderContext());
return (int) layout.getAdvance();
} else {
return fm.stringWidth(string);
}
}
The only thing Swing is looking at is one TextAttribute and whether we have complex text.
That is not enough. This is an existing implementation issue but one we should fix here.
-----------------