mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
Font: add support for Windows
This commit is contained in:
+1
-1
@@ -328,6 +328,7 @@ if(WIN_MSYS)
|
||||
src/detection/cpuUsage/cpuUsage_windows.c
|
||||
src/detection/cpuUsage/cpuUsage_nowait_windows.cpp
|
||||
src/detection/memory/memory_windows.cpp
|
||||
src/detection/font/font_windows.cpp
|
||||
src/util/windows/wmi.cpp
|
||||
|
||||
# Shared
|
||||
@@ -336,7 +337,6 @@ if(WIN_MSYS)
|
||||
|
||||
# TODO
|
||||
src/detection/media/media_linux.c
|
||||
src/detection/font/font_linux.c
|
||||
src/detection/temps/temps_linux.c
|
||||
)
|
||||
endif()
|
||||
|
||||
@@ -12,9 +12,10 @@ typedef struct FFFontResult
|
||||
FFstrbuf error;
|
||||
|
||||
/**
|
||||
* Linux / BSD: QT, GTK2, GTK3, GTK4
|
||||
* MacOS: System, User, Monospace, Application
|
||||
* Other: Unset, Unset, Unset, Unset
|
||||
* Linux / BSD: QT, GTK2, GTK3, GTK4
|
||||
* MacOS: System, User, Monospace, Application
|
||||
* Windows: Desktop, User, Unset, Unset
|
||||
* Other: Unset, Unset, Unset, Unset
|
||||
*/
|
||||
FFstrbuf fonts[FF_DETECT_FONT_NUM_FONTS];
|
||||
} FFFontResult;
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
extern "C" {
|
||||
#include "font.h"
|
||||
#include "common/font.h"
|
||||
}
|
||||
#include "util/windows/wmi.hpp"
|
||||
|
||||
#include <wchar.h>
|
||||
|
||||
extern "C"
|
||||
void ffDetectFontImpl(const FFinstance* instance, FFFontResult* result)
|
||||
{
|
||||
wchar_t query[256] = {};
|
||||
swprintf(query, 256, L"SELECT IconTitleFaceName, IconTitleSize FROM Win32_Desktop WHERE Name LIKE '%%\\\\%s'", instance->state.passwd->pw_name);
|
||||
|
||||
IEnumWbemClassObject* pEnumerator = ffQueryWmi(query, &result->error);
|
||||
if(!pEnumerator)
|
||||
return;
|
||||
|
||||
IWbemClassObject *pclsObj = NULL;
|
||||
ULONG uReturn = 0;
|
||||
|
||||
pEnumerator->Next(WBEM_INFINITE, 1, &pclsObj, &uReturn);
|
||||
|
||||
if(uReturn == 0)
|
||||
{
|
||||
ffStrbufInitS(&result->error, "No WMI result returned");
|
||||
pEnumerator->Release();
|
||||
return;
|
||||
}
|
||||
|
||||
FFstrbuf fontName;
|
||||
ffStrbufInit(&fontName);
|
||||
ffGetWmiObjString(pclsObj, L"IconTitleFaceName", &fontName);
|
||||
|
||||
uint64_t fontSize;
|
||||
ffGetWmiObjUnsigned(pclsObj, L"IconTitleSize", &fontSize);
|
||||
|
||||
ffStrbufAppendF(&result->fonts[0], "%*s (%upt)", fontName.length, fontName.chars, (unsigned)fontSize);
|
||||
|
||||
ffStrbufDestroy(&fontName);
|
||||
|
||||
pclsObj->Release();
|
||||
pEnumerator->Release();
|
||||
}
|
||||
@@ -40,6 +40,16 @@ static void printFont(const FFFontResult* font)
|
||||
printf("%s [User]", font->fonts[1].chars);
|
||||
}
|
||||
|
||||
#elif defined(_WIN32) || defined(__CYGWIN__)
|
||||
|
||||
static void printFont(const FFFontResult* font)
|
||||
{
|
||||
if(font->fonts[0].length > 0)
|
||||
{
|
||||
printf("%s [Desktop]", font->fonts[0].chars);
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static void printFont(const FFFontResult* font)
|
||||
|
||||
Reference in New Issue
Block a user