blob: a9f1633064951e531d5eeda9fe17804c4f1d2866 (
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
26
27
|
#include "../api/Config.h"
#include "util/Log.h"
#include <iostream>
#include "Font.h"
using namespace std;
using namespace crepe;
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)
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();
}
TTF_Font * Font::get_font() const { return this->font.get(); }
|