Fallback fonts

Signed-off-by: Slendi <slendi@socopon.com>
This commit is contained in:
2025-10-07 04:16:28 +03:00
parent c377baf3c9
commit 278f4c6df3
8 changed files with 427 additions and 122 deletions

View File

@@ -5,6 +5,8 @@
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <span>
#include <vector>
#include <poll.h>
#include <pthread.h>
#include <signal.h>
@@ -300,7 +302,19 @@ auto App::init_egl() -> void
m_tr = TextRenderer();
auto const font = find_font_path();
assert(font && "Could not find font");
auto const font_handle = m_tr->load_font(*font);
std::vector<std::filesystem::path> fallback_paths;
constexpr char const *fallback_candidates[] = {
"Noto Sans CJK JP:style=Regular",
"Noto Sans CJK SC:style=Regular",
"Noto Sans CJK KR:style=Regular",
"Noto Sans CJK TC:style=Regular",
};
for (auto const *name : fallback_candidates) {
if (auto fallback = find_font_path(name))
fallback_paths.push_back(*fallback);
}
auto const font_handle
= m_tr->load_font(*font, std::span(fallback_paths));
assert(font_handle && "Could not load font");
m_font = *font_handle;
}