aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay <raysan5@gmail.com>2019-04-24 22:39:40 +0200
committerGitHub <noreply@github.com>2019-04-24 22:39:40 +0200
commite1cd4674e76f2784948c14e2ed49a50e4bd1d71e (patch)
tree0d2354c91c77ab0783b655a1a398ab881998b3fb
parent96cd3b5abcbabd421d9017a0f764c0b5313e55db (diff)
parent86f9ea6e7a0962f3a1a066ed2e7cf0acd2f7df98 (diff)
downloadraylib-e1cd4674e76f2784948c14e2ed49a50e4bd1d71e.tar.gz
raylib-e1cd4674e76f2784948c14e2ed49a50e4bd1d71e.zip
Merge pull request #817 from Demizdor/fix_draw_text_rec_ex
Fixed text selection in DrawTextRecEx()
-rw-r--r--src/text.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/text.c b/src/text.c
index 22bd7659..15b8d555 100644
--- a/src/text.c
+++ b/src/text.c
@@ -900,7 +900,7 @@ void DrawTextRecEx(Font font, const char *text, Rectangle rec, float fontSize, f
int startLine = -1; // Index where to begin drawing (where a line begins)
int endLine = -1; // Index where to stop drawing (where a line ends)
- for (int i = 0; i < length; i++)
+ for (int i = 0, k = 0; i < length; i++, k++)
{
int glyphWidth = 0;
int next = 1;
@@ -979,7 +979,7 @@ void DrawTextRecEx(Font font, const char *text, Rectangle rec, float fontSize, f
//draw selected
bool isGlyphSelected = false;
- if ((selectStart >= 0) && (i >= selectStart) && (i < (selectStart + selectLength)))
+ if ((selectStart >= 0) && (k >= selectStart) && (k < (selectStart + selectLength)))
{
Rectangle strec = {rec.x + textOffsetX-1, rec.y + textOffsetY, glyphWidth, (font.baseSize + font.baseSize/4)*scaleFactor };
DrawRectangleRec(strec, selectBack);