From ca75b6b55baeb1898c0d7e543ca2d17d4faa6077 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 29 Sep 2022 22:06:43 +0800 Subject: [PATCH] Font: fix compiling on Android; detect more fonts on macOS --- src/detection/font/font.h | 6 +++--- src/detection/font/font_android.c | 1 + src/detection/font/font_apple.m | 16 +++------------- 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/src/detection/font/font.h b/src/detection/font/font.h index 400ff4791..fa02bbd37 100644 --- a/src/detection/font/font.h +++ b/src/detection/font/font.h @@ -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; diff --git a/src/detection/font/font_android.c b/src/detection/font/font_android.c index f6bfa81e3..f2331a302 100644 --- a/src/detection/font/font_android.c +++ b/src/detection/font/font_android.c @@ -1,4 +1,5 @@ #include "fastfetch.h" +#include "font.h" void ffDetectFontImpl(const FFinstance* instance, FFFontResult* result) { diff --git a/src/detection/font/font_apple.m b/src/detection/font/font_apple.m index 41dd5b8de..1d75ec337 100644 --- a/src/detection/font/font_apple.m +++ b/src/detection/font/font_apple.m @@ -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]); }