< prev index next >

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

Print this page

        

*** 23,32 **** --- 23,35 ---- * questions. */ package sun.font; + import sun.java2d.Disposer; + import sun.java2d.DisposerRecord; + import java.awt.Font; import java.awt.font.FontRenderContext; import java.awt.geom.AffineTransform; import java.lang.ref.Reference; import java.lang.ref.SoftReference;
*** 73,82 **** --- 76,87 ---- protected String fullName; /* Full font name (english) */ protected int style = Font.PLAIN; protected FontFamily family; protected int fontRank = DEFAULT_RANK; + private HarfbuzzFaceRef harfbuzzFaceRef; + /* * A mapper can be independent of the strike. * Perhaps the reference to the mapper ought to be held on the * scaler, as it may be implemented via scaler functionality anyway * and so the mapper would be useless if its native portion was
*** 476,485 **** --- 481,507 ---- */ protected long getPlatformNativeFontPtr() { return 0L; } + protected boolean isAAT() { + return false; + } + + synchronized long getHarfbuzzFacePtr() { + if (harfbuzzFaceRef == null) { + long harfbuzzFaceNativePtr = createHarfbuzzFace(isAAT(), getPlatformNativeFontPtr()); + if (harfbuzzFaceNativePtr == 0) return 0; + harfbuzzFaceRef = new HarfbuzzFaceRef(harfbuzzFaceNativePtr); + Disposer.addObjectRecord(this, harfbuzzFaceRef); + } + return harfbuzzFaceRef.harfbuzzFaceNativePtr; + } + + private native long createHarfbuzzFace(boolean aat, long platformNativeFontPtr); + private static native void disposeHarfbuzzFace(long harfbuzzFaceNativePtr); + /* for layout code */ protected long getUnitsPerEm() { return 2048; }
*** 557,562 **** --- 579,596 ---- */ return metrics.ascentX/-metrics.ascentY; } } + private static class HarfbuzzFaceRef implements DisposerRecord { + private final long harfbuzzFaceNativePtr; + + private HarfbuzzFaceRef(long harfbuzzFaceNativePtr) { + this.harfbuzzFaceNativePtr = harfbuzzFaceNativePtr; + } + + @Override + public void dispose() { + disposeHarfbuzzFace(harfbuzzFaceNativePtr); + } + } }
< prev index next >