mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-11-03 13:34:19 +01:00
e8e586ce7c
1. simplify resource management by using C++ RAII like GCC attribute extension `cleanup` 2. simplify HEKY reading Actually `__attribute__((__cleanup__(cleanupFn)))` is supported on all major C compiler ( gcc, clang and icc ) except MSVC I only used it on Windows and macOS for now. Let's see if the project author like it.
33 lines
906 B
C++
33 lines
906 B
C++
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 sql[256] = {};
|
|
swprintf(sql, 256, L"SELECT IconTitleFaceName, IconTitleSize FROM Win32_Desktop WHERE Name LIKE '%%\\\\%s'", instance->state.passwd->pw_name);
|
|
|
|
FFWmiQuery query(sql, &result->error);
|
|
if(!query)
|
|
return;
|
|
|
|
if(FFWmiRecord record = query.next())
|
|
{
|
|
FF_STRBUF_AUTO_DESTROY fontName;
|
|
ffStrbufInit(&fontName);
|
|
record.getString(L"IconTitleFaceName", &fontName);
|
|
|
|
uint64_t fontSize;
|
|
record.getUnsigned(L"IconTitleSize", &fontSize);
|
|
|
|
ffStrbufAppendF(&result->fonts[0], "%*s (%upt)", fontName.length, fontName.chars, (unsigned)fontSize);
|
|
}
|
|
else
|
|
ffStrbufInitS(&result->error, "No WMI result returned");
|
|
}
|