mirror of
https://github.com/love2d/love.git
synced 2026-08-12 08:30:56 +02:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user