summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorhkc <[email protected]>2022-10-14 18:43:12 +0300
committerGitHub <[email protected]>2022-10-14 17:43:12 +0200
commit0b69bc28c6dc671970b9cbe9dcf2bcdf1d8506d7 (patch)
tree6692b016629263406b4f8e1371a9d09c580d4e29 /src
parente61639f6fc46856ee3e66b28796a58ecb42278b1 (diff)
downloadraylib-0b69bc28c6dc671970b9cbe9dcf2bcdf1d8506d7.tar.gz
raylib-0b69bc28c6dc671970b9cbe9dcf2bcdf1d8506d7.zip
Fix ImageTextEx and ImageDrawTextEx scaling (#2756)
* Use RL_QUADS/RL_TRIANGLES for single-pixel drawing Addresses problem mentioned in https://github.com/raysan5/raylib/issues/2744#issuecomment-1273568263 (in short: when drawing pixels using DrawPixel{,V} in camera mode, upscaled pixel becomes a line instead of bigger pixel) * [rtextures] Fixed scaling down in ImageTextEx Closes #2755
Diffstat (limited to 'src')
-rw-r--r--src/rtextures.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/rtextures.c b/src/rtextures.c
index 45a96a16..569832ac 100644
--- a/src/rtextures.c
+++ b/src/rtextures.c
@@ -1248,6 +1248,7 @@ Image ImageTextEx(Font font, const char *text, float fontSize, float spacing, Co
// NOTE: Text image is generated at font base size, later scaled to desired font size
Vector2 imSize = MeasureTextEx(font, text, (float)font.baseSize, spacing); // WARNING: Module required: rtext
+ Vector2 textSize = MeasureTextEx(font, text, fontSize, spacing);
// Create image to store text
imText = GenImageColor((int)imSize.x, (int)imSize.y, BLANK);
@@ -1286,9 +1287,9 @@ Image ImageTextEx(Font font, const char *text, float fontSize, float spacing, Co
}
// Scale image depending on text size
- if (fontSize > imSize.y)
+ if (textSize.y != imSize.y)
{
- float scaleFactor = fontSize/imSize.y;
+ float scaleFactor = textSize.y / imSize.y;
TRACELOG(LOG_INFO, "IMAGE: Text scaled by factor: %f", scaleFactor);
// Using nearest-neighbor scaling algorithm for default font