From eec97302bb8aff53b3d339a5f1ec2d36ba8b7fad Mon Sep 17 00:00:00 2001 From: zvon Date: Sun, 23 Aug 2020 01:14:59 +0200 Subject: [PATCH] Check if font loaded --- sdlpp.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sdlpp.hpp b/sdlpp.hpp index 9dc5870..424f013 100644 --- a/sdlpp.hpp +++ b/sdlpp.hpp @@ -102,6 +102,10 @@ public: Font() = delete; Font(const std::string &font, int 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() { TTF_CloseFont( font_ptr );