-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcfont.cpp
More file actions
31 lines (28 loc) · 724 Bytes
/
cfont.cpp
File metadata and controls
31 lines (28 loc) · 724 Bytes
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
28
29
30
31
#include "cfont.hpp"
#include "color.hpp"
#include <Imlib2.h>
#include <iostream>
#include <sstream>
#include <stdlib.h>
CFont::CFont(string _name, float _size, Color _color)
: name(_name), size(_size), color(_color) {
std::ostringstream ss;
ss << size;
string s_size = string(ss.str());
imlib_font = imlib_load_font((name + "/" + s_size).c_str());
if (imlib_font == NULL) {
std::cerr<< "Error loading font " <<name<< "\n";
exit(-1);
}
}
void CFont::free() {
imlib_context_set_font(imlib_font);
imlib_free_font();
}
void CFont::use() {
imlib_context_set_font(imlib_font);
color.use();
}
void CFont::addFontpath(string path) {
imlib_add_path_to_font_path(path.c_str());
}