Font: fix compiling on Android; detect more fonts on macOS

This commit is contained in:
李通洲
2022-09-29 22:06:43 +08:00
parent 666b596f63
commit ca75b6b55b
3 changed files with 7 additions and 16 deletions
+3 -3
View File
@@ -12,9 +12,9 @@ typedef struct FFFontResult
FFstrbuf error;
/**
* Linux / BSD: QT, GTK2, GTK3, GTK4
* MacOS: System, User, Unset, Unset
* Other: Unset, Unset, Unset, Unset
* Linux / BSD: QT, GTK2, GTK3, GTK4
* MacOS: System, User, Monospace, Application
* Other: Unset, Unset, Unset, Unset
*/
FFstrbuf fonts[FF_DETECT_FONT_NUM_FONTS];
} FFFontResult;
+1
View File
@@ -1,4 +1,5 @@
#include "fastfetch.h"
#include "font.h"
void ffDetectFontImpl(const FFinstance* instance, FFFontResult* result)
{
+3 -13
View File
@@ -7,19 +7,7 @@
static void detectFontForType(CTFontUIFontType uiType, FFstrbuf* font)
{
CTFontRef ctFont = CTFontCreateUIFontForLanguage(uiType, 12, NULL);
ffCfStrGetString(CTFontCopyFullName(ctFont), font);
if(font->length == 0)
return;
FFstrbuf familyName;
ffStrbufInit(&familyName);
ffCfStrGetString(CTFontCopyFamilyName(ctFont), &familyName);
if (ffStrbufComp(&familyName, font) != 0)
ffStrbufAppendF(font, " (%*s)", familyName.length, familyName.chars);
ffStrbufDestroy(&familyName);
ffCfStrGetString(CTFontCopyFamilyName(ctFont), font);
}
void ffDetectFontImpl(const FFinstance* instance, FFFontResult* result)
@@ -27,4 +15,6 @@ void ffDetectFontImpl(const FFinstance* instance, FFFontResult* result)
FF_UNUSED(instance);
detectFontForType(kCTFontUIFontSystem, &result->fonts[0]);
detectFontForType(kCTFontUIFontUser, &result->fonts[1]);
detectFontForType(kCTFontUIFontUserFixedPitch, &result->fonts[2]);
detectFontForType(kCTFontUIFontApplication, &result->fonts[3]);
}