diff --git a/src/detection/font/font.h b/src/detection/font/font.h index 63d19e2ee..80bed7a39 100644 --- a/src/detection/font/font.h +++ b/src/detection/font/font.h @@ -12,10 +12,10 @@ typedef struct FFFontResult FFstrbuf error; /** - * Linux / BSD: QT, GTK2, GTK3, GTK4 - * MacOS: System, User, Monospace, Application - * Windows: Desktop, Unset, Unset, Unset - * Other: Unset, Unset, Unset, Unset + * Linux / BSD: QT, GTK2, GTK3, GTK4 + * MacOS: System, User, System Mono, User Mono + * Windows: Desktop, Unset, Unset, Unset + * Other: Unset, Unset, Unset, Unset */ FFstrbuf fonts[FF_DETECT_FONT_NUM_FONTS]; } FFFontResult; diff --git a/src/detection/font/font_apple.m b/src/detection/font/font_apple.m index 91689f6e9..773c7705b 100644 --- a/src/detection/font/font_apple.m +++ b/src/detection/font/font_apple.m @@ -1,23 +1,14 @@ #include "common/font.h" #include "common/io.h" -#include "util/apple/cf_helpers.h" #include "font.h" -#import - -static void detectFontForType(CTFontUIFontType uiType, FFstrbuf* font) -{ - CTFontRef ctFont = CTFontCreateUIFontForLanguage(uiType, 12, NULL); - ffCfStrGetString(CTFontCopyFamilyName(ctFont), font); -} +#import void ffDetectFontImpl(const FFinstance* instance, FFFontResult* result) { FF_UNUSED(instance); - ffSuppressIO(true); - detectFontForType(kCTFontUIFontSystem, &result->fonts[0]); - detectFontForType(kCTFontUIFontUser, &result->fonts[1]); - detectFontForType(kCTFontUIFontUserFixedPitch, &result->fonts[2]); - detectFontForType(kCTFontUIFontApplication, &result->fonts[3]); - ffSuppressIO(false); + ffStrbufAppendS(&result->fonts[0], [NSFont systemFontOfSize:12].familyName.UTF8String); + ffStrbufAppendS(&result->fonts[1], [NSFont userFontOfSize:12].familyName.UTF8String); + ffStrbufAppendS(&result->fonts[2], [NSFont monospacedSystemFontOfSize:12 weight:400].familyName.UTF8String); + ffStrbufAppendS(&result->fonts[3], [NSFont userFixedPitchFontOfSize:12].familyName.UTF8String); }