summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRay <[email protected]>2022-07-29 12:01:18 +0200
committerRay <[email protected]>2022-07-29 12:01:18 +0200
commitbb6b43b7cbe29dca7f21a78e6944455c6171ead8 (patch)
treeebeaff4101add8f3934b73095ff3732d0376e737
parent241d6526b078e262ecae340cd974eb715be17471 (diff)
downloadraylib-bb6b43b7cbe29dca7f21a78e6944455c6171ead8.tar.gz
raylib-bb6b43b7cbe29dca7f21a78e6944455c6171ead8.zip
REVIEWED: `GenImageFontAtlas()` #2556
Just reviewed font atlas size estimation, now it considers `fontSize` instead of `chars[i].image.height`, increasing considerably the atlas size estimation.
-rw-r--r--src/rtext.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/rtext.c b/src/rtext.c
index 722dbb1d..3b450727 100644
--- a/src/rtext.c
+++ b/src/rtext.c
@@ -686,13 +686,13 @@ Image GenImageFontAtlas(const GlyphInfo *chars, Rectangle **charRecs, int glyphC
// NOTE 2: SDF font characters already contain an internal padding,
// so image size would result bigger than default font type
float requiredArea = 0;
- for (int i = 0; i < glyphCount; i++) requiredArea += ((chars[i].image.width + 2*padding)*(chars[i].image.height + 2*padding));
+ for (int i = 0; i < glyphCount; i++) requiredArea += ((chars[i].image.width + 2*padding)*(fontSize + 2*padding));
float guessSize = sqrtf(requiredArea)*1.4f;
- int imageSize = (int)powf(2, ceilf(logf((float)guessSize)/logf(2))); // Calculate next POT
+ int imageSize = (int)powf(2, ceilf(logf((float)guessSize)/logf(2))); // Calculate next POT
atlas.width = imageSize; // Atlas bitmap width
atlas.height = imageSize; // Atlas bitmap height
- atlas.data = (unsigned char *)RL_CALLOC(1, atlas.width*atlas.height); // Create a bitmap to store characters (8 bpp)
+ atlas.data = (unsigned char *)RL_CALLOC(1, atlas.width*atlas.height); // Create a bitmap to store characters (8 bpp)
atlas.format = PIXELFORMAT_UNCOMPRESSED_GRAYSCALE;
atlas.mipmaps = 1;