mirror of
https://github.com/raysan5/raylib.git
synced 2026-08-27 17:41:33 +00:00
Update rtext.c
This commit is contained in:
13
src/rtext.c
13
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;
|
||||
|
||||
Reference in New Issue
Block a user