Update rtext.c

This commit is contained in:
Ray
2026-08-26 19:46:45 +02:00
parent 173b854168
commit ba0ac542c5

View File

@@ -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;