From cc4934c0fbc48aa1fbd3347071bf8ca6d43e835a Mon Sep 17 00:00:00 2001 From: Steve Date: Tue, 11 Dec 2018 15:32:04 +0000 Subject: [PATCH] Error handling. --- src/system/text.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/system/text.c b/src/system/text.c index a369519..f0712f1 100644 --- a/src/system/text.c +++ b/src/system/text.c @@ -86,6 +86,12 @@ static void initFont(char *name, char *filename) dest.x = 0; dest.y += dest.h + 1; + + if (dest.y + dest.h >= FONT_TEXTURE_SIZE) + { + SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_CRITICAL, "Out of glyph space in %dx%d font atlas texture map.", FONT_TEXTURE_SIZE, FONT_TEXTURE_SIZE); + exit(1); + } } SDL_BlitSurface(text, NULL, surface, &dest); @@ -301,7 +307,7 @@ static Glyph *findGlyph(char *c) } } - SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_CRITICAL, "Couldn't find glyph for '%s'\n", c); + SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_CRITICAL, "Couldn't find glyph for '%s'", c); exit(1); return NULL;