raylib icon indicating copy to clipboard operation
raylib copied to clipboard

Calculate exact image size in GenImageFontAtlas

Open hanaxar opened this issue 2 years ago • 1 comments

Calculate exact image size with a method based on total glyph width and glyph row count. Current method seemed a little bit overkill with square root, log and power functions and only approximates image size which can be wonky with some weird fonts like cursive fonts. Proposed method calculates image size directly with a simpler (and probably faster) method and results exact image size needed.

hanaxar avatar Mar 17 '23 10:03 hanaxar

@hanaxar Thanks for the review. Would it be possible to use a simple while() loop? I try to avoid the do-while approach in raylib.

raysan5 avatar Mar 20 '23 17:03 raysan5

Converted do-while into while() loop. And also added an extra step to calculate maximum glyph width and excluding it from the image width for safety.

hanaxar avatar Mar 20 '23 22:03 hanaxar

@hanaxar Thank you very much for the improvement!

raysan5 avatar Mar 22 '23 09:03 raysan5