aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/facade/Font.cpp
diff options
context:
space:
mode:
authorheavydemon21 <nielsstunnebrink1@gmail.com>2024-12-17 09:09:32 +0100
committerheavydemon21 <nielsstunnebrink1@gmail.com>2024-12-17 09:09:32 +0100
commitbfc07676707eae2c0161c6b86ccdd1583d96f71b (patch)
treeb18bd17b0d07b3b51b2461462e3380d36905e61f /src/crepe/facade/Font.cpp
parent2f8d36a33854715828d412792663f355b9e393ae (diff)
parentd63eb7302d05fbe9b4c044ece3444e8ac4e56e02 (diff)
Merge branch 'wouter/text-component' into niels/UI
Diffstat (limited to 'src/crepe/facade/Font.cpp')
-rw-r--r--src/crepe/facade/Font.cpp16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/crepe/facade/Font.cpp b/src/crepe/facade/Font.cpp
index a9f1633..8c16563 100644
--- a/src/crepe/facade/Font.cpp
+++ b/src/crepe/facade/Font.cpp
@@ -1,3 +1,4 @@
+#include "../api/Asset.h"
#include "../api/Config.h"
#include "util/Log.h"
#include <iostream>
@@ -11,17 +12,12 @@ Font::Font(const Asset & src, Mediator & mediator)
: Resource(src, mediator) {
dbg_trace();
Config & config = Config::get_instance();
- const std::string & FONT_PATH = src.get_path();
- cout << FONT_PATH.c_str() << endl;
- TTF_Font * font = TTF_OpenFont(FONT_PATH.c_str(), config.font.size);
- if (font == NULL)
+ 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 = {font, [](TTF_Font * font) { TTF_CloseFont(font); }};
-}
-
-Font::~Font(){
- dbg_trace();
- this->font.reset();
+ }
+ this->font = {loaded_font, [](TTF_Font * font) { TTF_CloseFont(font); }};
}
TTF_Font * Font::get_font() const { return this->font.get(); }