mirror of
https://github.com/raysan5/raylib.git
synced 2025-09-11 22:08:15 +00:00
REVIEWED: GetCodepoints() issue
- Improved LoadBMFont()
This commit is contained in:
17
src/text.c
17
src/text.c
@@ -887,6 +887,8 @@ int *GetCodepoints(const char *text, int *count)
|
|||||||
i += bytesProcessed;
|
i += bytesProcessed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*count = codepointsCount;
|
||||||
|
|
||||||
return codepoints;
|
return codepoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1594,18 +1596,15 @@ static Font LoadBMFont(const char *fileName)
|
|||||||
TraceLog(LOG_DEBUG, "[%s] Font texture loading path: %s", fileName, texPath);
|
TraceLog(LOG_DEBUG, "[%s] Font texture loading path: %s", fileName, texPath);
|
||||||
|
|
||||||
Image imFont = LoadImage(texPath);
|
Image imFont = LoadImage(texPath);
|
||||||
Image imFontAlpha = ImageCopy(imFont);
|
|
||||||
|
|
||||||
if (imFont.format == UNCOMPRESSED_GRAYSCALE)
|
if (imFont.format == UNCOMPRESSED_GRAYSCALE)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < imFontAlpha.width*imFontAlpha.height; i++) ((unsigned char *)imFontAlpha.data)[i] = 0xff;
|
// Convert image to GRAYSCALE + ALPHA, using the mask as the alpha channel
|
||||||
|
ImageAlphaMask(&imFont, imFont);
|
||||||
ImageAlphaMask(&imFontAlpha, imFont);
|
for (int p = 0; p < (imFont.width*imFont.height*2); p += 2) ((unsigned char *)(imFont.data))[p] = 0xff;
|
||||||
font.texture = LoadTextureFromImage(imFontAlpha);
|
|
||||||
}
|
}
|
||||||
else font.texture = LoadTextureFromImage(imFont);
|
|
||||||
|
|
||||||
UnloadImage(imFont);
|
font.texture = LoadTextureFromImage(imFont);
|
||||||
|
|
||||||
RL_FREE(texPath);
|
RL_FREE(texPath);
|
||||||
|
|
||||||
@@ -1633,10 +1632,10 @@ static Font LoadBMFont(const char *fileName)
|
|||||||
font.chars[i].advanceX = charAdvanceX;
|
font.chars[i].advanceX = charAdvanceX;
|
||||||
|
|
||||||
// Fill character image data from imFont data
|
// Fill character image data from imFont data
|
||||||
font.chars[i].image = ImageFromImage(imFontAlpha, font.recs[i]);
|
font.chars[i].image = ImageFromImage(imFont, font.recs[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
UnloadImage(imFontAlpha);
|
UnloadImage(imFont);
|
||||||
|
|
||||||
fclose(fntFile);
|
fclose(fntFile);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user