mirror of
https://github.com/raysan5/raylib.git
synced 2025-09-16 00:08:15 +00:00
Corrected bug on spritefont loading
This commit is contained in:
15
src/text.c
15
src/text.c
@@ -241,9 +241,8 @@ SpriteFont LoadSpriteFont(const char *fileName)
|
|||||||
{
|
{
|
||||||
Image image = LoadImage(fileName);
|
Image image = LoadImage(fileName);
|
||||||
|
|
||||||
#if defined(PLATFORM_WEB)
|
if (image.data != NULL)
|
||||||
ImageToPOT(&image, MAGENTA);
|
{
|
||||||
#endif
|
|
||||||
// Process bitmap font pixel data to get characters measures
|
// Process bitmap font pixel data to get characters measures
|
||||||
// spriteFont chars data is filled inside the function and memory is allocated!
|
// spriteFont chars data is filled inside the function and memory is allocated!
|
||||||
int numChars = ParseImageData(image, &spriteFont.charValues, &spriteFont.charRecs);
|
int numChars = ParseImageData(image, &spriteFont.charValues, &spriteFont.charRecs);
|
||||||
@@ -254,6 +253,12 @@ SpriteFont LoadSpriteFont(const char *fileName)
|
|||||||
spriteFont.numChars = numChars;
|
spriteFont.numChars = numChars;
|
||||||
spriteFont.texture = LoadTextureFromImage(image); // Convert loaded image to OpenGL texture
|
spriteFont.texture = LoadTextureFromImage(image); // Convert loaded image to OpenGL texture
|
||||||
spriteFont.size = spriteFont.charRecs[0].height;
|
spriteFont.size = spriteFont.charRecs[0].height;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TraceLog(WARNING, "[%s] SpriteFont could not be loaded, using default font", fileName, numChars);
|
||||||
|
spriteFont = GetDefaultFont();
|
||||||
|
}
|
||||||
|
|
||||||
UnloadImage(image);
|
UnloadImage(image);
|
||||||
}
|
}
|
||||||
@@ -545,7 +550,9 @@ static SpriteFont LoadRBMF(const char *fileName)
|
|||||||
|
|
||||||
if (rbmfFile == NULL)
|
if (rbmfFile == NULL)
|
||||||
{
|
{
|
||||||
TraceLog(WARNING, "[%s] rBMF font file could not be opened", fileName);
|
TraceLog(WARNING, "[%s] rBMF font file could not be opened, using default font", fileName);
|
||||||
|
|
||||||
|
spriteFont = GetDefaultFont();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user