--- old/src/java.desktop/share/classes/sun/font/TrueTypeFont.java 2014-12-15 12:06:05.000000000 -0800 +++ new/src/java.desktop/share/classes/sun/font/TrueTypeFont.java 2014-12-15 12:06:05.000000000 -0800 @@ -963,6 +963,18 @@ setStyle(getTableBuffer(os_2Tag)); } + private int fontWidth = 0; + @Override + public int getWidth() { + return (fontWidth > 0) ? fontWidth : super.getWidth(); + } + + private int fontWeight = 0; + @Override + public int getWeight() { + return (fontWeight > 0) ? fontWeight : super.getWeight(); + } + /* TrueTypeFont can use the fsSelection fields of OS/2 table * to determine the style. In the unlikely case that doesn't exist, * can use macStyle in the 'head' table but simpler to @@ -978,8 +990,15 @@ private static final int fsSelectionBoldBit = 0x00020; private static final int fsSelectionRegularBit = 0x00040; private void setStyle(ByteBuffer os_2Table) { + if (os_2Table == null) { + return; + } + if (os_2Table.capacity() >= 8) { + fontWeight = os_2Table.getChar(4) & 0xffff; + fontWidth = os_2Table.getChar(6) & 0xffff; + } /* fsSelection is unsigned short at buffer offset 62 */ - if (os_2Table == null || os_2Table.capacity() < 64) { + if (os_2Table.capacity() < 64) { super.setStyle(); return; }