From 7763a55c4c5fe38f7ae8b982a3a3f161228ff960 Mon Sep 17 00:00:00 2001 From: prr Date: Mon, 17 Oct 2016 15:28:05 -0700 Subject: [PATCH] 8089573: [macosx] Incorrect char to glyph mapping printing on OSX 10.10 Reviewed-by: serb, vadim --- src/macosx/native/sun/font/AWTFont.m | 48 ++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/src/macosx/native/sun/font/AWTFont.m b/src/macosx/native/sun/font/AWTFont.m index bfb90ec6a..6458f176b 100644 --- a/src/macosx/native/sun/font/AWTFont.m +++ b/src/macosx/native/sun/font/AWTFont.m @@ -162,6 +162,44 @@ GetFamilyNameForFontName(NSString* fontname) return [sFontFamilyTable objectForKey:fontname]; } +static void addFont(CTFontUIFontType uiType, + NSMutableArray *allFonts, + NSMutableDictionary* fontFamilyTable) { + + CTFontRef font = CTFontCreateUIFontForLanguage(uiType, 0.0, NULL); + if (font == NULL) { + return; + } + CTFontDescriptorRef desc = CTFontCopyFontDescriptor(font); + if (desc == NULL) { + CFRelease(font); + return; + } + CFStringRef family = CTFontDescriptorCopyAttribute(desc, kCTFontFamilyNameAttribute); + if (family == NULL) { + CFRelease(desc); + CFRelease(font); + return; + } + CFStringRef name = CTFontDescriptorCopyAttribute(desc, kCTFontNameAttribute); + if (name == NULL) { + CFRelease(family); + CFRelease(desc); + CFRelease(font); + return; + } + [allFonts addObject:name]; + [fontFamilyTable setObject:family forKey:name]; +#ifdef DEBUG + NSLog(@"name is : %@", (NSString*)name); + NSLog(@"family is : %@", (NSString*)family); +#endif + CFRelease(family); + CFRelease(name); + CFRelease(desc); + CFRelease(font); +} + static NSArray* GetFilteredFonts() { @@ -196,6 +234,16 @@ GetFilteredFonts() } } + /* + * JavaFX registers these fonts and so JDK needs to do so as well. + * If this isn't done we will have mis-matched rendering, since + * although these may include fonts that are enumerated normally + * they also demonstrably includes fonts that are not. + */ + addFont(kCTFontUIFontSystem, allFonts, fontFamilyTable); + addFont(kCTFontUIFontEmphasizedSystem, allFonts, fontFamilyTable); + addFont(kCTFontUIFontUserFixedPitch, allFonts, fontFamilyTable); + sFilteredFonts = allFonts; sFontFamilyTable = fontFamilyTable; } -- GitLab