aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorraysan5 <raysan5@gmail.com>2016-11-21 19:47:58 +0100
committerraysan5 <raysan5@gmail.com>2016-11-21 19:47:58 +0100
commit481ce3d39d8072d20b425dba928efe4cff522db9 (patch)
tree054cf37cf5a52b888752f5ccd9e4e18af0c2e305 /src
parent85c400c006cd2ef7dd4133ccb47223069334a38d (diff)
downloadraylib-481ce3d39d8072d20b425dba928efe4cff522db9.tar.gz
raylib-481ce3d39d8072d20b425dba928efe4cff522db9.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/text.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/text.c b/src/text.c
index d752f1cb..c394889e 100644
--- a/src/text.c
+++ b/src/text.c
@@ -875,10 +875,18 @@ static SpriteFont LoadBMFont(const char *fileName)
TraceLog(DEBUG, "[%s] Font texture loading path: %s", fileName, texPath);
Image imFont = LoadImage(texPath);
+
+ if (imFont.format == UNCOMPRESSED_GRAYSCALE)
+ {
+ Image imCopy = ImageCopy(imFont);
+
+ for (int i = 0; i < imCopy.width*imCopy.height; i++) ((unsigned char *)imCopy.data)[i] = 0xff; // WHITE pixel
- if (imFont.format == UNCOMPRESSED_GRAYSCALE) ImageAlphaMask(&imFont, imFont);
-
- font.texture = LoadTextureFromImage(imFont);
+ ImageAlphaMask(&imCopy, imFont);
+ font.texture = LoadTextureFromImage(imCopy);
+ UnloadImage(imCopy);
+ }
+ else font.texture = LoadTextureFromImage(imFont);
font.size = fontSize;
font.numChars = numChars;