From 922d7f6c96f81a33538900f8a8992a5b6f640874 Mon Sep 17 00:00:00 2001 From: crupest Date: Thu, 23 Apr 2020 02:00:05 +0800 Subject: ... --- src/win/graph/direct/text_layout.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/win/graph') 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 DWriteTextLayout::TextRangeRect(const TextRange& text_range) { +std::vector 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(text_range.position), w_text_); -- cgit v1.2.3