瀏覽代碼

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.
pull/197/head
raysan5 8 年之前
父節點
當前提交
481ce3d39d
共有 1 個檔案被更改,包括 11 行新增3 行删除
  1. +11
    -3
      src/text.c

+ 11
- 3
src/text.c 查看文件

@ -875,10 +875,18 @@ static SpriteFont LoadBMFont(const char *fileName)
TraceLog(DEBUG, "[%s] Font texture loading path: %s", fileName, texPath); TraceLog(DEBUG, "[%s] Font texture loading path: %s", fileName, texPath);
Image imFont = LoadImage(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.size = fontSize;
font.numChars = numChars; font.numChars = numChars;

Loading…
取消
儲存