blob: 37dee3a0bdd116f37b50c5924210504a6647d5a6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
#include "../api/Config.h"
#include "Font.h"
using namespace std;
using namespace crepe;
Font::Font(const Asset& src, Mediator& mediator)
: Resource(src, mediator), font(nullptr, TTF_CloseFont) {
// Get the font file path from the Asset
const std::string font_path = src.get_path();
// Attempt to load the font
this->font.reset(TTF_OpenFont(font_path.c_str(), Config::get_instance().font.size));
// Check if font loading failed
if (!this->font) {
throw runtime_error(format("Failed to load font from path: {}"
". SDL_ttf error: {}",font_path, TTF_GetError()));
}
}
TTF_Font* Font::get_font() const {
return this->font.get();
}
|