From 3004bf1f002799115bdec0fd5f88916fdc5df2ce Mon Sep 17 00:00:00 2001 From: nanako <469449812@qq.com> Date: Mon, 23 Jun 2025 18:16:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=96=87=E6=9C=AC=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E6=A1=86=E6=8D=A2=E7=A9=BA=E8=A1=8C=E6=97=B6cursor?= =?UTF-8?q?=E4=B8=8D=E6=AD=A3=E7=A1=AE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mirage_render/src/font/font_system.cpp | 26 +++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/mirage_render/src/font/font_system.cpp b/src/mirage_render/src/font/font_system.cpp index bd79a32..cc376ff 100644 --- a/src/mirage_render/src/font/font_system.cpp +++ b/src/mirage_render/src/font/font_system.cpp @@ -28,9 +28,7 @@ namespace text_layout_impl { line.max_descent = std::max(line.max_descent, std::abs(font_metrics.descent)); line.max_line_height = std::max(line.max_line_height, font_metrics.line_height * line_spacing); } - void add_pending_glyph(text_layout_t::line_info_t& line, - const font_manager::glyph_info_t& info, - float cursor_x) { + void add_pending_glyph(text_layout_t::line_info_t& line, const font_manager::glyph_info_t& info, float cursor_x) { text_layout_t::pending_glyph_t pending; pending.glyph_index = info.glyph_index; pending.prev_glyph_id_for_kerning = line.prev_glyph_id; @@ -47,23 +45,25 @@ namespace text_layout_impl { return max_width > 0 && next_x > max_width && has_content; } - void handle_newline(bool& at_line_start, - text_layout_t::line_info_t& line, - float& total_height, - const std::function& finish_line) { + void handle_newline(const bool& at_line_start, + const text_layout_t::line_info_t& line, + float& cursor_y, + float& total_height, + const std::function& finish_line) { if (at_line_start) { total_height += line.max_line_height; + cursor_y += line.max_line_height; } else { finish_line(true); } } void finalize_layout(const text_layout_t::line_info_t& line, - bool at_line_start, - bool text_empty, - float& total_height, - float default_line_height, - const std::function& finish_line) { + bool at_line_start, + bool text_empty, + float& total_height, + float default_line_height, + const std::function& finish_line) { if (line.has_content) { finish_line(false); } else if (at_line_start && !text_empty) { @@ -234,7 +234,7 @@ void font_manager::append_layout_text( // 处理每个字符 for (const char32_t c : append_text) { if (c == U'\n') { - text_layout_impl::handle_newline(at_line_start, current_line, total_height, finish_line); + text_layout_impl::handle_newline(at_line_start, current_line, cursor_y, total_height, finish_line); continue; }