#include "TextureBase.hpp"
#include "Viewport.hpp"
-#include "../app/init.hpp"
+#include "../app/error.hpp"
#include <algorithm>
#include <cstring>
Font::Font(const char *src, int size, long index)
: handle(TTF_OpenFontIndex(src, size, index)) {
if (!handle) {
- throw std::runtime_error(TTF_GetError());
+ throw TTFError("TTF_OpenFontIndex");
}
}
glm::ivec2 Font::TextSize(const char *text) const {
glm::ivec2 size;
if (TTF_SizeUTF8(handle, text, &size.x, &size.y) != 0) {
- throw std::runtime_error(TTF_GetError());
+ throw TTFError("TTF_SizeUTF8");
}
return size;
}
void Font::Render(const char *text, Texture &tex) const {
SDL_Surface *srf = TTF_RenderUTF8_Blended(handle, text, { 0xFF, 0xFF, 0xFF, 0xFF });
if (!srf) {
- throw std::runtime_error(TTF_GetError());
+ throw TTFError("TTF_RenderUTF8_Blended");
}
tex.Bind();
tex.Data(*srf, false);