From 56072a631dbcde21c4b65917c1ce97262d064a5a Mon Sep 17 00:00:00 2001 From: Dan Bechard Date: Sat, 13 Aug 2022 05:18:57 -0400 Subject: [PATCH] Fix Codepoint position truncation (#2636) This truncation causes text that spans the zero coord boundary to round differently left or zero vs. right of zero, in turn causing letters to appear squished together. If you actually need the position to be an integer, you should instead `floorf()` the float, rather than doing an integer truncation, but I don't see any reason to convert it to an integer in the first place. Everything else in the equation is a float. --- src/rtext.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rtext.c b/src/rtext.c index 63bcdfdea..40f6d3b5a 100644 --- a/src/rtext.c +++ b/src/rtext.c @@ -1093,8 +1093,8 @@ void DrawTextCodepoint(Font font, int codepoint, Vector2 position, float fontSiz // Character destination rectangle on screen // NOTE: We consider glyphPadding on drawing - Rectangle dstRec = { (int)position.x + font.glyphs[index].offsetX*scaleFactor - (float)font.glyphPadding*scaleFactor, - (int)position.y + font.glyphs[index].offsetY*scaleFactor - (float)font.glyphPadding*scaleFactor, + Rectangle dstRec = { position.x + font.glyphs[index].offsetX*scaleFactor - (float)font.glyphPadding*scaleFactor, + position.y + font.glyphs[index].offsetY*scaleFactor - (float)font.glyphPadding*scaleFactor, (font.recs[index].width + 2.0f*font.glyphPadding)*scaleFactor, (font.recs[index].height + 2.0f*font.glyphPadding)*scaleFactor };