@@ -66,11 +66,32 @@ - (void) finalize {
66
66
[super finalize ];
67
67
}
68
68
69
+ static NSString * uiName = nil ;
70
+ static NSString * uiBoldName = nil ;
71
+
69
72
+ (AWTFont *) awtFontForName : (NSString *)name
70
73
style : (int )style
71
74
{
72
75
// 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
+ }
74
95
75
96
if (nsFont == nil ) {
76
97
// if can't get font of that name, substitute system default font
@@ -162,7 +183,7 @@ + (NSFont *) nsFontForJavaFont:(jobject)javaFont env:(JNIEnv *)env {
162
183
return [sFontFamilyTable objectForKey: fontname];
163
184
}
164
185
165
- static void addFont (CTFontUIFontType uiType,
186
+ static void addFont (CTFontUIFontType uiType,
166
187
NSMutableArray *allFonts,
167
188
NSMutableDictionary * fontFamilyTable) {
168
189
@@ -188,6 +209,12 @@ static void addFont(CTFontUIFontType uiType,
188
209
CFRelease (font);
189
210
return ;
190
211
}
212
+ if (uiType == kCTFontUIFontSystem ) {
213
+ uiName = (NSString *)name;
214
+ }
215
+ if (uiType == kCTFontUIFontEmphasizedSystem ) {
216
+ uiBoldName = (NSString *)name;
217
+ }
191
218
[allFonts addObject: name];
192
219
[fontFamilyTable setObject: family forKey: name];
193
220
#ifdef DEBUG
@@ -199,7 +226,7 @@ static void addFont(CTFontUIFontType uiType,
199
226
CFRelease (desc);
200
227
CFRelease (font);
201
228
}
202
-
229
+
203
230
static NSArray *
204
231
GetFilteredFonts ()
205
232
{
@@ -242,7 +269,6 @@ static void addFont(CTFontUIFontType uiType,
242
269
*/
243
270
addFont (kCTFontUIFontSystem , allFonts, fontFamilyTable);
244
271
addFont (kCTFontUIFontEmphasizedSystem , allFonts, fontFamilyTable);
245
- addFont (kCTFontUIFontUserFixedPitch , allFonts, fontFamilyTable);
246
272
247
273
sFilteredFonts = allFonts;
248
274
sFontFamilyTable = fontFamilyTable;
@@ -610,7 +636,7 @@ static JNF_MEMBER_CACHE(jm_registerFont, jc_CFontManager,
610
636
NSLog (@" Font is : %@ " , (NSString *)fontname);
611
637
#endif
612
638
jstring jFontName = (jstring)JNFNSToJavaString (env, fontname);
613
- (*env)->CallBooleanMethod (env, arrayListOfString, addMID, jFontName);
639
+ (*env)->CallBooleanMethod (env, arrayListOfString, addMID, jFontName);
614
640
(*env)->DeleteLocalRef (env, jFontName);
615
641
}
616
642
}
0 commit comments