From ba0ac542c5a87bee01dd38a75396ef60ef36e15e Mon Sep 17 00:00:00 2001 From: Ray Date: Wed, 26 Aug 2026 19:46:45 +0200 Subject: [PATCH] Update rtext.c --- src/rtext.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/rtext.c b/src/rtext.c index a123fea31..08fde1a4e 100644 --- a/src/rtext.c +++ b/src/rtext.c @@ -417,9 +417,6 @@ Font LoadFontFromImage(Image image, Color key, int firstChar) int charSpacing = 0; int lineSpacing = 0; - int x = 0; - int y = 0; - // Allocate a temporal arrays for glyphs data measures, // once the actual number of glyphs is obtained, copy data to a sized array int tempCharValues[MAX_GLYPHS_FROM_IMAGE] = { 0 }; @@ -428,6 +425,8 @@ Font LoadFontFromImage(Image image, Color key, int firstChar) Color *pixels = LoadImageColors(image); // Parse image data to get charSpacing and lineSpacing + int x = 0; + int y = 0; for (y = 0; y < image.height; y++) { for (x = 0; x < image.width; x++) @@ -438,9 +437,11 @@ Font LoadFontFromImage(Image image, Color key, int firstChar) if (!COLOR_EQUAL(pixels[y*image.width + x], key)) break; } - if ((x == 0) || (y == 0)) { - UnloadImageColors(pixels); // Unload pixel colors to prevent memory leak - return font; // Security check + // Security check + if ((x == 0) || (y == 0)) + { + UnloadImageColors(pixels); + return font; } charSpacing = x;