35 lines
695 B
C++
35 lines
695 B
C++
#include <iostream>
|
|
#include <string>
|
|
#include <fmt/format.h>
|
|
#include "font.hpp"
|
|
|
|
namespace hibis {
|
|
namespace rsdl {
|
|
Font::Font(std::string path, uint size) {
|
|
this->size = size;
|
|
this->path = path;
|
|
loadFont();
|
|
}
|
|
|
|
Font::~Font() {
|
|
TTF_CloseFont(loadedFont);
|
|
}
|
|
|
|
void Font::loadFont(bool reload) {
|
|
// If already loaded, close font
|
|
if (loadedFont != NULL) {
|
|
TTF_CloseFont(loadedFont);
|
|
loadedFont = NULL;
|
|
}
|
|
|
|
loadedFont = TTF_OpenFont(path.c_str(), size);
|
|
|
|
// Do the message
|
|
if (!didReload) {
|
|
std::cout << fmt::format((reload ? "Reloaded font from" : "Loaded font at") + (std::string)" {}", path) << std::endl;
|
|
didReload = reload;
|
|
}
|
|
}
|
|
}
|
|
}
|