IDEA-157062 AIOOBE at StandardGlyphVector.getLogicalBounds
This adjusts the fix for IDEA-156971, so that original font's style is used to create a native font object. It turns out, changing style does have an impact on char-to-glyph mapping in native code.
This can influence also fake-italic fonts created by CFontManager, but it's only critical for our case, where we must use exactly the same font which is returned by font fallback code.
diff --git a/src/macosx/classes/sun/font/CCompositeGlyphMapper.java b/src/macosx/classes/sun/font/CCompositeGlyphMapper.java
index bb7e6fd..11ee071 100644
--- a/src/macosx/classes/sun/font/CCompositeGlyphMapper.java
+++ b/src/macosx/classes/sun/font/CCompositeGlyphMapper.java
@@ -60,7 +60,7 @@
fallbackFont = new CFont(fallbackFontName, fallbackFontFamilyName);
}
- if (mainFont.isFakeItalic()) fallbackFont = ((CFont)fallbackFont).createItalicVariant();
+ if (mainFont.isFakeItalic()) fallbackFont = ((CFont)fallbackFont).createItalicVariant(false);
slot = compositeFont.addSlot((CFont) fallbackFont);
}
diff --git a/src/macosx/classes/sun/font/CFont.java b/src/macosx/classes/sun/font/CFont.java
index e2e95e8..aea7937 100644
--- a/src/macosx/classes/sun/font/CFont.java
+++ b/src/macosx/classes/sun/font/CFont.java
@@ -182,12 +182,14 @@
isFakeItalic = other.isFakeItalic;
}
- public CFont createItalicVariant() {
+ public CFont createItalicVariant(boolean updateStyle) {
CFont font = new CFont(this, familyName);
font.nativeFontName = fullName;
font.fullName =
fullName + (style == Font.BOLD ? "" : "-") + "Italic-Derived";
- font.style |= Font.ITALIC;
+ if (updateStyle) {
+ font.style |= Font.ITALIC;
+ }
font.isFakeItalic = true;
return font;
}
diff --git a/src/macosx/classes/sun/font/CFontManager.java b/src/macosx/classes/sun/font/CFontManager.java
index d05f549..494bab0 100644
--- a/src/macosx/classes/sun/font/CFontManager.java
+++ b/src/macosx/classes/sun/font/CFontManager.java
@@ -25,23 +25,17 @@
package sun.font;
+import sun.awt.FontConfiguration;
+import sun.awt.HeadlessToolkit;
+import sun.lwawt.macosx.LWCToolkit;
+import sun.misc.ThreadGroupUtils;
+
+import javax.swing.plaf.FontUIResource;
import java.awt.*;
import java.io.File;
import java.security.AccessController;
import java.security.PrivilegedAction;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.Locale;
-import java.util.TreeMap;
-import java.util.Vector;
-
-import javax.swing.plaf.FontUIResource;
-
-import sun.awt.FontConfiguration;
-import sun.awt.HeadlessToolkit;
-import sun.misc.ThreadGroupUtils;
-import sun.lwawt.macosx.*;
+import java.util.*;
public final class CFontManager extends SunFontManager {
private FontConfigManager fcManager = null;
@@ -277,10 +271,10 @@
if (plain == null && bold == null) continue;
if (italic != null && boldItalic != null) continue;
if (plain != null && italic == null) {
- registerGenericFont(plain.createItalicVariant(), true);
+ registerGenericFont(plain.createItalicVariant(true), true);
}
if (bold != null && boldItalic == null) {
- registerGenericFont(bold.createItalicVariant(), true);
+ registerGenericFont(bold.createItalicVariant(true), true);
}
}
}