aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYuqian Yang <crupest@crupest.life>2025-10-05 17:10:42 +0800
committerYuqian Yang <crupest@crupest.life>2025-10-05 17:10:42 +0800
commit7fffbd150b7dc54ced2cf79ed466c2beea6483b2 (patch)
tree46090bb7d8b01e92cd14d227fbeeb84b0210adc9 /src
parent1b20e0cbae04bd1bb9e0054a0335fe82c22476a8 (diff)
downloadcru-7fffbd150b7dc54ced2cf79ed466c2beea6483b2.tar.gz
cru-7fffbd150b7dc54ced2cf79ed466c2beea6483b2.tar.bz2
cru-7fffbd150b7dc54ced2cf79ed466c2beea6483b2.zip
Fix TextSinglePoint and ime demo.HEADmain
Diffstat (limited to 'src')
-rw-r--r--src/platform/graphics/cairo/PangoTextLayout.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/platform/graphics/cairo/PangoTextLayout.cpp b/src/platform/graphics/cairo/PangoTextLayout.cpp
index d69ee273..8dfd59d5 100644
--- a/src/platform/graphics/cairo/PangoTextLayout.cpp
+++ b/src/platform/graphics/cairo/PangoTextLayout.cpp
@@ -162,16 +162,23 @@ std::vector<Rect> PangoTextLayout::TextRangeRect(const TextRange& text_range) {
Rect PangoTextLayout::TextSinglePoint(Index position, bool trailing) {
auto utf8_index = FromUtf16IndexToUtf8Index(position);
- int line_index, x_pos;
+ int line_index, x_pos, y_pos = 0;
pango_layout_index_to_line_x(pango_layout_, utf8_index, trailing, &line_index,
&x_pos);
+ for (int i = 0; i < line_index; i++) {
+ auto line = pango_layout_get_line(pango_layout_, line_index);
+ PangoRectangle rectangle;
+ pango_layout_line_get_extents(line, nullptr, &rectangle);
+ y_pos += rectangle.height;
+ }
+
auto line = pango_layout_get_line(pango_layout_, line_index);
PangoRectangle rectangle;
pango_layout_line_get_extents(line, nullptr, &rectangle);
return ConvertFromPango(
- Rect(rectangle.x + x_pos, rectangle.y, 0, rectangle.height));
+ Rect(rectangle.x + x_pos, y_pos, 0, rectangle.height));
}
TextHitTestResult PangoTextLayout::HitTest(const Point& point) {