Fill truetype font glyph atlases with transparent white instead of transparent black in the borders between glyphs. Fixes black fringes around text (resolves issue #1495) and reduces the appearance of flickering when text is moved at non-integer coordinates and gamma correct rendering isn't enabled (closes issue #1143).

This commit is contained in:
Alex Szpakowski
2019-05-27 19:36:22 -03:00
parent 46d8b07e41
commit 02fa8b0b2b
+12 -2
View File
@@ -153,9 +153,19 @@ void Font::createTexture()
image->setFilter(filter);
{
// Initialize the texture with transparent black.
size_t bpp = getPixelFormatSize(pixelFormat);
std::vector<uint8> emptydata(size.width * size.height * bpp, 0);
size_t pixelcount = size.width * size.height;
// Initialize the texture with transparent white for Luminance-Alpha
// formats (since we keep luminance constant and vary alpha in those
// glyphs), and transparent black otherwise.
std::vector<uint8> emptydata(pixelcount * bpp, 0);
if (pixelFormat == PIXELFORMAT_LA8)
{
for (size_t i = 0; i < pixelcount; i++)
emptydata[i * 2 + 0] = 255;
}
Rect rect = {0, 0, size.width, size.height};
image->replacePixels(emptydata.data(), emptydata.size(), 0, 0, rect, false);