Various things

Signed-off-by: Slendi <slendi@socopon.com>
This commit is contained in:
2025-10-07 04:32:14 +03:00
parent 278f4c6df3
commit 64979c6e5c
3 changed files with 29 additions and 4 deletions

View File

@@ -6,6 +6,7 @@
#include <cstdlib>
#include <cstring>
#include <span>
#include <unordered_set>
#include <vector>
#include <poll.h>
#include <pthread.h>
@@ -303,15 +304,33 @@ auto App::init_egl() -> void
auto const font = find_font_path();
assert(font && "Could not find font");
std::vector<std::filesystem::path> fallback_paths;
std::unordered_set<std::string> seen_paths;
auto const primary_path_str = font->string();
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",
"sans-serif:lang=ja",
"sans-serif:lang=ko",
"sans-serif:lang=zh-cn",
"sans-serif:lang=zh-tw",
"sans-serif:lang=zh-hk",
};
for (auto const *name : fallback_candidates) {
if (auto fallback = find_font_path(name))
if (auto fallback = find_font_path(name)) {
auto const path_str = fallback->string();
if (path_str == primary_path_str)
continue;
if (!seen_paths.emplace(path_str).second)
continue;
fallback_paths.push_back(*fallback);
}
}
if (fallback_paths.empty()) {
TraceLog(LOG_WARNING,
"No fallback fonts found; some glyphs may render as missing");
}
auto const font_handle
= m_tr->load_font(*font, std::span(fallback_paths));