From 0f609e1e9c2e080e766a0fd68710c291669a3116 Mon Sep 17 00:00:00 2001 From: nanako <469449812@qq.com> Date: Fri, 20 Jun 2025 10:30:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/src/main.cpp | 126 ++++++++++----------- src/mirage_render/src/font/font_system.cpp | 2 + 2 files changed, 65 insertions(+), 63 deletions(-) diff --git a/example/src/main.cpp b/example/src/main.cpp index a56e152..5d45195 100644 --- a/example/src/main.cpp +++ b/example/src/main.cpp @@ -69,36 +69,36 @@ int main(int argc, char* argv[]) { window->set_content( mnew(mv_box) [ - // mslot(mv_box) - // .horizontal_alignment(horizontal_alignment_t::left) - // + mnew(mbutton) - // [ - // mslot(mbutton) - // .margin({10}) - // .visibility(visibility_t::visible)[ - // mnew(mtext_block, - // .text(config_info_str) - // .font_size(15) - // ) - // ] - // ], + mslot(mv_box) + .horizontal_alignment(horizontal_alignment_t::left) + + mnew(mbutton) + [ + mslot(mbutton) + .margin({10}) + .visibility(visibility_t::visible)[ + mnew(mtext_block, + .text(config_info_str) + .font_size(15) + ) + ] + ], - // mslot(mv_box) - // .horizontal_alignment(horizontal_alignment_t::right) - // + mnew(mbutton) - // [ - // mslot(mbutton) - // .margin({10}) - // .visibility(visibility_t::visible) - // [ - // mnew(mtext_block, - // .text(U"Hello, World! 你好,世界!\n换行测试1111,测试测试测试测试,测试测试😀🐵🙏 😃🐵🙏") - // // .text(U"😀🐵🙏😀🐵🙏") - // .font_size(15) - // .warp_text(true) - // ) - // ] - // ], + mslot(mv_box) + .horizontal_alignment(horizontal_alignment_t::right) + + mnew(mbutton) + [ + mslot(mbutton) + .margin({10}) + .visibility(visibility_t::visible) + [ + mnew(mtext_block, + .text(U"Hello, World! 你好,世界!\n换行测试1111,测试测试测试测试,测试测试😀🐵🙏 😃🐵🙏") + // .text(U"😀🐵🙏😀🐵🙏") + .font_size(15) + .warp_text(true) + ) + ] + ], mslot(mv_box) .horizontal_alignment(horizontal_alignment_t::stretch) @@ -106,40 +106,40 @@ int main(int argc, char* argv[]) { ] ); - // const auto& window2 = mwindow::create({800, 600}, L"Hello, World!"); - // window2->set_content( - // mnew(moverlay) - // [ - // mslot(moverlay) - // .h_alignment(horizontal_alignment_t::center) - // .v_alignment(vertical_alignment_t::center) - // + mnew(mbutton) - // [ - // mslot(mbutton) - // .margin({10}) - // [ - // mnew(mtext_block, - // .text(U"测试测试") - // .font_size(24)) - // ] - // ], - // - // mslot(moverlay) - // .h_alignment(horizontal_alignment_t::center) - // .v_alignment(vertical_alignment_t::center) - // + mnew(mbutton) - // [ - // mslot(mbutton) - // .margin({10}) - // [ - // mnew(mtext_block, - // .text(U"测试测试21111") - // .font_size(15)) - // ] - // ] - // ] - // ); - // + const auto& window2 = mwindow::create({800, 600}, L"Hello, World!"); + window2->set_content( + mnew(moverlay) + [ + mslot(moverlay) + .h_alignment(horizontal_alignment_t::center) + .v_alignment(vertical_alignment_t::center) + + mnew(mbutton) + [ + mslot(mbutton) + .margin({10}) + [ + mnew(mtext_block, + .text(U"测试测试") + .font_size(24)) + ] + ], + + mslot(moverlay) + .h_alignment(horizontal_alignment_t::center) + .v_alignment(vertical_alignment_t::center) + + mnew(mbutton) + [ + mslot(mbutton) + .margin({10}) + [ + mnew(mtext_block, + .text(U"测试测试21111") + .font_size(15)) + ] + ] + ] + ); + mirage_app::get().run(); return 0; diff --git a/src/mirage_render/src/font/font_system.cpp b/src/mirage_render/src/font/font_system.cpp index fef272a..d44047c 100644 --- a/src/mirage_render/src/font/font_system.cpp +++ b/src/mirage_render/src/font/font_system.cpp @@ -215,6 +215,8 @@ void font_manager::append_layout_text( const bool is_emoji = emoji_detector::is_emoji(c); uint32_t glyph_index = 0; const auto& using_font = get_font_for_code_point(primary_font, c, &glyph_index); + if (!using_font) + return; if (!font_metrics_cache.contains(using_font)) { // 确保获取度量前字体大小已设置 (已在循环开始前完成)