29 lines
730 B
C++
29 lines
730 B
C++
#include "font.hpp"
|
|
|
|
#include <gz-util/exceptions.hpp>
|
|
|
|
namespace gz {
|
|
|
|
FontManager::FontManager(const std::string&& fontDir)
|
|
: fontDir(fontDir) {
|
|
FT_Error error = FT_Init_FreeType(&freetype);
|
|
if (error != FT_Err_Ok) {
|
|
throw Exception("Could not load freetype library", "FontManager");
|
|
}
|
|
|
|
}
|
|
|
|
|
|
void FontManager::loadFont(const std::string& font) {
|
|
FT_Error error = FT_New_Face(freetype, (fontDir + "/" + font).c_str(), 0, &faces[font]);
|
|
if (error != FT_Err_Ok) {
|
|
throw Exception("Could not load font.", "FontManager::loadFont");
|
|
}
|
|
FT_Set_Pixel_Sizes(faces[font], 0, 48);
|
|
if (FT_Load_Char(faces[font], 'X', FT_LOAD_RENDER)) {
|
|
throw Exception("Could not load char.", "FontManager::loadFont");
|
|
}
|
|
}
|
|
|
|
}
|