#include "Display/UI/Text/FontFace.h" #include #include FT_FREETYPE_H #include namespace Display::UI::Text { struct FontFace::FreeType { FT_Library library = nullptr; FT_Face face = nullptr; }; FontFace::FontFace(const std::string &path, int pixelSize) : freetype(std::make_unique()) { if (FT_Init_FreeType(&freetype->library)) throw std::runtime_error("FT_Init_FreeType failed"); if (FT_New_Face(freetype->library, path.c_str(), 0, &freetype->face)) throw std::runtime_error("FT_New_Face failed"); FT_Set_Pixel_Sizes(freetype->face, 0, pixelSize); } FontFace::~FontFace() { if (freetype->face) FT_Done_Face(freetype->face); if (freetype->library) FT_Done_FreeType(freetype->library); } void *FontFace::getFace() const { return freetype->face; } } // namespace Display::UI::Text