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; }