Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-aarch32-jdk8u
Path: blob/jdk8u272-b10-aarch32-20201026/jdk/src/macosx/native/sun/font/AWTFont.m
83405 views
1
/*
2
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation. Oracle designates this
8
* particular file as subject to the "Classpath" exception as provided
9
* by Oracle in the LICENSE file that accompanied this code.
10
*
11
* This code is distributed in the hope that it will be useful, but WITHOUT
12
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
* version 2 for more details (a copy is included in the LICENSE file that
15
* accompanied this code).
16
*
17
* You should have received a copy of the GNU General Public License version
18
* 2 along with this work; if not, write to the Free Software Foundation,
19
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20
*
21
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
* or visit www.oracle.com if you need additional information or have any
23
* questions.
24
*/
25
26
#import <JavaNativeFoundation/JavaNativeFoundation.h>
27
28
#import "java_awt_Font.h"
29
#import "sun_awt_PlatformFont.h"
30
#import "sun_awt_FontDescriptor.h"
31
#import "sun_font_CFont.h"
32
#import "sun_font_CFontManager.h"
33
34
#import "AWTFont.h"
35
#import "AWTStrike.h"
36
#import "CoreTextSupport.h"
37
38
@implementation AWTFont
39
40
- (id) initWithFont:(NSFont *)font {
41
self = [super init];
42
if (self) {
43
fFont = [font retain];
44
fNativeCGFont = CTFontCopyGraphicsFont((CTFontRef)font, NULL);
45
layoutTableCache = NULL;
46
}
47
return self;
48
}
49
50
static TTLayoutTableCache* newCFontLayoutTableCache() {
51
TTLayoutTableCache* ltc = calloc(1, sizeof(TTLayoutTableCache));
52
if (ltc) {
53
int i;
54
for(i=0;i<LAYOUTCACHE_ENTRIES;i++) {
55
ltc->entries[i].len = -1;
56
}
57
}
58
return ltc;
59
}
60
61
static void freeCFontLayoutTableCache(TTLayoutTableCache* ltc) {
62
if (ltc) {
63
int i;
64
for(i=0;i<LAYOUTCACHE_ENTRIES;i++) {
65
if(ltc->entries[i].ptr) free (ltc->entries[i].ptr);
66
}
67
if (ltc->kernPairs) free(ltc->kernPairs);
68
free(ltc);
69
}
70
}
71
72
- (void) dealloc {
73
[fFont release];
74
fFont = nil;
75
76
if (fNativeCGFont) {
77
CGFontRelease(fNativeCGFont);
78
fNativeCGFont = NULL;
79
if (layoutTableCache != NULL) {
80
freeCFontLayoutTableCache(layoutTableCache);
81
layoutTableCache = NULL;
82
}
83
}
84
85
[super dealloc];
86
}
87
88
- (void) finalize {
89
if (fNativeCGFont) {
90
CGFontRelease(fNativeCGFont);
91
fNativeCGFont = NULL;
92
}
93
if (layoutTableCache != NULL) {
94
freeCFontLayoutTableCache(layoutTableCache);
95
layoutTableCache = NULL;
96
}
97
[super finalize];
98
}
99
100
static NSString* uiName = nil;
101
static NSString* uiBoldName = nil;
102
103
+ (AWTFont *) awtFontForName:(NSString *)name
104
style:(int)style
105
{
106
// create font with family & size
107
NSFont *nsFont = nil;
108
109
if ((uiName != nil && [name isEqualTo:uiName]) ||
110
(uiBoldName != nil && [name isEqualTo:uiBoldName])) {
111
if (style & java_awt_Font_BOLD) {
112
nsFont = [NSFont boldSystemFontOfSize:1.0];
113
} else {
114
nsFont = [NSFont systemFontOfSize:1.0];
115
}
116
#ifdef DEBUG
117
NSLog(@"nsFont-name is : %@", nsFont.familyName);
118
NSLog(@"nsFont-family is : %@", nsFont.fontName);
119
NSLog(@"nsFont-desc-name is : %@", nsFont.fontDescriptor.postscriptName);
120
#endif
121
122
123
} else {
124
nsFont = [NSFont fontWithName:name size:1.0];
125
}
126
127
if (nsFont == nil) {
128
// if can't get font of that name, substitute system default font
129
nsFont = [NSFont fontWithName:@"Lucida Grande" size:1.0];
130
#ifdef DEBUG
131
NSLog(@"needed to substitute Lucida Grande for: %@", name);
132
#endif
133
}
134
135
// create an italic style (if one is installed)
136
if (style & java_awt_Font_ITALIC) {
137
nsFont = [[NSFontManager sharedFontManager] convertFont:nsFont toHaveTrait:NSItalicFontMask];
138
}
139
140
// create a bold style (if one is installed)
141
if (style & java_awt_Font_BOLD) {
142
nsFont = [[NSFontManager sharedFontManager] convertFont:nsFont toHaveTrait:NSBoldFontMask];
143
}
144
145
return [[[AWTFont alloc] initWithFont:nsFont] autorelease];
146
}
147
148
+ (NSFont *) nsFontForJavaFont:(jobject)javaFont env:(JNIEnv *)env {
149
if (javaFont == NULL) {
150
#ifdef DEBUG
151
NSLog(@"nil font");
152
#endif
153
return nil;
154
}
155
156
static JNF_CLASS_CACHE(jc_Font, "java/awt/Font");
157
158
// obtain the Font2D
159
static JNF_MEMBER_CACHE(jm_Font_getFont2D, jc_Font, "getFont2D", "()Lsun/font/Font2D;");
160
jobject font2d = JNFCallObjectMethod(env, javaFont, jm_Font_getFont2D);
161
if (font2d == NULL) {
162
#ifdef DEBUG
163
NSLog(@"nil font2d");
164
#endif
165
return nil;
166
}
167
168
// if it's not a CFont, it's likely one of TTF or OTF fonts
169
// from the Sun rendering loops
170
static JNF_CLASS_CACHE(jc_CFont, "sun/font/CFont");
171
if (!JNFIsInstanceOf(env, font2d, &jc_CFont)) {
172
#ifdef DEBUG
173
NSLog(@"font2d !instanceof CFont");
174
#endif
175
return nil;
176
}
177
178
static JNF_MEMBER_CACHE(jm_CFont_getFontStrike, jc_CFont, "getStrike", "(Ljava/awt/Font;)Lsun/font/FontStrike;");
179
jobject fontStrike = JNFCallObjectMethod(env, font2d, jm_CFont_getFontStrike, javaFont);
180
181
static JNF_CLASS_CACHE(jc_CStrike, "sun/font/CStrike");
182
if (!JNFIsInstanceOf(env, fontStrike, &jc_CStrike)) {
183
#ifdef DEBUG
184
NSLog(@"fontStrike !instanceof CStrike");
185
#endif
186
return nil;
187
}
188
189
static JNF_MEMBER_CACHE(jm_CStrike_nativeStrikePtr, jc_CStrike, "getNativeStrikePtr", "()J");
190
jlong awtStrikePtr = JNFCallLongMethod(env, fontStrike, jm_CStrike_nativeStrikePtr);
191
if (awtStrikePtr == 0L) {
192
#ifdef DEBUG
193
NSLog(@"nil nativeFontPtr from CFont");
194
#endif
195
return nil;
196
}
197
198
AWTStrike *strike = (AWTStrike *)jlong_to_ptr(awtStrikePtr);
199
200
return [NSFont fontWithName:[strike->fAWTFont->fFont fontName] matrix:(CGFloat *)(&(strike->fAltTx))];
201
}
202
203
@end
204
205
206
#pragma mark --- Font Discovery and Loading ---
207
208
static NSArray* sFilteredFonts = nil;
209
static NSDictionary* sFontFamilyTable = nil;
210
211
static NSString*
212
GetFamilyNameForFontName(NSString* fontname)
213
{
214
return [sFontFamilyTable objectForKey:fontname];
215
}
216
217
static void addFont(CTFontUIFontType uiType,
218
NSMutableArray *allFonts,
219
NSMutableDictionary* fontFamilyTable) {
220
221
CTFontRef font = CTFontCreateUIFontForLanguage(uiType, 0.0, NULL);
222
if (font == NULL) {
223
return;
224
}
225
CTFontDescriptorRef desc = CTFontCopyFontDescriptor(font);
226
if (desc == NULL) {
227
CFRelease(font);
228
return;
229
}
230
CFStringRef family = CTFontDescriptorCopyAttribute(desc, kCTFontFamilyNameAttribute);
231
if (family == NULL) {
232
CFRelease(desc);
233
CFRelease(font);
234
return;
235
}
236
CFStringRef name = CTFontDescriptorCopyAttribute(desc, kCTFontNameAttribute);
237
if (name == NULL) {
238
CFRelease(family);
239
CFRelease(desc);
240
CFRelease(font);
241
return;
242
}
243
if (uiType == kCTFontUIFontSystem) {
244
uiName = (NSString*)name;
245
}
246
if (uiType == kCTFontUIFontEmphasizedSystem) {
247
uiBoldName = (NSString*)name;
248
}
249
[allFonts addObject:name];
250
[fontFamilyTable setObject:family forKey:name];
251
#ifdef DEBUG
252
NSLog(@"name is : %@", (NSString*)name);
253
NSLog(@"family is : %@", (NSString*)family);
254
#endif
255
CFRelease(family);
256
CFRelease(name);
257
CFRelease(desc);
258
CFRelease(font);
259
}
260
261
static NSArray*
262
GetFilteredFonts()
263
{
264
if (sFilteredFonts == nil) {
265
NSFontManager *fontManager = [NSFontManager sharedFontManager];
266
NSUInteger fontCount = [[fontManager availableFonts] count];
267
268
NSMutableArray *allFonts = [[NSMutableArray alloc] initWithCapacity:fontCount];
269
NSMutableDictionary* fontFamilyTable = [[NSMutableDictionary alloc] initWithCapacity:fontCount];
270
NSArray *allFamilies = [fontManager availableFontFamilies];
271
272
NSUInteger familyCount = [allFamilies count];
273
274
NSUInteger familyIndex;
275
for (familyIndex = 0; familyIndex < familyCount; familyIndex++) {
276
NSString *family = [allFamilies objectAtIndex:familyIndex];
277
278
if ((family == nil) || [family characterAtIndex:0] == '.') {
279
continue;
280
}
281
282
NSArray *fontFaces = [fontManager availableMembersOfFontFamily:family];
283
NSUInteger faceCount = [fontFaces count];
284
285
NSUInteger faceIndex;
286
for (faceIndex = 0; faceIndex < faceCount; faceIndex++) {
287
NSString* face = [[fontFaces objectAtIndex:faceIndex] objectAtIndex:0];
288
if (face != nil) {
289
[allFonts addObject:face];
290
[fontFamilyTable setObject:family forKey:face];
291
}
292
}
293
}
294
295
/*
296
* JavaFX registers these fonts and so JDK needs to do so as well.
297
* If this isn't done we will have mis-matched rendering, since
298
* although these may include fonts that are enumerated normally
299
* they also demonstrably includes fonts that are not.
300
*/
301
addFont(kCTFontUIFontSystem, allFonts, fontFamilyTable);
302
addFont(kCTFontUIFontEmphasizedSystem, allFonts, fontFamilyTable);
303
304
sFilteredFonts = allFonts;
305
sFontFamilyTable = fontFamilyTable;
306
}
307
308
return sFilteredFonts;
309
}
310
311
#pragma mark --- sun.font.CFontManager JNI ---
312
313
static OSStatus CreateFSRef(FSRef *myFSRefPtr, NSString *inPath)
314
{
315
return FSPathMakeRef((UInt8 *)[inPath fileSystemRepresentation],
316
myFSRefPtr, NULL);
317
}
318
319
// /*
320
// * Class: sun_font_CFontManager
321
// * Method: loadFileFont
322
// * Signature: (Ljava/lang/String;)Lsun/font/Font2D;
323
// */
324
// JNIEXPORT /* sun.font.CFont */ jobject JNICALL
325
// Java_sun_font_CFontManager_loadFileFont
326
// (JNIEnv *env, jclass obj, jstring fontpath)
327
// {
328
// jobject result = NULL;
329
//
330
// JNF_COCOA_ENTER(env);
331
//
332
// NSString *nsFilePath = JNFJavaToNSString(env, fontpath);
333
// jstring javaFontName = NULL;
334
//
335
// //
336
// // Note: This API uses ATS and can therefore return Carbon error codes.
337
// // These codes can be found at:
338
// // http://developer.apple.com/techpubs/macosx/Carbon/Files/FileManager/File_Manager/ResultCodes/ResultCodes.html
339
// //
340
//
341
// FSRef iFile;
342
// OSStatus status = CreateFSRef(&iFile, nsFilePath);
343
//
344
// if (status == noErr) {
345
// ATSFontContainerRef oContainer;
346
// status = ATSFontActivateFromFileReference(&iFile, kATSFontContextLocal,
347
// kATSFontFormatUnspecified,
348
// NULL,
349
// kATSOptionFlagsUseDataFork,
350
// &oContainer);
351
// if (status == noErr) {
352
// ATSFontRef ioArray[1];
353
// ItemCount oCount;
354
// status = ATSFontFindFromContainer(oContainer,
355
// kATSOptionFlagsUseDataFork,
356
// 1, ioArray, &oCount);
357
//
358
// if (status == noErr) {
359
// CFStringRef oName;
360
// status = ATSFontGetPostScriptName(ioArray[0],
361
// kATSOptionFlagsUseDataFork,
362
// &oName);
363
// if (status == noErr) {
364
// javaFontName = JNFNSToJavaString(env, (NSString *)oName);
365
// CFRelease(oName);
366
// }
367
// }
368
// }
369
// }
370
//
371
// if (javaFontName != NULL) {
372
// // create the CFont!
373
// static JNF_CLASS_CACHE(sjc_CFont, "sun/font/CFont");
374
// static JNF_CTOR_CACHE(sjf_CFont_ctor,
375
// sjc_CFont, "(Ljava/lang/String;)V");
376
// result = JNFNewObject(env, sjf_CFont_ctor, javaFontName);
377
// }
378
//
379
// JNF_COCOA_EXIT(env);
380
//
381
// return result;
382
// }
383
384
/*
385
* Class: sun_font_CFontManager
386
* Method: loadNativeFonts
387
* Signature: ()V
388
*/
389
JNIEXPORT void JNICALL
390
Java_sun_font_CFontManager_loadNativeFonts
391
(JNIEnv *env, jobject jthis)
392
{
393
static JNF_CLASS_CACHE(jc_CFontManager,
394
"sun/font/CFontManager");
395
static JNF_MEMBER_CACHE(jm_registerFont, jc_CFontManager,
396
"registerFont",
397
"(Ljava/lang/String;Ljava/lang/String;)V");
398
399
jint num = 0;
400
401
JNF_COCOA_ENTER(env);
402
403
NSArray *filteredFonts = GetFilteredFonts();
404
num = (jint)[filteredFonts count];
405
406
jint i;
407
for (i = 0; i < num; i++) {
408
NSString *fontname = [filteredFonts objectAtIndex:i];
409
jobject jFontName = JNFNSToJavaString(env, fontname);
410
jobject jFontFamilyName =
411
JNFNSToJavaString(env, GetFamilyNameForFontName(fontname));
412
413
JNFCallVoidMethod(env, jthis,
414
jm_registerFont, jFontName, jFontFamilyName);
415
}
416
417
JNF_COCOA_EXIT(env);
418
}
419
420
/*
421
* Class: Java_sun_font_CFontManager_loadNativeDirFonts
422
* Method: loadNativeDirFonts
423
* Signature: (Ljava/lang/String;)V;
424
*/
425
JNIEXPORT void JNICALL
426
Java_sun_font_CFontManager_loadNativeDirFonts
427
(JNIEnv *env, jclass clz, jstring filename)
428
{
429
JNF_COCOA_ENTER(env);
430
431
NSString *nsFilePath = JNFJavaToNSString(env, filename);
432
433
FSRef iFile;
434
OSStatus status = CreateFSRef(&iFile, nsFilePath);
435
436
if (status == noErr) {
437
ATSFontContainerRef oContainer;
438
status = ATSFontActivateFromFileReference(&iFile, kATSFontContextLocal,
439
kATSFontFormatUnspecified,
440
NULL, kNilOptions,
441
&oContainer);
442
}
443
444
JNF_COCOA_EXIT(env);
445
}
446
447
#pragma mark --- sun.font.CFont JNI ---
448
449
/*
450
* Class: sun_font_CFont
451
* Method: getPlatformFontPtrNative
452
* Signature: (JI)[B
453
*/
454
JNIEXPORT jlong JNICALL
455
Java_sun_font_CFont_getCGFontPtrNative
456
(JNIEnv *env, jclass clazz,
457
jlong awtFontPtr)
458
{
459
AWTFont *awtFont = (AWTFont *)jlong_to_ptr(awtFontPtr);
460
return (jlong)(awtFont->fNativeCGFont);
461
}
462
463
/*
464
* Class: sun_font_CFont
465
* Method: getLayoutTableCacheNative
466
* Signature: (J)J
467
*/
468
JNIEXPORT jlong JNICALL
469
Java_sun_font_CFont_getLayoutTableCacheNative
470
(JNIEnv *env, jclass clazz,
471
jlong awtFontPtr)
472
{
473
AWTFont *awtFont = (AWTFont *)jlong_to_ptr(awtFontPtr);
474
if (awtFont->layoutTableCache == NULL) {
475
awtFont->layoutTableCache = newCFontLayoutTableCache();
476
}
477
return (jlong)(awtFont->layoutTableCache);
478
}
479
480
/*
481
* Class: sun_font_CFont
482
* Method: getTableBytesNative
483
* Signature: (JI)[B
484
*/
485
JNIEXPORT jbyteArray JNICALL
486
Java_sun_font_CFont_getTableBytesNative
487
(JNIEnv *env, jclass clazz,
488
jlong awtFontPtr, jint jtag)
489
{
490
jbyteArray jbytes = NULL;
491
JNF_COCOA_ENTER(env);
492
493
CTFontTableTag tag = (CTFontTableTag)jtag;
494
int i, found = 0;
495
AWTFont *awtFont = (AWTFont *)jlong_to_ptr(awtFontPtr);
496
NSFont* nsFont = awtFont->fFont;
497
CTFontRef ctfont = (CTFontRef)nsFont;
498
CFArrayRef tagsArray =
499
CTFontCopyAvailableTables(ctfont, kCTFontTableOptionNoOptions);
500
CFIndex numTags = CFArrayGetCount(tagsArray);
501
for (i=0; i<numTags; i++) {
502
if (tag ==
503
(CTFontTableTag)(uintptr_t)CFArrayGetValueAtIndex(tagsArray, i)) {
504
found = 1;
505
break;
506
}
507
}
508
CFRelease(tagsArray);
509
if (!found) {
510
return NULL;
511
}
512
CFDataRef table = CTFontCopyTable(ctfont, tag, kCTFontTableOptionNoOptions);
513
if (table == NULL) {
514
return NULL;
515
}
516
517
char *tableBytes = (char*)(CFDataGetBytePtr(table));
518
size_t tableLength = CFDataGetLength(table);
519
if (tableBytes == NULL || tableLength == 0) {
520
CFRelease(table);
521
return NULL;
522
}
523
524
jbytes = (*env)->NewByteArray(env, (jsize)tableLength);
525
if (jbytes == NULL) {
526
return NULL;
527
}
528
(*env)->SetByteArrayRegion(env, jbytes, 0,
529
(jsize)tableLength,
530
(jbyte*)tableBytes);
531
CFRelease(table);
532
533
JNF_COCOA_EXIT(env);
534
535
return jbytes;
536
}
537
538
/*
539
* Class: sun_font_CFont
540
* Method: initNativeFont
541
* Signature: (Ljava/lang/String;I)J
542
*/
543
JNIEXPORT jlong JNICALL
544
Java_sun_font_CFont_createNativeFont
545
(JNIEnv *env, jclass clazz,
546
jstring nativeFontName, jint style)
547
{
548
AWTFont *awtFont = nil;
549
550
JNF_COCOA_ENTER(env);
551
552
awtFont =
553
[AWTFont awtFontForName:JNFJavaToNSString(env, nativeFontName)
554
style:style]; // autoreleased
555
556
if (awtFont) {
557
CFRetain(awtFont); // GC
558
}
559
560
JNF_COCOA_EXIT(env);
561
562
return ptr_to_jlong(awtFont);
563
}
564
565
/*
566
* Class: sun_font_CFont
567
* Method: getWidthNative
568
* Signature: (J)F
569
*/
570
JNIEXPORT jfloat JNICALL
571
Java_sun_font_CFont_getWidthNative
572
(JNIEnv *env, jobject cfont, jlong awtFontPtr)
573
{
574
float widthVal;
575
JNF_COCOA_ENTER(env);
576
577
AWTFont *awtFont = (AWTFont *)jlong_to_ptr(awtFontPtr);
578
NSFont* nsFont = awtFont->fFont;
579
NSFontDescriptor *fontDescriptor = nsFont.fontDescriptor;
580
NSDictionary *fontTraits = [fontDescriptor objectForKey : NSFontTraitsAttribute];
581
NSNumber *width = [fontTraits objectForKey : NSFontWidthTrait];
582
widthVal = (float)[width floatValue];
583
584
JNF_COCOA_EXIT(env);
585
return (jfloat)widthVal;
586
}
587
588
/*
589
* Class: sun_font_CFont
590
* Method: getWeightNative
591
* Signature: (J)F
592
*/
593
JNIEXPORT jfloat JNICALL
594
Java_sun_font_CFont_getWeightNative
595
(JNIEnv *env, jobject cfont, jlong awtFontPtr)
596
{
597
float weightVal;
598
JNF_COCOA_ENTER(env);
599
600
AWTFont *awtFont = (AWTFont *)jlong_to_ptr(awtFontPtr);
601
NSFont* nsFont = awtFont->fFont;
602
NSFontDescriptor *fontDescriptor = nsFont.fontDescriptor;
603
NSDictionary *fontTraits = [fontDescriptor objectForKey : NSFontTraitsAttribute];
604
NSNumber *weight = [fontTraits objectForKey : NSFontWeightTrait];
605
weightVal = (float)[weight floatValue];
606
607
JNF_COCOA_EXIT(env);
608
return (jfloat)weightVal;
609
}
610
611
/*
612
* Class: sun_font_CFont
613
* Method: disposeNativeFont
614
* Signature: (J)V
615
*/
616
JNIEXPORT void JNICALL
617
Java_sun_font_CFont_disposeNativeFont
618
(JNIEnv *env, jclass clazz, jlong awtFontPtr)
619
{
620
JNF_COCOA_ENTER(env);
621
622
if (awtFontPtr) {
623
CFRelease((AWTFont *)jlong_to_ptr(awtFontPtr)); // GC
624
}
625
626
JNF_COCOA_EXIT(env);
627
}
628
629
630
#pragma mark --- Miscellaneous JNI ---
631
632
#ifndef HEADLESS
633
/*
634
* Class: sun_awt_PlatformFont
635
* Method: initIDs
636
* Signature: ()V
637
*/
638
JNIEXPORT void JNICALL
639
Java_sun_awt_PlatformFont_initIDs
640
(JNIEnv *env, jclass cls)
641
{
642
}
643
644
/*
645
* Class: sun_awt_FontDescriptor
646
* Method: initIDs
647
* Signature: ()V
648
*/
649
JNIEXPORT void JNICALL
650
Java_sun_awt_FontDescriptor_initIDs
651
(JNIEnv *env, jclass cls)
652
{
653
}
654
#endif
655
656
/*
657
* Class: sun_awt_FontDescriptor
658
* Method: initIDs
659
* Signature: ()V
660
*/
661
JNIEXPORT void JNICALL
662
Java_sun_font_CFont_getCascadeList
663
(JNIEnv *env, jclass cls, jlong awtFontPtr, jobject arrayListOfString)
664
{
665
jclass alc = (*env)->FindClass(env, "java/util/ArrayList");
666
if (alc == NULL) return;
667
jmethodID addMID = (*env)->GetMethodID(env, alc, "add", "(Ljava/lang/Object;)Z");
668
if (addMID == NULL) return;
669
670
CFIndex i;
671
AWTFont *awtFont = (AWTFont *)jlong_to_ptr(awtFontPtr);
672
NSFont* nsFont = awtFont->fFont;
673
CTFontRef font = (CTFontRef)nsFont;
674
CFStringRef base = CTFontCopyFullName(font);
675
CFArrayRef codes = CFLocaleCopyISOLanguageCodes();
676
677
#ifdef DEBUG
678
NSLog(@"BaseFont is : %@", (NSString*)base);
679
#endif
680
CFArrayRef fds = CTFontCopyDefaultCascadeListForLanguages(font, codes);
681
CFIndex cnt = CFArrayGetCount(fds);
682
for (i=0; i<cnt; i++) {
683
CTFontDescriptorRef ref = CFArrayGetValueAtIndex(fds, i);
684
CFStringRef fontname =
685
CTFontDescriptorCopyAttribute(ref, kCTFontNameAttribute);
686
#ifdef DEBUG
687
NSLog(@"Font is : %@", (NSString*)fontname);
688
#endif
689
jstring jFontName = (jstring)JNFNSToJavaString(env, fontname);
690
(*env)->CallBooleanMethod(env, arrayListOfString, addMID, jFontName);
691
(*env)->DeleteLocalRef(env, jFontName);
692
}
693
}
694
695