First commit
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user