summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTim Romero <[email protected]>2024-01-10 12:34:04 -0800
committerGitHub <[email protected]>2024-01-10 21:34:04 +0100
commit2c124c96dfdb1b81aa3fef099739442ce2d9fa9d (patch)
treeeed89563e4a11d4e06b7c423233755f23e640732
parentbe78255beac318e2dac68550202bb4ef8620f30c (diff)
downloadraylib-2c124c96dfdb1b81aa3fef099739442ce2d9fa9d.tar.gz
raylib-2c124c96dfdb1b81aa3fef099739442ce2d9fa9d.zip
[rtext] Adjust font atlas area calculation so padding area is not underestimated at small font sizes. (#3719)
-rw-r--r--src/rtext.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/rtext.c b/src/rtext.c
index a7c8a726..270d0121 100644
--- a/src/rtext.c
+++ b/src/rtext.c
@@ -725,7 +725,7 @@ Image GenImageFontAtlas(const GlyphInfo *glyphs, Rectangle **glyphRecs, int glyp
for (int i = 0; i < glyphCount; i++)
{
if (glyphs[i].image.width > maxGlyphWidth) maxGlyphWidth = glyphs[i].image.width;
- totalWidth += glyphs[i].image.width + 4*padding;
+ totalWidth += glyphs[i].image.width + 2*padding;
}
//#define SUPPORT_FONT_ATLAS_SIZE_CONSERVATIVE
@@ -743,8 +743,9 @@ Image GenImageFontAtlas(const GlyphInfo *glyphs, Rectangle **glyphRecs, int glyp
atlas.width = imageSize; // Atlas bitmap width
atlas.height = imageSize; // Atlas bitmap height
#else
+ int paddedFontSize = fontSize + 2*padding;
// No need for a so-conservative atlas generation
- float totalArea = totalWidth*fontSize*1.2f;
+ float totalArea = totalWidth*paddedFontSize*1.2f;
float imageMinSize = sqrtf(totalArea);
int imageSize = (int)powf(2, ceilf(logf(imageMinSize)/logf(2)));