--- old/src/java.desktop/macosx/classes/sun/font/CFont.java 2015-11-12 21:21:15.000000000 -0800 +++ new/src/java.desktop/macosx/classes/sun/font/CFont.java 2015-11-12 21:21:15.000000000 -0800 @@ -31,12 +31,13 @@ import java.awt.geom.GeneralPath;; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; +import java.util.ArrayList; // Right now this class is final to avoid a problem with native code. // For some reason the JNI IsInstanceOf was not working correctly // so we are checking the class specifically. If we subclass this // we need to modify the native code in CFontWrapper.m -public final class CFont extends PhysicalFont { +public final class CFont extends PhysicalFont implements FontSubstitution { /* CFontStrike doesn't call these methods so they are unimplemented. * They are here to meet the requirements of PhysicalFont, needed @@ -76,6 +77,20 @@ throw new InternalError("Not implemented"); } + @Override + protected long getLayoutTableCache() { + return getLayoutTableCacheNative(getNativeFontPtr()); + } + + @Override + protected byte[] getTableBytes(int tag) { + return getTableBytesNative(getNativeFontPtr(), tag); + } + + private native synchronized long getLayoutTableCacheNative(long nativeFontPtr); + + private native byte[] getTableBytesNative(long nativeFontPtr, int tag); + private static native long createNativeFont(final String nativeFontName, final int style); private static native void disposeNativeFont(final long nativeFontPtr); @@ -179,10 +194,51 @@ protected synchronized long getNativeFontPtr() { if (nativeFontPtr == 0L) { nativeFontPtr = createNativeFont(nativeFontName, style); -} + } return nativeFontPtr; } + static native void getCascadeList(long nativeFontPtr, ArrayList listOfString); + + private CompositeFont createCompositeFont() { + ArrayList listOfString = new ArrayList(); + getCascadeList(nativeFontPtr, listOfString); + + FontManager fm = FontManagerFactory.getInstance(); + int numFonts = 1 + listOfString.size(); + PhysicalFont[] fonts = new PhysicalFont[numFonts]; + fonts[0] = this; + int idx = 1; + for (String s : listOfString) { + if (s.equals(".AppleSymbolsFB")) { + // Don't know why we get the weird name above .. replace. + s = "AppleSymbols"; + } + Font2D f2d = fm.findFont2D(s, Font.PLAIN, FontManager.NO_FALLBACK); + if (f2d == null || f2d == this) { + continue; + } + fonts[idx++] = (PhysicalFont)f2d; + } + if (idx < fonts.length) { + PhysicalFont[] orig = fonts; + fonts = new PhysicalFont[idx]; + System.arraycopy(orig, 0, fonts, 0, idx); + } + CompositeFont compFont = new CompositeFont(fonts); + compFont.mapper = new CCompositeGlyphMapper(compFont); + return compFont; + } + + private CompositeFont compFont; + + public CompositeFont getCompositeFont2D() { + if (compFont == null) { + compFont = createCompositeFont(); + } + return compFont; + } + protected synchronized void finalize() { if (nativeFontPtr != 0) { disposeNativeFont(nativeFontPtr);