diff --git a/src/modules/graphics/Font.cpp b/src/modules/graphics/Font.cpp index 08e94a28f..6d111b0e4 100644 --- a/src/modules/graphics/Font.cpp +++ b/src/modules/graphics/Font.cpp @@ -152,12 +152,14 @@ void Font::createTexture() image = gfx->newImage(TEXTURE_2D, pixelFormat, size.width, size.height, 1, settings); image->setFilter(filter); - // Initialize the texture with transparent black. - size_t bpp = getPixelFormatSize(pixelFormat); - std::vector emptydata(size.width * size.height * bpp, 0); + { + // Initialize the texture with transparent black. + size_t bpp = getPixelFormatSize(pixelFormat); + std::vector emptydata(size.width * size.height * bpp, 0); - Rect rect = {0, 0, size.width, size.height}; - image->replacePixels(emptydata.data(), emptydata.size(), 0, 0, rect, false); + Rect rect = {0, 0, size.width, size.height}; + image->replacePixels(emptydata.data(), emptydata.size(), 0, 0, rect, false); + } images.emplace_back(image, Acquire::NORETAIN);