Add skeleton of TextRenderer
Signed-off-by: Slendi <slendi@socopon.com>
This commit is contained in:
43
src/App.cpp
43
src/App.cpp
@@ -1,11 +1,11 @@
|
||||
#include "App.hpp"
|
||||
|
||||
#include <cassert>
|
||||
#include <chrono>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <poll.h>
|
||||
#include <print>
|
||||
#include <pthread.h>
|
||||
#include <signal.h>
|
||||
#include <sys/mman.h>
|
||||
@@ -27,35 +27,6 @@
|
||||
#include "blur-client-protocol.h"
|
||||
#include "ext-background-effect-v1-client-protocol.h"
|
||||
|
||||
auto find_font_path(std::string_view path = "sans-serif:style=Regular")
|
||||
-> std::optional<std::string>
|
||||
{
|
||||
if (!FcInit())
|
||||
return std::nullopt;
|
||||
|
||||
std::string query(path);
|
||||
FcPattern *pattern
|
||||
= FcNameParse(reinterpret_cast<FcChar8 const *>(query.c_str()));
|
||||
FcConfigSubstitute(nullptr, pattern, FcMatchPattern);
|
||||
FcDefaultSubstitute(pattern);
|
||||
|
||||
FcResult result;
|
||||
FcPattern *font = FcFontMatch(nullptr, pattern, &result);
|
||||
|
||||
std::optional<std::string> final_path;
|
||||
|
||||
if (font) {
|
||||
FcChar8 *file;
|
||||
if (FcPatternGetString(font, FC_FILE, 0, &file) == FcResultMatch)
|
||||
final_path = reinterpret_cast<char *>(file);
|
||||
FcPatternDestroy(font);
|
||||
}
|
||||
|
||||
FcPatternDestroy(pattern);
|
||||
FcFini();
|
||||
return final_path;
|
||||
}
|
||||
|
||||
auto TypingBuffer::push_utf8(char const *s) -> void
|
||||
{
|
||||
for (unsigned char const *p = reinterpret_cast<unsigned char const *>(s);
|
||||
@@ -83,11 +54,6 @@ auto TypingBuffer::push_utf8(char const *s) -> void
|
||||
|
||||
App::App()
|
||||
{
|
||||
{
|
||||
auto const path = find_font_path();
|
||||
if (path)
|
||||
std::println("font path = {}", *path);
|
||||
}
|
||||
init_wayland();
|
||||
init_egl();
|
||||
init_signal();
|
||||
@@ -330,6 +296,13 @@ auto App::init_egl() -> void
|
||||
ensure_egl_surface();
|
||||
|
||||
InitWindow(m_win_w, m_win_h, "");
|
||||
|
||||
m_tr = TextRenderer();
|
||||
auto const font = find_font_path();
|
||||
assert(font && "Could not find font");
|
||||
auto const font_handle = m_tr->load_font(*font);
|
||||
assert(font_handle && "Could not load font");
|
||||
m_font = *font_handle;
|
||||
}
|
||||
|
||||
auto App::init_signal() -> void
|
||||
|
||||
Reference in New Issue
Block a user