Skip to content
Permalink
Browse files
8244621: [macos10.15] Garbled FX printing plus CoreText warnings on C…
…atalina when building with Xcode 11

Reviewed-by: kcr, psadhukhan
  • Loading branch information
prrace committed Jun 5, 2020
1 parent 5aea3f0 commit 2048bcb648c2f42b59119eb603d33e8878c58650
Showing 1 changed file with 31 additions and 5 deletions.
@@ -66,11 +66,32 @@ - (void) finalize {
[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 @@ + (NSFont *) nsFontForJavaFont:(jobject)javaFont env:(JNIEnv *)env {
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 @@ static void addFont(CTFontUIFontType uiType,
*/
addFont(kCTFontUIFontSystem, allFonts, fontFamilyTable);
addFont(kCTFontUIFontEmphasizedSystem, allFonts, fontFamilyTable);
addFont(kCTFontUIFontUserFixedPitch, allFonts, fontFamilyTable);

sFilteredFonts = allFonts;
sFontFamilyTable = fontFamilyTable;
@@ -610,7 +636,7 @@ static JNF_MEMBER_CACHE(jm_registerFont, jc_CFontManager,
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);
}
}

0 comments on commit 2048bcb

Please sign in to comment.