Check if font loaded

This commit is contained in:
zvon 2020-08-23 01:14:59 +02:00
parent 6acfff3e8f
commit eec97302bb

View File

@ -102,6 +102,10 @@ public:
Font() = delete; Font() = delete;
Font(const std::string &font, int size) { Font(const std::string &font, int size) {
font_ptr = TTF_OpenFont(font.c_str(), size); font_ptr = TTF_OpenFont(font.c_str(), size);
if(font_ptr == NULL) {
std::cerr << "Unable to load font '" << font << "': TTF Error: " << TTF_GetError() << std::endl;
throw "TTF_OpenFont error";
}
} }
~Font() { ~Font() {
TTF_CloseFont( font_ptr ); TTF_CloseFont( font_ptr );