aboutsummaryrefslogtreecommitdiff
path: root/src/win/graph/direct/text_layout.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/win/graph/direct/text_layout.cpp')
-rw-r--r--src/win/graph/direct/text_layout.cpp8
1 files changed, 7 insertions, 1 deletions
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_);