From 97cb9c3f186b4947dda493f3499ceed31c6b6ec0 Mon Sep 17 00:00:00 2001 From: nanako <469449812@qq.com> Date: Mon, 30 Jun 2025 17:32:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=96=87=E6=9C=ACy=E5=9D=90?= =?UTF-8?q?=E6=A0=87=E4=B8=8D=E6=AD=A3=E7=A1=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mirage_render/src/font/font_layout.cpp | 2 +- .../src/widget/leaf_widget/meditable_text_box.cpp | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/mirage_render/src/font/font_layout.cpp b/src/mirage_render/src/font/font_layout.cpp index a9df90d..ab56b30 100644 --- a/src/mirage_render/src/font/font_layout.cpp +++ b/src/mirage_render/src/font/font_layout.cpp @@ -247,7 +247,7 @@ void text_layout_t::line_t::format(const font_face_ptr& in_primary_font, float i const float size_y_diff = g_metrics.rect.size().y() - static_cast(g.region->rect.size().y()); const float baseline_y = position_y + metrics.ascent + (line_height - metrics.line_height) / 2.0f; - g.position.y() = baseline_y + g_metrics.offset.y() + size_y_diff; + g.position.y() = baseline_y + g_metrics.offset.y() + size_y_diff - metrics.descent; cursor_x += kerning + g_metrics.advance.x(); diff --git a/src/mirage_widget/src/widget/leaf_widget/meditable_text_box.cpp b/src/mirage_widget/src/widget/leaf_widget/meditable_text_box.cpp index 076078e..39f77ee 100644 --- a/src/mirage_widget/src/widget/leaf_widget/meditable_text_box.cpp +++ b/src/mirage_widget/src/widget/leaf_widget/meditable_text_box.cpp @@ -55,9 +55,10 @@ void meditable_text_box::on_paint(mirage_paint_context& in_context) { in_context.geo() ); if (is_focus()) { - const float line_height = layout_.get_last_line().get_line_height(); - const float line_width = layout_.get_last_line().line_width; - const auto& cursor_pos = Eigen::Vector2f(line_width, layout_.get_last_line().position_y) + Eigen::Vector2f(round_, round_); + const auto& last_line = layout_.get_last_line(); + const float line_height = last_line.get_line_height() * line_spacing_; + const float line_width = last_line.line_width; + const auto& cursor_pos = Eigen::Vector2f(line_width, last_line.position_y) + Eigen::Vector2f(round_, round_); // 绘制光标 in_context.drawer().make_rounded_rect( cursor_pos,