diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-12-18 13:36:52 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-12-18 13:36:52 +0100 |
commit | 0e800c6857122436e7a766c6934991aa1d8d31ff (patch) | |
tree | ce5eb98a3b93b40b9535613b84eff3a7a4b1854a /src/crepe/facade/Font.cpp | |
parent | 3c7373eba71ccf5f16069d540c9f66e297895b1a (diff) | |
parent | 81404db80bbf9463c3d535ae389e7fbb753a902c (diff) |
Merge branch 'master' into loek/savemgrloek/savemgr
Diffstat (limited to 'src/crepe/facade/Font.cpp')
-rw-r--r-- | src/crepe/facade/Font.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/crepe/facade/Font.cpp b/src/crepe/facade/Font.cpp new file mode 100644 index 0000000..771002f --- /dev/null +++ b/src/crepe/facade/Font.cpp @@ -0,0 +1,21 @@ +#include <SDL2/SDL_ttf.h> + +#include "../api/Asset.h" +#include "../api/Config.h" + +#include "Font.h" + +using namespace std; +using namespace crepe; + +Font::Font(const Asset & src, Mediator & mediator) : Resource(src, mediator) { + const Config & config = Config::get_instance(); + const std::string FONT_PATH = src.get_path(); + TTF_Font * loaded_font = TTF_OpenFont(FONT_PATH.c_str(), config.font.size); + if (loaded_font == NULL) { + throw runtime_error(format("Font: {} (path: {})", TTF_GetError(), FONT_PATH)); + } + this->font = {loaded_font, [](TTF_Font * close_font) { TTF_CloseFont(close_font); }}; +} + +TTF_Font * Font::get_font() const { return this->font.get(); } |