From 2c813446389f134457b9d77dd71ea9c9758d7208 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Fri, 13 Feb 2026 15:11:27 +0300 Subject: [PATCH] test library --- src/coders/vector_fonts.cpp | 34 ++++++++++++++++++++++++++++++++++ src/coders/vector_fonts.hpp | 5 +++++ 2 files changed, 39 insertions(+) create mode 100644 src/coders/vector_fonts.cpp create mode 100644 src/coders/vector_fonts.hpp diff --git a/src/coders/vector_fonts.cpp b/src/coders/vector_fonts.cpp new file mode 100644 index 000000000..a3773a4e5 --- /dev/null +++ b/src/coders/vector_fonts.cpp @@ -0,0 +1,34 @@ +#include "vector_fonts.hpp" + +#include "io/io.hpp" + +#include +#include +#include FT_FREETYPE_H + +static FT_Library library; + +void vector_fonts::initialize() { + if (FT_Error error = FT_Init_FreeType(&library)) { + throw std::runtime_error( + "could not initialize freetype: " + + std::string(FT_Error_String(error)) + ); + } +} + +static FT_Face load_ft_face(const io::path& path) { + auto bytes = io::read_bytes_buffer(path); + + FT_Face face; + + if (FT_Error error = + FT_New_Memory_Face(library, bytes.data(), bytes.size(), 0, &face)) { + throw std::runtime_error( + "could not load font '" + path.string() + + "': " + std::string(FT_Error_String(error)) + ); + } + + return face; +} diff --git a/src/coders/vector_fonts.hpp b/src/coders/vector_fonts.hpp new file mode 100644 index 000000000..4e093d593 --- /dev/null +++ b/src/coders/vector_fonts.hpp @@ -0,0 +1,5 @@ +#pragma once + +namespace vector_fonts { + void initialize(); +}