8244621: [macos10.15] Garbled FX printing plus CoreText warnings on Catalina when building with Xcode 11

Reviewed-by: kcr, psadhukhan
This commit is contained in:
Phil Race 2020-06-05 16:40:56 -07:00
parent 5aea3f0250
commit 2048bcb648

View File

@ -66,11 +66,32 @@
[super finalize];
}
static NSString* uiName = nil;
static NSString* uiBoldName = nil;
+ (AWTFont *) awtFontForName:(NSString *)name
style:(int)style
{
// create font with family & size
NSFont *nsFont = [NSFont fontWithName:name size:1.0];
NSFont *nsFont = nil;
if ((uiName != nil && [name isEqualTo:uiName]) ||
(uiBoldName != nil && [name isEqualTo:uiBoldName])) {
if (style & java_awt_Font_BOLD) {
nsFont = [NSFont boldSystemFontOfSize:1.0];
} else {
nsFont = [NSFont systemFontOfSize:1.0];
}
#ifdef DEBUG
NSLog(@"nsFont-name is : %@", nsFont.familyName);
NSLog(@"nsFont-family is : %@", nsFont.fontName);
NSLog(@"nsFont-desc-name is : %@", nsFont.fontDescriptor.postscriptName);
#endif
} else {
nsFont = [NSFont fontWithName:name size:1.0];
}
if (nsFont == nil) {
// if can't get font of that name, substitute system default font
@ -162,7 +183,7 @@ GetFamilyNameForFontName(NSString* fontname)
return [sFontFamilyTable objectForKey:fontname];
}
static void addFont(CTFontUIFontType uiType,
static void addFont(CTFontUIFontType uiType,
NSMutableArray *allFonts,
NSMutableDictionary* fontFamilyTable) {
@ -188,6 +209,12 @@ static void addFont(CTFontUIFontType uiType,
CFRelease(font);
return;
}
if (uiType == kCTFontUIFontSystem) {
uiName = (NSString*)name;
}
if (uiType == kCTFontUIFontEmphasizedSystem) {
uiBoldName = (NSString*)name;
}
[allFonts addObject:name];
[fontFamilyTable setObject:family forKey:name];
#ifdef DEBUG
@ -199,7 +226,7 @@ static void addFont(CTFontUIFontType uiType,
CFRelease(desc);
CFRelease(font);
}
static NSArray*
GetFilteredFonts()
{
@ -242,7 +269,6 @@ GetFilteredFonts()
*/
addFont(kCTFontUIFontSystem, allFonts, fontFamilyTable);
addFont(kCTFontUIFontEmphasizedSystem, allFonts, fontFamilyTable);
addFont(kCTFontUIFontUserFixedPitch, allFonts, fontFamilyTable);
sFilteredFonts = allFonts;
sFontFamilyTable = fontFamilyTable;
@ -610,7 +636,7 @@ Java_sun_font_CFont_getCascadeList
NSLog(@"Font is : %@", (NSString*)fontname);
#endif
jstring jFontName = (jstring)JNFNSToJavaString(env, fontname);
(*env)->CallBooleanMethod(env, arrayListOfString, addMID, jFontName);
(*env)->CallBooleanMethod(env, arrayListOfString, addMID, jFontName);
(*env)->DeleteLocalRef(env, jFontName);
}
}