51
src/App.cpp
51
src/App.cpp
@@ -5,16 +5,16 @@
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <span>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
#include <poll.h>
|
||||
#include <pthread.h>
|
||||
#include <signal.h>
|
||||
#include <span>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/signalfd.h>
|
||||
#include <thread>
|
||||
#include <unistd.h>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
#include <GLES3/gl3.h>
|
||||
#include <fontconfig/fontconfig.h>
|
||||
@@ -190,12 +190,22 @@ auto App::init_wayland() -> void
|
||||
bool alt = app->m_kbd.mod_active("Mod1");
|
||||
bool meta = app->m_kbd.mod_active("Mod4");
|
||||
if (!(ctrl || alt || meta)) {
|
||||
u32 cp = xkb_keysym_to_utf32(sym);
|
||||
if (cp >= 0x20) {
|
||||
char buf[8];
|
||||
int n = xkb_keysym_to_utf8(sym, buf, sizeof(buf));
|
||||
if (n > 0)
|
||||
app->m_kbd.typing.push_utf8(buf);
|
||||
if (sym == XKB_KEY_Left) {
|
||||
app->m_kbd.typing.push_back(0);
|
||||
} else if (sym == XKB_KEY_Down) {
|
||||
app->m_kbd.typing.push_back(1);
|
||||
} else if (sym == XKB_KEY_Up) {
|
||||
app->m_kbd.typing.push_back(2);
|
||||
} else if (sym == XKB_KEY_Right) {
|
||||
app->m_kbd.typing.push_back(3);
|
||||
} else {
|
||||
u32 cp = xkb_keysym_to_utf32(sym);
|
||||
if (cp >= 0x20) {
|
||||
char buf[8];
|
||||
int n = xkb_keysym_to_utf8(sym, buf, sizeof(buf));
|
||||
if (n > 0)
|
||||
app->m_kbd.typing.push_utf8(buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -300,7 +310,7 @@ auto App::init_egl() -> void
|
||||
|
||||
InitWindow(m_win_w, m_win_h, "");
|
||||
|
||||
m_tr = TextRenderer();
|
||||
m_tr = std::make_shared<TextRenderer>();
|
||||
auto const font = find_font_path();
|
||||
assert(font && "Could not find font");
|
||||
std::vector<std::filesystem::path> fallback_paths;
|
||||
@@ -308,15 +318,15 @@ auto App::init_egl() -> void
|
||||
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",
|
||||
"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)) {
|
||||
@@ -332,8 +342,7 @@ auto App::init_egl() -> void
|
||||
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));
|
||||
auto const font_handle = m_tr->load_font(*font, std::span(fallback_paths));
|
||||
assert(font_handle && "Could not load font");
|
||||
m_font = *font_handle;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user