diff --git a/src/share/classes/sun/font/FileFont.java b/src/share/classes/sun/font/FileFont.java index adce6d94e5d176806ad12465376b45bf0bfb0980..9c72251dffc81644c23f386bb4441f6bf1364f2d 100644 --- a/src/share/classes/sun/font/FileFont.java +++ b/src/share/classes/sun/font/FileFont.java @@ -163,7 +163,9 @@ public abstract class FileFont extends PhysicalFont { } } } - scaler.dispose(); + if (scaler != null) { + scaler.dispose(); + } scaler = FontScaler.getNullScaler(); } diff --git a/src/share/classes/sun/font/StandardGlyphVector.java b/src/share/classes/sun/font/StandardGlyphVector.java index c452dd97c1d9a0b7402f0b0962dd8ee01f9068aa..66001682dffce7ac3abd2a6d2a99140fe1a57085 100644 --- a/src/share/classes/sun/font/StandardGlyphVector.java +++ b/src/share/classes/sun/font/StandardGlyphVector.java @@ -1740,8 +1740,9 @@ public class StandardGlyphVector extends GlyphVector { tx, sgv.font.getStyle(), aa, fm); - - FontStrike strike = sgv.font2D.getStrike(desc); // !!! getStrike(desc, false) + // Get the strike via the handle. Shouldn't matter + // if we've invalidated the font but its an extra precaution. + FontStrike strike = sgv.font2D.handle.font2D.getStrike(desc); // !!! getStrike(desc, false) return new GlyphStrike(sgv, strike, dx, dy); } diff --git a/src/share/classes/sun/font/SunFontManager.java b/src/share/classes/sun/font/SunFontManager.java index bd55f8bbd9c29a45e1771b3d803e246b8352cd88..bb069a3a06ca672e510ab7aa4f1e964035dd9bac 100644 --- a/src/share/classes/sun/font/SunFontManager.java +++ b/src/share/classes/sun/font/SunFontManager.java @@ -2619,6 +2619,9 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE { physicalFonts.remove(oldFont.fullName); fullNameToFont.remove(oldFont.fullName.toLowerCase(Locale.ENGLISH)); FontFamily.remove(oldFont); + if (oldFont instanceof FileFont) { + ((FileFont)oldFont).deregisterFontAndClearStrikeCache(); + } if (localeFullNamesToFont != null) { Map.Entry[] mapEntries = diff --git a/src/share/classes/sun/font/TrueTypeFont.java b/src/share/classes/sun/font/TrueTypeFont.java index e60a74b7b055edb8498a7cc2a490c7ef78a260e7..5a3180e154662663b08aa03d731a7e13040ac964 100644 --- a/src/share/classes/sun/font/TrueTypeFont.java +++ b/src/share/classes/sun/font/TrueTypeFont.java @@ -1037,6 +1037,9 @@ public class TrueTypeFont extends FileFont { if (head_Table != null && head_Table.capacity() >= 18) { ShortBuffer sb = head_Table.asShortBuffer(); upem = sb.get(9) & 0xffff; + if (upem < 16 || upem > 16384) { + upem = 2048; + } } ByteBuffer os2_Table = getTableBuffer(os_2Tag);