Corrected bug with alpha mask on font
Mask was wrongly applied to 8-bit font image, it generated dark borders on the font. Grayscale image has to be considered as the alpha mask for a completely white image to use it correctly.
This commit is contained in:
parent
85c400c006
commit
481ce3d39d
1 changed files with 11 additions and 3 deletions
12
src/text.c
12
src/text.c
|
@ -876,9 +876,17 @@ static SpriteFont LoadBMFont(const char *fileName)
|
||||||
|
|
||||||
Image imFont = LoadImage(texPath);
|
Image imFont = LoadImage(texPath);
|
||||||
|
|
||||||
if (imFont.format == UNCOMPRESSED_GRAYSCALE) ImageAlphaMask(&imFont, imFont);
|
if (imFont.format == UNCOMPRESSED_GRAYSCALE)
|
||||||
|
{
|
||||||
|
Image imCopy = ImageCopy(imFont);
|
||||||
|
|
||||||
font.texture = LoadTextureFromImage(imFont);
|
for (int i = 0; i < imCopy.width*imCopy.height; i++) ((unsigned char *)imCopy.data)[i] = 0xff; // WHITE pixel
|
||||||
|
|
||||||
|
ImageAlphaMask(&imCopy, imFont);
|
||||||
|
font.texture = LoadTextureFromImage(imCopy);
|
||||||
|
UnloadImage(imCopy);
|
||||||
|
}
|
||||||
|
else font.texture = LoadTextureFromImage(imFont);
|
||||||
|
|
||||||
font.size = fontSize;
|
font.size = fontSize;
|
||||||
font.numChars = numChars;
|
font.numChars = numChars;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue