shithub: cstory

Download patch

ref: a542a5c11d9ca451ed4ffeb5456150fc09cd96f6
parent: aac1c9c844bb05bf39b8659b2e9a8641e387ce97
author: Clownacy <Clownacy@users.noreply.github.com>
date: Wed Sep 16 17:20:49 EDT 2020

Cleanup and fixes

--- a/src/Font.cpp
+++ b/src/Font.cpp
@@ -1177,8 +1177,6 @@
 
 Font* LoadBitmapFont(const char *bitmap_path, const char *metadata_path)
 {
-	Font *font = NULL;
-
 	size_t bitmap_width, bitmap_height;
 	unsigned char *image_buffer = DecodeBitmapFromFile(bitmap_path, &bitmap_width, &bitmap_height, 1);
 
@@ -1189,7 +1187,7 @@
 
 		if (metadata_buffer != NULL)
 		{
-			font = (Font*)malloc(sizeof(Font));
+			Font *font = (Font*)malloc(sizeof(Font));
 
 			if (font != NULL)
 			{
@@ -1261,7 +1259,7 @@
 		FreeBitmap(image_buffer);
 	}
 
-	return font;
+	return NULL;
 }
 
 void DrawText(Font *font, RenderBackend_Surface *surface, int x, int y, unsigned long colour, const char *string)
@@ -1305,12 +1303,13 @@
 	if (font != NULL)
 	{
 		RenderBackend_DestroyGlyphAtlas(font->atlas);
-
+		free(font->local_glyphs);
 		FreeBitmap(font->image_buffer);
 
 //		FT_Done_Face(font->face);
 //		free(font->data);
 //		FT_Done_FreeType(font->library);
+
 		free(font);
 	}
 }