There is a logical bug in the distance field cache that spans multiple textures. The way the glyphs are allocated in the cache, it creates a big area allocator with textureSize*textureCount height, and then allocates to this. But since the (glyph heights + padding + margin) are not necessarily a factor in the texture height, some of them may end up at the edge between two textures. The result of this is that the actual texture height will be larger than the maximum size, since it will be correctly expanded to account for the remaining part of the glyph that falls outside the texture.
In addition, the next texture will have an unused section to account for the overlap from the previous texture, but this is just a little wasteful, it is not a critical bug.
Since the case where the caches actually exceed a single maximum sized texture is so rare, we haven't actually seen this happen in the wild. But when using the distancefieldgenerator, it is quite easy to get into this situation since the default texture size is so low.
A proper fix for this would be to have a separate area allocator for each texture instead of one big one, but this would have some implications for the pregenerated cache format. We would still have to support the old in order to support older files.
So a quicker fix is to set the maximum height of the textures in the allocator to be maxSize - fontPixelSize. That way we leave space for exceeding the cache by up to one glyph height. It would be good enough for a rare case.
|For Gerrit Dashboard: QTBUG-76528|
|265692,4||distancefieldgenerator: Avoid exceeding max texture size||5.12||qt/qttools||Status: MERGED||+2||0|
|265694,4||distancefieldgenerator: Fix crash with multiple textures||5.12||qt/qttools||Status: MERGED||+2||0|
|266368,2||Fix distance field cache growing outside limit||5.12||qt/qtdeclarative||Status: MERGED||+2||0|
|266374,2||Fix possible crash when distance field cache spans multiple textures||5.12||qt/qtdeclarative||Status: MERGED||+2||0|