aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/Text.cpp b/src/Text.cpp
index bf7ed6a..a1da8de 100644
--- a/src/Text.cpp
+++ b/src/Text.cpp
@@ -1085,6 +1085,9 @@ namespace QuickMedia
break;
}
+ if(vertex_ref.codepoint == '\n')
+ continue;
+
float vertex_right_side = get_text_quad_right_side(vertex_ref);
if(vertex_right_side > maxWidth && maxWidth > WORD_WRAP_MIN_SIZE) {
++num_lines;
@@ -1352,6 +1355,7 @@ namespace QuickMedia
const int start_line = get_vertex_line(startIndex);
float closest_char = 999999.9f;
int closest_index = -1;
+
for(int i = getEndOfLine(startIndex) + 1; i < num_vertices && get_vertex_line(i) == start_line + 1; ++i) {
const float left_pos = get_text_quad_left_side(vertices_linear[i]);
const float pos_diff = std::abs(caret_offset_x - left_pos);
@@ -1360,8 +1364,19 @@ namespace QuickMedia
closest_index = i;
}
}
+
+ if(!vertices_linear.empty()) {
+ const float right_pos_last = get_text_quad_right_side(vertices_linear.back());
+ const float pos_diff = std::abs(caret_offset_x - right_pos_last);
+ if(pos_diff < closest_char) {
+ closest_char = pos_diff;
+ closest_index = vertices_linear.size();
+ }
+ }
+
if(closest_index != -1)
return closest_index;
+
return startIndex;
}