|
4 | 4 |
|
5 | 5 | #import <AppKit/AppKit.h> |
6 | 6 |
|
7 | | -#define FF_FONT_MODULE_NAME "Font" |
8 | | - |
9 | | -static void detectFontForType(CTFontUIFontType uiType, FFFontResult* result) |
| 7 | +static void detectFontForType(CTFontUIFontType uiType, FFstrbuf* font) |
10 | 8 | { |
11 | 9 | CTFontRef ctFont = CTFontCreateUIFontForLanguage(uiType, 12, NULL); |
| 10 | + ffCfStrGetString(CTFontCopyFullName(ctFont), font); |
12 | 11 |
|
13 | | - ffStrbufInit(&result->fontPretty); |
14 | | - ffCfStrGetString(CTFontCopyFullName(ctFont), &result->fontPretty); |
| 12 | + if(font->length == 0) |
| 13 | + return; |
15 | 14 |
|
16 | 15 | FFstrbuf familyName; |
17 | 16 | ffStrbufInit(&familyName); |
18 | 17 | ffCfStrGetString(CTFontCopyFamilyName(ctFont), &familyName); |
19 | 18 |
|
20 | | - if (ffStrbufComp(&familyName, &result->fontPretty) != 0) |
21 | | - { |
22 | | - ffStrbufAppendF(&result->fontPretty, " (%*s)", familyName.length, familyName.chars); |
23 | | - } |
| 19 | + if (ffStrbufComp(&familyName, font) != 0) |
| 20 | + ffStrbufAppendF(font, " (%*s)", familyName.length, familyName.chars); |
24 | 21 |
|
25 | 22 | ffStrbufDestroy(&familyName); |
26 | 23 | } |
27 | 24 |
|
28 | | -const char* ffDetectFontImpl(FFinstance* instance, FFlist* result) |
| 25 | +void ffDetectFontImpl(const FFinstance* instance, FFFontResult* result) |
29 | 26 | { |
30 | 27 | FF_UNUSED(instance); |
31 | | - |
32 | | - FFFontResult* resultSystem = (FFFontResult*)ffListAdd(result); |
33 | | - resultSystem->type = "SYS"; |
34 | | - detectFontForType(kCTFontUIFontSystem, resultSystem); |
35 | | - |
36 | | - FFFontResult* resultUser = (FFFontResult*)ffListAdd(result); |
37 | | - resultUser->type = "USER"; |
38 | | - detectFontForType(kCTFontUIFontUser, resultUser); |
39 | | - |
40 | | - return NULL; |
| 28 | + detectFontForType(kCTFontUIFontSystem, &result->fonts[0]); |
| 29 | + detectFontForType(kCTFontUIFontUser, &result->fonts[1]); |
41 | 30 | } |
0 commit comments