Update rtext.c
This commit is contained in:
parent
173b854168
commit
ba0ac542c5
1 changed files with 7 additions and 6 deletions
13
src/rtext.c
13
src/rtext.c
|
|
@ -417,9 +417,6 @@ Font LoadFontFromImage(Image image, Color key, int firstChar)
|
||||||
int charSpacing = 0;
|
int charSpacing = 0;
|
||||||
int lineSpacing = 0;
|
int lineSpacing = 0;
|
||||||
|
|
||||||
int x = 0;
|
|
||||||
int y = 0;
|
|
||||||
|
|
||||||
// Allocate a temporal arrays for glyphs data measures,
|
// Allocate a temporal arrays for glyphs data measures,
|
||||||
// once the actual number of glyphs is obtained, copy data to a sized array
|
// once the actual number of glyphs is obtained, copy data to a sized array
|
||||||
int tempCharValues[MAX_GLYPHS_FROM_IMAGE] = { 0 };
|
int tempCharValues[MAX_GLYPHS_FROM_IMAGE] = { 0 };
|
||||||
|
|
@ -428,6 +425,8 @@ Font LoadFontFromImage(Image image, Color key, int firstChar)
|
||||||
Color *pixels = LoadImageColors(image);
|
Color *pixels = LoadImageColors(image);
|
||||||
|
|
||||||
// Parse image data to get charSpacing and lineSpacing
|
// Parse image data to get charSpacing and lineSpacing
|
||||||
|
int x = 0;
|
||||||
|
int y = 0;
|
||||||
for (y = 0; y < image.height; y++)
|
for (y = 0; y < image.height; y++)
|
||||||
{
|
{
|
||||||
for (x = 0; x < image.width; x++)
|
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 (!COLOR_EQUAL(pixels[y*image.width + x], key)) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((x == 0) || (y == 0)) {
|
// Security check
|
||||||
UnloadImageColors(pixels); // Unload pixel colors to prevent memory leak
|
if ((x == 0) || (y == 0))
|
||||||
return font; // Security check
|
{
|
||||||
|
UnloadImageColors(pixels);
|
||||||
|
return font;
|
||||||
}
|
}
|
||||||
|
|
||||||
charSpacing = x;
|
charSpacing = x;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue