diff -r 8240eeda4390 javafx-font/src/com/sun/t2k/T2KFontFile.java --- a/javafx-font/src/com/sun/t2k/T2KFontFile.java Wed Feb 06 10:28:06 2013 -0500 +++ b/javafx-font/src/com/sun/t2k/T2KFontFile.java Fri Feb 08 13:59:30 2013 -0800 @@ -690,6 +690,64 @@ throw new Exception("Font name not found."); } + System.out.println("font name="+fullName + " " + upem + " "); + System.out.println("ascent = " + ascent); + System.out.println("descent = " + descent); + hhea = readTable(hheaTag);//need to read again cause the inner buffer gets reused + int hheaAscent = 0,hheaDescent = 0; + if (hhea != null) { + System.out.println("hhea ascent=" + (hhea.getShort(4))); + System.out.println("hhea descent=" + hhea.getShort(6)); + System.out.println("hhea linegap=" + hhea.getShort(8)); + hheaAscent = hhea.getShort(4); + System.out.println("hheaAscent = " + hheaAscent); + hheaDescent = hhea.getShort(6); + System.out.println("hheaDescent = " + hheaDescent); + } + Buffer os_2 = readTable(os_2Tag); + if (os_2 != null && os_2.capacity() >= 88) { + System.out.println("os_2 TypoAscender=" + (os_2.getShort(68))); + System.out.println("os_2 TypoDescender=" + (os_2.getShort(70))); + System.out.println("os_2 TypoLineGap=" + os_2.getShort(72)); + System.out.println("os_2 WinAscent=" + os_2.getShort(74)); + System.out.println("os_2 WinDescent=" + os_2.getShort(76)); + System.out.println("os_2 xHeight=" + os_2.getShort(86)); + System.out.println("os_2 CapHeight=" + os_2.getShort(88)); + +// ascent = -(float)os_2.getShort(68); +// descent = -(float)os_2.getShort(70); +// linegap = (float)os_2.getShort(72); +// float deltaA = (float)hhea.getShort(4) - (float)os_2.getShort(68); //positives +// float deltaD = (float)hhea.getShort(6) - (float)os_2.getShort(70); //negatives +// float delta = (deltaA + deltaD) / 2; +// System.out.println("adding delta of " + delta); +// if (delta > 0) { +// descent += delta; +// } else { +// ascent -= delta; +// } +// ascent = -(os_2.getShort(68)); +// descent = -(os_2.getShort(70)); + + float os2TypoAscender = os_2.getShort(68); + System.out.println("os2TypoAscender = " + os2TypoAscender); + float os2CapHeight = os_2.getShort(88); + System.out.println("os2CapHeight = " + os2CapHeight); + if (os2CapHeight == 0) os2CapHeight = os2TypoAscender; + System.out.println("os2CapHeight = " + os2CapHeight); + + float topPadding = hheaAscent - os2CapHeight; + System.out.println("topPadding = (hheaAscent - os2CapHeight) = " + topPadding); + if (topPadding > hheaDescent) { + descent = topPadding; + } else { + ascent += (topPadding - hheaDescent); + } + + System.out.println("ascent = " + ascent); + System.out.println("descent = " + descent); + } + /* update the font resource only if the file was decoded * and initialized successfully. */