aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDmitry Batrak <Dmitry.Batrak@jetbrains.com>2017-01-24 11:45:38 +0300
committerDmitry Batrak <Dmitry.Batrak@jetbrains.com>2017-01-24 11:45:38 +0300
commit49d28094dde7dac40758647bbeb2fa8404d051f5 (patch)
treeda25fbb5b0f20580782fadd66f1a1e59cff4363e /src
parent93224482088461c73bab49c119758a9cf1272123 (diff)
downloadjdk8u_jdk-49d28094dde7dac40758647bbeb2fa8404d051f5.tar.gz
Fix inconsistent character width calculation for San Francisco font on macOSjb8u112-b705
The fix makes sure that font fallback is consistently applied in different code path. Previously sun.font.CCompositeGlyphMapper.convertToGlyph switched to fallback path if returned Postscript font name didn't match the original font name. It turns out, this is the case for .SFNSText-Regular (potentially, because of the way we register it in AWTFont.m)
Diffstat (limited to 'src')
-rw-r--r--src/macosx/classes/sun/font/CCompositeGlyphMapper.java2
-rw-r--r--src/macosx/native/sun/font/CCharToGlyphMapper.m6
-rw-r--r--src/macosx/native/sun/font/CoreTextSupport.h4
-rw-r--r--src/macosx/native/sun/font/CoreTextSupport.m15
4 files changed, 14 insertions, 13 deletions
diff --git a/src/macosx/classes/sun/font/CCompositeGlyphMapper.java b/src/macosx/classes/sun/font/CCompositeGlyphMapper.java
index 11ee071fe7..bc47304135 100644
--- a/src/macosx/classes/sun/font/CCompositeGlyphMapper.java
+++ b/src/macosx/classes/sun/font/CCompositeGlyphMapper.java
@@ -44,7 +44,7 @@ public final class CCompositeGlyphMapper extends CompositeGlyphMapper {
String fallbackFontName = fallbackFontInfo[0];
String fallbackFontFamilyName = fallbackFontInfo[1];
if (fallbackFontName == null || fallbackFontFamilyName == null) {
- return missingGlyph;
+ return compositeGlyphCode(0, glyphCode);
}
int slot = compositeFont.findSlot(fallbackFontName);
diff --git a/src/macosx/native/sun/font/CCharToGlyphMapper.m b/src/macosx/native/sun/font/CCharToGlyphMapper.m
index a36a213d21..da735886e0 100644
--- a/src/macosx/native/sun/font/CCharToGlyphMapper.m
+++ b/src/macosx/native/sun/font/CCharToGlyphMapper.m
@@ -124,16 +124,16 @@ Java_sun_font_CCompositeGlyphMapper_nativeCodePointToGlyph
{
JNF_COCOA_ENTER(env);
AWTFont *awtFont = (AWTFont *)jlong_to_ptr(awtFontPtr);
- CFStringRef fontNames[2];
+ CFStringRef fontNames[] = {NULL, NULL};
CGGlyph glyph = CTS_CopyGlyphAndFontNamesForCodePoint(awtFont, (UnicodeScalarValue)codePoint, fontNames);
if (glyph > 0) {
jstring fontName = (jstring)JNFNSToJavaString(env, (NSString *)fontNames[0]);
- if (fontNames[0]) CFRelease(fontNames[0]);
(*env)->SetObjectArrayElement(env, resultArray, 0, fontName);
jstring fontFamilyName = (jstring)JNFNSToJavaString(env, (NSString *)fontNames[1]);
- if (fontNames[1]) CFRelease(fontNames[1]);
(*env)->SetObjectArrayElement(env, resultArray, 1, fontFamilyName);
}
+ if (fontNames[0]) CFRelease(fontNames[0]);
+ if (fontNames[1]) CFRelease(fontNames[1]);
return glyph;
JNF_COCOA_EXIT(env);
}
diff --git a/src/macosx/native/sun/font/CoreTextSupport.h b/src/macosx/native/sun/font/CoreTextSupport.h
index 66ca1b115a..27a09fccba 100644
--- a/src/macosx/native/sun/font/CoreTextSupport.h
+++ b/src/macosx/native/sun/font/CoreTextSupport.h
@@ -54,7 +54,9 @@ CTFontRef CTS_CopyCTFallbackFontAndGlyphForJavaGlyphCode(const AWTFont *font, co
// Returns the substituted font, and places the appropriate glyph into "glyphRef"
CTFontRef CTS_CopyCTFallbackFontAndGlyphForUnicode(const AWTFont *font, const UTF16Char *charRef, CGGlyph *glyphRef, int count);
-// Transform a single Unicode character into glyphs. Names of the relevant font (original or substituted one) are also returned
+// Transform a single Unicode character code into glyph code.
+// Names of the relevant font are also returned, if the substitution is used.
+// Non-null components of fontNames array should always be released by the calling code, regardless of the returned value.
CGGlyph CTS_CopyGlyphAndFontNamesForCodePoint(const AWTFont *font, const UnicodeScalarValue codePoint, CFStringRef fontNames[]);
// Breakup a 32 bit unicode value into the component surrogate pairs
diff --git a/src/macosx/native/sun/font/CoreTextSupport.m b/src/macosx/native/sun/font/CoreTextSupport.m
index 5bd6663767..62b615db34 100644
--- a/src/macosx/native/sun/font/CoreTextSupport.m
+++ b/src/macosx/native/sun/font/CoreTextSupport.m
@@ -144,8 +144,8 @@ void CTS_GetGlyphsAsIntsForCharacters
}
/*
- * Returns glyph code for a given Unicode character. Names of the relevant font (original or substituted one)
- * are also returned.
+ * Returns glyph code for a given Unicode character.
+ * Names of the corresponding substituted font are also returned if substitution is performed.
*/
CGGlyph CTS_CopyGlyphAndFontNamesForCodePoint
(const AWTFont *font, const UnicodeScalarValue codePoint, CFStringRef fontNames[])
@@ -163,16 +163,15 @@ CGGlyph CTS_CopyGlyphAndFontNamesForCodePoint
CTFontRef actualFonts[count];
GetFontsAndGlyphsForCharacters(fontRef, unicodes, glyphs, glyphsAsInts, actualFonts, count);
CGGlyph glyph = glyphs[0];
- if (glyph > 0) {
- bool substitutionHappened = glyphsAsInts[0] < 0;
- CTFontRef actualFont = substitutionHappened ? actualFonts[0] : fontRef;
+ bool substitutionHappened = glyphsAsInts[0] < 0;
+ if (glyph > 0 && substitutionHappened) {
+ CTFontRef actualFont = actualFonts[0];
CFStringRef fontName = CTFontCopyPostScriptName(actualFont);
CFStringRef familyName = CTFontCopyFamilyName(actualFont);
- if (substitutionHappened) {
- CFRelease(actualFont);
- }
+ CFRelease(actualFont);
fontNames[0] = fontName;
fontNames[1] = familyName;
+ if (!fontName || !familyName) glyph = 0;
}
return glyph;
}