src/java.desktop/share/classes/sun/font/TrueTypeFont.java

Print this page

        

*** 961,970 **** --- 961,982 ---- @Override protected void setStyle() { 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 * fall back to super class algorithm of looking for well known string. * A very few fonts don't specify this information, but I only
*** 976,987 **** */ private static final int fsSelectionItalicBit = 0x00001; private static final int fsSelectionBoldBit = 0x00020; private static final int fsSelectionRegularBit = 0x00040; private void setStyle(ByteBuffer os_2Table) { /* fsSelection is unsigned short at buffer offset 62 */ ! if (os_2Table == null || os_2Table.capacity() < 64) { super.setStyle(); return; } int fsSelection = os_2Table.getChar(62) & 0xffff; int italic = fsSelection & fsSelectionItalicBit; --- 988,1006 ---- */ private static final int fsSelectionItalicBit = 0x00001; 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.capacity() < 64) { super.setStyle(); return; } int fsSelection = os_2Table.getChar(62) & 0xffff; int italic = fsSelection & fsSelectionItalicBit;