From a542a5c11d9ca451ed4ffeb5456150fc09cd96f6 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Wed, 16 Sep 2020 21:20:49 +0100 Subject: [PATCH] Cleanup and fixes --- src/Font.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Font.cpp b/src/Font.cpp index 55cb6078..ac62be5a 100644 --- a/src/Font.cpp +++ b/src/Font.cpp @@ -1177,8 +1177,6 @@ Font* LoadFont(const char *font_filename, size_t cell_width, size_t cell_height) 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 @@ Font* LoadBitmapFont(const char *bitmap_path, const char *metadata_path) if (metadata_buffer != NULL) { - font = (Font*)malloc(sizeof(Font)); + Font *font = (Font*)malloc(sizeof(Font)); if (font != NULL) { @@ -1261,7 +1259,7 @@ Font* LoadBitmapFont(const char *bitmap_path, const char *metadata_path) 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 @@ void UnloadFont(Font *font) 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); } }