aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ui/render/text_render_object.cpp2
-rw-r--r--src/win/graph/direct/text_layout.cpp8
2 files changed, 8 insertions, 2 deletions
diff --git a/src/ui/render/text_render_object.cpp b/src/ui/render/text_render_object.cpp
index be02f8fe..e8368480 100644
--- a/src/ui/render/text_render_object.cpp
+++ b/src/ui/render/text_render_object.cpp
@@ -50,7 +50,7 @@ std::vector<Rect> TextRenderObject::TextRangeRect(const TextRange& text_range) {
return text_layout_->TextRangeRect(text_range);
}
-Point TextRenderObject::TextSingleRect(int position, bool trailing) {
+Point TextRenderObject::TextSingleRect(gsl::index position, bool trailing) {
return text_layout_->TextSingleRect(position, trailing);
}
diff --git a/src/win/graph/direct/text_layout.cpp b/src/win/graph/direct/text_layout.cpp
index f582dd0a..4a742694 100644
--- a/src/win/graph/direct/text_layout.cpp
+++ b/src/win/graph/direct/text_layout.cpp
@@ -66,7 +66,13 @@ Rect DWriteTextLayout::GetTextBounds() {
return Rect{metrics.left, metrics.top, metrics.width, metrics.height};
}
-std::vector<Rect> DWriteTextLayout::TextRangeRect(const TextRange& text_range) {
+std::vector<Rect> DWriteTextLayout::TextRangeRect(
+ const TextRange& text_range_arg) {
+ if (text_range_arg.count == 0) {
+ return {};
+ }
+ const auto text_range = text_range_arg.Normalize();
+
// TODO: This can be faster with one iteration.
const int start_index =
IndexUtf8ToUtf16(text_, static_cast<int>(text_range.position), w_text_);