From 191dc08564f308bd5ff11953f72b3949a880be42 Mon Sep 17 00:00:00 2001 From: iikare <13582030+iikare@users.noreply.github.com> Date: Tue, 5 Jul 2022 13:37:28 -0700 Subject: [PATCH] convert `while()` loop to `for()` loop --- src/rtext.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/rtext.c b/src/rtext.c index f3cc4f3d1..1a5004271 100644 --- a/src/rtext.c +++ b/src/rtext.c @@ -690,7 +690,6 @@ Image GenImageFontAtlas(const GlyphInfo *chars, Rectangle **charRecs, int glyphC float guessSize = sqrtf(requiredArea)*1.4f; int imageSize = (int)powf(2, ceilf(logf((float)guessSize)/logf(2))); // Calculate next POT - int currentRepeatCount = 0; const int maxRepeatCount = 2; bool undersizedAtlasFlag = false; @@ -708,7 +707,7 @@ Image GenImageFontAtlas(const GlyphInfo *chars, Rectangle **charRecs, int glyphC // When the guesstimate of the atlas size is determined to be undersized, // repeat the atlas generation process with an atlas data texture of a size // that is double the previous size, up to a limit of `maxRepeatCount` times - while (currentRepeatCount < maxRepeatCount) + for (int currentRepeatCount = 0; currentRepeatCount <= maxRepeatCount; currentRepeatCount++) { if (currentRepeatCount > 0) { @@ -761,13 +760,12 @@ Image GenImageFontAtlas(const GlyphInfo *chars, Rectangle **charRecs, int glyphC if (offsetY > (atlas.height - fontSize - padding)) { // The current atlas is too small to hold all glyphs, so move to the next atlas size - currentRepeatCount++; undersizedAtlasFlag = true; // If the process repeats more times than the defined limit, abort and log the unpackaged characters for(int j = i + 1; j < glyphCount; j++) { - if (currentRepeatCount > maxRepeatCount) + if (currentRepeatCount == maxRepeatCount) { TRACELOG(LOG_WARNING, "FONT: Failed to package character (%i)", j); }