mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-30 09:33:39 +01:00
Font: simplify code; fix memleaks (macOS)
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -1,23 +1,14 @@
|
||||
#include "common/font.h"
|
||||
#include "common/io.h"
|
||||
#include "util/apple/cf_helpers.h"
|
||||
#include "font.h"
|
||||
|
||||
#import <AppKit/AppKit.h>
|
||||
|
||||
static void detectFontForType(CTFontUIFontType uiType, FFstrbuf* font)
|
||||
{
|
||||
CTFontRef ctFont = CTFontCreateUIFontForLanguage(uiType, 12, NULL);
|
||||
ffCfStrGetString(CTFontCopyFamilyName(ctFont), font);
|
||||
}
|
||||
#import <AppKit/NSFont.h>
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user