Skip to content

Commit 2048bcb

Browse files
committedJun 5, 2020
8244621: [macos10.15] Garbled FX printing plus CoreText warnings on Catalina when building with Xcode 11
Reviewed-by: kcr, psadhukhan
1 parent 5aea3f0 commit 2048bcb

File tree

1 file changed

+31
-5
lines changed
  • src/java.desktop/macosx/native/libawt_lwawt/font

1 file changed

+31
-5
lines changed
 

‎src/java.desktop/macosx/native/libawt_lwawt/font/AWTFont.m

+31-5
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,32 @@ - (void) finalize {
6666
[super finalize];
6767
}
6868

69+
static NSString* uiName = nil;
70+
static NSString* uiBoldName = nil;
71+
6972
+ (AWTFont *) awtFontForName:(NSString *)name
7073
style:(int)style
7174
{
7275
// create font with family & size
73-
NSFont *nsFont = [NSFont fontWithName:name size:1.0];
76+
NSFont *nsFont = nil;
77+
78+
if ((uiName != nil && [name isEqualTo:uiName]) ||
79+
(uiBoldName != nil && [name isEqualTo:uiBoldName])) {
80+
if (style & java_awt_Font_BOLD) {
81+
nsFont = [NSFont boldSystemFontOfSize:1.0];
82+
} else {
83+
nsFont = [NSFont systemFontOfSize:1.0];
84+
}
85+
#ifdef DEBUG
86+
NSLog(@"nsFont-name is : %@", nsFont.familyName);
87+
NSLog(@"nsFont-family is : %@", nsFont.fontName);
88+
NSLog(@"nsFont-desc-name is : %@", nsFont.fontDescriptor.postscriptName);
89+
#endif
90+
91+
92+
} else {
93+
nsFont = [NSFont fontWithName:name size:1.0];
94+
}
7495

7596
if (nsFont == nil) {
7697
// if can't get font of that name, substitute system default font
@@ -162,7 +183,7 @@ + (NSFont *) nsFontForJavaFont:(jobject)javaFont env:(JNIEnv *)env {
162183
return [sFontFamilyTable objectForKey:fontname];
163184
}
164185

165-
static void addFont(CTFontUIFontType uiType,
186+
static void addFont(CTFontUIFontType uiType,
166187
NSMutableArray *allFonts,
167188
NSMutableDictionary* fontFamilyTable) {
168189

@@ -188,6 +209,12 @@ static void addFont(CTFontUIFontType uiType,
188209
CFRelease(font);
189210
return;
190211
}
212+
if (uiType == kCTFontUIFontSystem) {
213+
uiName = (NSString*)name;
214+
}
215+
if (uiType == kCTFontUIFontEmphasizedSystem) {
216+
uiBoldName = (NSString*)name;
217+
}
191218
[allFonts addObject:name];
192219
[fontFamilyTable setObject:family forKey:name];
193220
#ifdef DEBUG
@@ -199,7 +226,7 @@ static void addFont(CTFontUIFontType uiType,
199226
CFRelease(desc);
200227
CFRelease(font);
201228
}
202-
229+
203230
static NSArray*
204231
GetFilteredFonts()
205232
{
@@ -242,7 +269,6 @@ static void addFont(CTFontUIFontType uiType,
242269
*/
243270
addFont(kCTFontUIFontSystem, allFonts, fontFamilyTable);
244271
addFont(kCTFontUIFontEmphasizedSystem, allFonts, fontFamilyTable);
245-
addFont(kCTFontUIFontUserFixedPitch, allFonts, fontFamilyTable);
246272

247273
sFilteredFonts = allFonts;
248274
sFontFamilyTable = fontFamilyTable;
@@ -610,7 +636,7 @@ static JNF_MEMBER_CACHE(jm_registerFont, jc_CFontManager,
610636
NSLog(@"Font is : %@", (NSString*)fontname);
611637
#endif
612638
jstring jFontName = (jstring)JNFNSToJavaString(env, fontname);
613-
(*env)->CallBooleanMethod(env, arrayListOfString, addMID, jFontName);
639+
(*env)->CallBooleanMethod(env, arrayListOfString, addMID, jFontName);
614640
(*env)->DeleteLocalRef(env, jFontName);
615641
}
616642
}

0 commit comments

Comments
 (0)
Please sign in to comment.