diff options
| author | sumuel <samuel@yakubos.org> | 2026-08-17 20:44:55 +0000 |
|---|---|---|
| committer | sumuel <samuel@yakubos.org> | 2026-08-17 20:44:55 +0000 |
| commit | 76424950e373d3b04ac3dd13019151bfba3e8423 (patch) | |
| tree | 4c3cfdbda039e592b9186be3e28f8d7cfd439e8a /src/detection/font/font_haiku.cpp | |
Add the files
Diffstat (limited to 'src/detection/font/font_haiku.cpp')
| -rw-r--r-- | src/detection/font/font_haiku.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/detection/font/font_haiku.cpp b/src/detection/font/font_haiku.cpp new file mode 100644 index 0000000..dc29dd0 --- /dev/null +++ b/src/detection/font/font_haiku.cpp @@ -0,0 +1,54 @@ +extern "C" { +#include "font.h" +} + +#include <Application.h> +#include <Font.h> +#include <Menu.h> + +extern "C" { +const char* ffDetectFontImpl(FFFontResult* result); +} + +static void generateString(FFFontResult* font) { + const char* types[] = { "Plain", "Menu", "Bold", "Mono" }; + for (uint32_t i = 0; i < ARRAY_SIZE(types); ++i) { + if (i == 0 || !ffStrbufEqual(&font->fonts[i - 1], &font->fonts[i])) { + if (i > 0) { + ffStrbufAppendS(&font->display, "], "); + } + ffStrbufAppendF(&font->display, "%s [%s", font->fonts[i].chars, types[i]); + } else { + ffStrbufAppendS(&font->display, " / "); + ffStrbufAppendS(&font->display, types[i]); + } + } + ffStrbufAppendC(&font->display, ']'); +} + +const char* ffDetectFontImpl(FFFontResult* result) { + struct menu_info menuInfo; + const BFont* f; + // We need a valid be_app to query the app_server here. + BApplication app("application/x-vnd.fastfetch-cli-fastfetch"); + + if ((f = be_plain_font) != NULL) { + f->GetFamilyAndStyle(&menuInfo.f_family, &menuInfo.f_style); + ffStrbufAppendF(&result->fonts[0], "%s %s (%dpt)", menuInfo.f_family, menuInfo.f_style, (int) f->Size()); + } + if (get_menu_info(&menuInfo) == B_OK) { + ffStrbufAppendF(&result->fonts[1], "%s %s (%dpt)", menuInfo.f_family, menuInfo.f_style, (int) menuInfo.font_size); + } + if ((f = be_bold_font) != NULL) { + f->GetFamilyAndStyle(&menuInfo.f_family, &menuInfo.f_style); + ffStrbufAppendF(&result->fonts[2], "%s %s (%dpt)", menuInfo.f_family, menuInfo.f_style, (int) f->Size()); + } + if ((f = be_fixed_font) != NULL) { + f->GetFamilyAndStyle(&menuInfo.f_family, &menuInfo.f_style); + ffStrbufAppendF(&result->fonts[3], "%s %s (%dpt)", menuInfo.f_family, menuInfo.f_style, (int) f->Size()); + } + + generateString(result); + + return NULL; +} |