shithub: cstory

Download patch

ref: bdbebf9a351fe2ca1ff6fd9aeabf17440e9effae
parent: d0ec163e0acc1c8ed692c8272fb9998fec333021
parent: 88602ccaf6f22208be9ec37efaf22d4904139079
author: Clownacy <Clownacy@users.noreply.github.com>
date: Wed Apr 29 12:13:08 EDT 2020

Merge branch 'portable' of https://github.com/Clownacy/Cave-Story-Engine-2 into portable

--- a/src/Font.cpp
+++ b/src/Font.cpp
@@ -1012,17 +1012,18 @@
 						break;
 				}
 
-				glyph->backend = RenderBackend_LoadGlyph(bitmap.buffer, bitmap.width, bitmap.rows, bitmap.pitch);
+				// Don't bother loading glyphs that don't have an image (causes `cute_spritebatch.h` to freak-out)
+				if (bitmap.width == 0 || bitmap.rows == 0)
+					glyph->backend = NULL;
+				else
+					glyph->backend = RenderBackend_LoadGlyph(bitmap.buffer, bitmap.width, bitmap.rows, bitmap.pitch);
 
 				FT_Bitmap_Done(font_object->library, &bitmap);
 
-				if (glyph->backend != NULL)
-				{
-					glyph->next = font_object->glyph_list_head;
-					font_object->glyph_list_head = glyph;
+				glyph->next = font_object->glyph_list_head;
+				font_object->glyph_list_head = glyph;
 
-					return glyph;
-				}
+				return glyph;
 			}
 
 			FT_Bitmap_Done(font_object->library, &bitmap);
@@ -1041,7 +1042,9 @@
 	{
 		CachedGlyph *next_glyph = glyph->next;
 
-		RenderBackend_UnloadGlyph(glyph->backend);
+		if (glyph->backend != NULL)
+			RenderBackend_UnloadGlyph(glyph->backend);
+
 		free(glyph);
 
 		glyph = next_glyph;