You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-12 13:20:55 +00:00
Improve fill aligned text hit testing.
This commit is contained in:
@@ -1038,11 +1038,17 @@ int TextServer::shaped_text_hit_test_position(RID p_shaped, float p_coords) cons
|
|||||||
|
|
||||||
float off = 0.0f;
|
float off = 0.0f;
|
||||||
for (int i = 0; i < v_size; i++) {
|
for (int i = 0; i < v_size; i++) {
|
||||||
for (int k = 0; k < glyphs[i].repeat; k++) {
|
|
||||||
if (glyphs[i].count > 0) {
|
if (glyphs[i].count > 0) {
|
||||||
float advance = 0.f;
|
float advance = 0.f;
|
||||||
for (int j = 0; j < glyphs[i].count; j++) {
|
for (int j = 0; j < glyphs[i].count; j++) {
|
||||||
advance += glyphs[i + j].advance;
|
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.
|
// Place caret to the left of clicked grapheme.
|
||||||
if (p_coords >= off && p_coords < off + advance / 2) {
|
if (p_coords >= off && p_coords < off + advance / 2) {
|
||||||
@@ -1061,8 +1067,7 @@ int TextServer::shaped_text_hit_test_position(RID p_shaped, float p_coords) cons
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
off += glyphs[i].advance;
|
off += glyphs[i].advance * glyphs[i].repeat;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user