First commit

This commit is contained in:
2025-12-23 21:24:06 +00:00
parent 2a30c0d77b
commit f5dc0ccbc9
52 changed files with 1663 additions and 208 deletions
+38
View File
@@ -0,0 +1,38 @@
#include "Display/UI/Text/FontFace.h"
#include <ft2build.h>
#include FT_FREETYPE_H
#include <stdexcept>
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<FreeType>())
{
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