shithub: cstory

Download patch

ref: 9e9b8942a5a387c7b3ee5a40ad03f936df0e90b8
parent: 5395196b520f36c63d7e052119756cbe426e84c9
author: Clownacy <Clownacy@users.noreply.github.com>
date: Tue Nov 3 08:33:32 EST 2020

Don't upload glyphs with no width or height

The SDLTexture renderer gives annoying errors otherwise

--- a/src/Font.cpp
+++ b/src/Font.cpp
@@ -1082,7 +1082,8 @@
 			glyph->y_offset = (font->face->size->metrics.ascender + (64 / 2)) / 64 - font->face->glyph->bitmap_top;
 			glyph->x_advance = font->face->glyph->advance.x / 64;
 
-			RenderBackend_UploadGlyph(font->atlas, glyph->x, glyph->y, bitmap.buffer, glyph->width, glyph->height, glyph->width);
+			if (glyph->width != 0 && glyph->height != 0)	// Some glyphs are just plain empty - don't bother trying to upload them
+				RenderBackend_UploadGlyph(font->atlas, glyph->x, glyph->y, bitmap.buffer, glyph->width, glyph->height, glyph->width);
 
 			FT_Bitmap_Done(font->library, &bitmap);
 
@@ -1121,7 +1122,8 @@
 		glyph->y_offset = 0;
 		glyph->x_advance = local_glyph->x_advance;
 
-		RenderBackend_UploadGlyph(font->atlas, glyph->x, glyph->y, &font->image_buffer[local_glyph->y * font->image_buffer_width + local_glyph->x], glyph->width, glyph->height, font->image_buffer_width);
+		if (glyph->width != 0 && glyph->height != 0)	// Some glyphs are just plain empty - don't bother trying to upload them
+			RenderBackend_UploadGlyph(font->atlas, glyph->x, glyph->y, &font->image_buffer[local_glyph->y * font->image_buffer_width + local_glyph->x], glyph->width, glyph->height, font->image_buffer_width);
 
 		*glyph_pointer = glyph->next;
 		glyph->next = font->glyph_list_head;