From 5999226f522df00e970dbc84a94f11df0350f605 Mon Sep 17 00:00:00 2001 From: Phil Race Date: Wed, 9 Dec 2015 15:20:39 -0800 Subject: [PATCH] 8137106: EUDC (End User Defined Characters) are not displayed on Windows with Java 8u60+ Reviewed-by: serb, jgodinez --- .../share/classes/sun/font/TrueTypeFont.java | 33 ++++++++++++++----- .../classes/sun/awt/Win32FontManager.java | 2 +- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/jdk/src/java.desktop/share/classes/sun/font/TrueTypeFont.java b/jdk/src/java.desktop/share/classes/sun/font/TrueTypeFont.java index c4893b6dd60..7668b6572a8 100644 --- a/jdk/src/java.desktop/share/classes/sun/font/TrueTypeFont.java +++ b/jdk/src/java.desktop/share/classes/sun/font/TrueTypeFont.java @@ -176,6 +176,13 @@ public class TrueTypeFont extends FileFont { private String localeFamilyName; private String localeFullName; + public TrueTypeFont(String platname, Object nativeNames, int fIndex, + boolean javaRasterizer) + throws FontFormatException + { + this(platname, nativeNames, fIndex, javaRasterizer, true); + } + /** * - does basic verification of the file * - reads the header table for this font (within a collection) @@ -186,14 +193,17 @@ public class TrueTypeFont extends FileFont { * or fails verification, or there's no usable cmap */ public TrueTypeFont(String platname, Object nativeNames, int fIndex, - boolean javaRasterizer) + boolean javaRasterizer, boolean useFilePool) throws FontFormatException { super(platname, nativeNames); useJavaRasterizer = javaRasterizer; fontRank = Font2D.TTF_RANK; try { - verify(); + verify(useFilePool); init(fIndex); + if (!useFilePool) { + close(); + } } catch (Throwable t) { close(); if (t instanceof FontFormatException) { @@ -280,6 +290,10 @@ public class TrueTypeFont extends FileFont { } + private synchronized FileChannel open() throws FontFormatException { + return open(true); + } + /* This is intended to be called, and the returned value used, * from within a block synchronized on this font object. * ie the channel returned may be nulled out at any time by "close()" @@ -287,7 +301,8 @@ public class TrueTypeFont extends FileFont { * Deadlock warning: FontManager.addToPool(..) acquires a global lock, * which means nested locks may be in effect. */ - private synchronized FileChannel open() throws FontFormatException { + private synchronized FileChannel open(boolean usePool) + throws FontFormatException { if (disposerRecord.channel == null) { if (FontUtilities.isLogging()) { FontUtilities.getLogger().info("open TTF: " + platName); @@ -306,9 +321,11 @@ public class TrueTypeFont extends FileFont { }); disposerRecord.channel = raf.getChannel(); fileSize = (int)disposerRecord.channel.size(); - FontManager fm = FontManagerFactory.getInstance(); - if (fm instanceof SunFontManager) { - ((SunFontManager) fm).addToPool(this); + if (usePool) { + FontManager fm = FontManagerFactory.getInstance(); + if (fm instanceof SunFontManager) { + ((SunFontManager) fm).addToPool(this); + } } } catch (NullPointerException e) { close(); @@ -492,8 +509,8 @@ public class TrueTypeFont extends FileFont { } } - private void verify() throws FontFormatException { - open(); + private void verify(boolean usePool) throws FontFormatException { + open(usePool); } /* sizes, in bytes, of TT/TTC header records */ diff --git a/jdk/src/java.desktop/windows/classes/sun/awt/Win32FontManager.java b/jdk/src/java.desktop/windows/classes/sun/awt/Win32FontManager.java index ee50f24a293..815393eaa1c 100644 --- a/jdk/src/java.desktop/windows/classes/sun/awt/Win32FontManager.java +++ b/jdk/src/java.desktop/windows/classes/sun/awt/Win32FontManager.java @@ -61,7 +61,7 @@ public final class Win32FontManager extends SunFontManager { * enumerate (allow direct use) of EUDC fonts. */ eudcFont = new TrueTypeFont(eudcFile, null, 0, - true); + true, false); } catch (FontFormatException e) { } }