summaryrefslogtreecommitdiff
path: root/servers/text_server.cpp
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2020-12-23 01:15:29 +0100
committerGitHub <noreply@github.com>2020-12-23 01:15:29 +0100
commit8ad0ff8ae5578d92352b63d863e5dcd801458368 (patch)
tree9827c3253f985a8409e21efa13c02a0179baddff /servers/text_server.cpp
parent727faf9b48ed41120b3caba0394fb8c703074be2 (diff)
parentcc4d6eb7f6be529f6fabc1242e363a460e39abdc (diff)
Merge pull request #44487 from bruvzg/ctl_fixes_2
[CTL] Fix RTL scrolling and tabs selection.
Diffstat (limited to 'servers/text_server.cpp')
-rw-r--r--servers/text_server.cpp51
1 files changed, 30 insertions, 21 deletions
diff --git a/servers/text_server.cpp b/servers/text_server.cpp
index 30dfa60ba3..fa39185ac0 100644
--- a/servers/text_server.cpp
+++ b/servers/text_server.cpp
@@ -905,7 +905,7 @@ Vector<Vector2> TextServer::shaped_text_get_selection(RID p_shaped, int p_start,
float off = 0.0f;
for (int i = 0; i < v_size; i++) {
for (int k = 0; k < glyphs[i].repeat; k++) {
- if (glyphs[i].count > 0 && glyphs[i].index != 0) {
+ if ((glyphs[i].count > 0) && ((glyphs[i].index != 0) || ((glyphs[i].flags & GRAPHEME_IS_SPACE) == GRAPHEME_IS_SPACE))) {
if (glyphs[i].start < end && glyphs[i].end > start) {
// Grapheme fully in selection range.
if (glyphs[i].start >= start && glyphs[i].end <= end) {
@@ -963,6 +963,10 @@ Vector<Vector2> TextServer::shaped_text_get_selection(RID p_shaped, int p_start,
// Merge intersecting ranges.
int i = 0;
while (i < ranges.size()) {
+ i++;
+ }
+ i = 0;
+ while (i < ranges.size()) {
int j = i + 1;
while (j < ranges.size()) {
if (Math::is_equal_approx(ranges[i].y, ranges[j].x, UNIT_EPSILON)) {
@@ -1034,31 +1038,36 @@ int TextServer::shaped_text_hit_test_position(RID p_shaped, float p_coords) cons
float off = 0.0f;
for (int i = 0; i < v_size; i++) {
- for (int k = 0; k < glyphs[i].repeat; k++) {
- if (glyphs[i].count > 0) {
- float advance = 0.f;
- for (int j = 0; j < glyphs[i].count; j++) {
- advance += glyphs[i + j].advance;
+ if (glyphs[i].count > 0) {
+ float advance = 0.f;
+ for (int j = 0; j < glyphs[i].count; j++) {
+ advance += glyphs[i + j].advance * glyphs[i + j].repeat;
+ }
+ if (((glyphs[i].flags & GRAPHEME_IS_VIRTUAL) == GRAPHEME_IS_VIRTUAL) && (p_coords >= off && p_coords < off + advance)) {
+ if ((glyphs[i].flags & GRAPHEME_IS_RTL) == GRAPHEME_IS_RTL) {
+ return glyphs[i].end;
+ } else {
+ return glyphs[i].start;
}
- // Place caret to the left of clicked grapheme.
- if (p_coords >= off && p_coords < off + advance / 2) {
- if ((glyphs[i].flags & GRAPHEME_IS_RTL) == GRAPHEME_IS_RTL) {
- return glyphs[i].end;
- } else {
- return glyphs[i].start;
- }
+ }
+ // Place caret to the left of clicked grapheme.
+ if (p_coords >= off && p_coords < off + advance / 2) {
+ if ((glyphs[i].flags & GRAPHEME_IS_RTL) == GRAPHEME_IS_RTL) {
+ return glyphs[i].end;
+ } else {
+ return glyphs[i].start;
}
- // Place caret to the right of clicked grapheme.
- if (p_coords >= off + advance / 2 && p_coords < off + advance) {
- if ((glyphs[i].flags & GRAPHEME_IS_RTL) == GRAPHEME_IS_RTL) {
- return glyphs[i].start;
- } else {
- return glyphs[i].end;
- }
+ }
+ // Place caret to the right of clicked grapheme.
+ if (p_coords >= off + advance / 2 && p_coords < off + advance) {
+ if ((glyphs[i].flags & GRAPHEME_IS_RTL) == GRAPHEME_IS_RTL) {
+ return glyphs[i].start;
+ } else {
+ return glyphs[i].end;
}
}
- off += glyphs[i].advance;
}
+ off += glyphs[i].advance * glyphs[i].repeat;
}
return 0;
}