@@ -1351,6 +1351,15 @@ std::unique_ptr<Emboss::DataBase> GLGizmoText::create_emboss_data_base(
13511351 assert (style_manager.get_wx_font ().IsOk ());
13521352 assert (style.path .compare (WxFontUtils::store_wxFont (style_manager.get_wx_font ())) == 0 );
13531353
1354+ // Multiline placement uses the Emboss 2D layout, so character spacing must live in FontProp.
1355+ // Single-line text still applies m_text_gap in GenerateTextJob::calc_position_points.
1356+ if (get_count_lines (text) > 1 ) {
1357+ if (std::abs (m_text_gap) > 1e-4f )
1358+ style.prop .char_gap = static_cast <int >(std::lround (m_text_gap));
1359+ else
1360+ style.prop .char_gap .reset ();
1361+ }
1362+
13541363 bool is_outside = (type == ModelVolumeType::MODEL_PART );
13551364
13561365 // Cancel previous Job, when it is in process
@@ -2522,7 +2531,8 @@ bool GLGizmoText::set_height()
25222531
25232532void GLGizmoText::draw_text_input (int caption_width)
25242533{
2525- bool allow_multi_line = false ;
2534+ // Enter creates a new line; Emboss::text2vshapes + GenerateTextJob baked layout consume '\n'.
2535+ bool allow_multi_line = true ;
25262536 bool support_backup_fonts = GUI::wxGetApp ().app_config ->get_bool (" support_backup_fonts" );
25272537 auto create_range_text_prep = [&mng = m_style_manager, &text = m_text, &exist_unknown = m_text_contain_unknown_glyph, support_backup_fonts]() {
25282538 if (text.empty ()) { return std::string (); }
@@ -2983,6 +2993,34 @@ void GLGizmoText::draw_advanced(float caption_size, float slider_width, float sl
29832993 m_need_update_text = true ;
29842994 }
29852995 }
2996+
2997+ // Line gap (font points) — used by Emboss::get_line_height for multiline text.
2998+ std::optional<int > &line_gap = m_style_manager.get_font_prop ().line_gap ;
2999+ float line_gap_value = static_cast <float >(line_gap.value_or (0 ));
3000+ const float min_line_gap = static_cast <float >(limits.line_gap .min );
3001+ const float max_line_gap = static_cast <float >(limits.line_gap .max );
3002+ ImGui::AlignTextToFramePadding ();
3003+ m_imgui->text (_L (" Line gap" ));
3004+ ImGui::SameLine (caption_size + ad_space_size);
3005+ ImGui::PushItemWidth (slider_width);
3006+ if (m_imgui->bbl_slider_float_style (" ##text_line_gap" , &line_gap_value, min_line_gap, max_line_gap, " %.0f" , 1 .0f , true )) {
3007+ if (std::abs (line_gap_value) < 0 .5f )
3008+ line_gap.reset ();
3009+ else
3010+ line_gap = static_cast <int >(std::lround (line_gap_value));
3011+ }
3012+ is_stop_sliding = m_imgui->get_last_slider_status ().deactivated_after_edit ;
3013+ if (is_stop_sliding)
3014+ m_need_update_text = true ;
3015+ ImGui::SameLine (drag_left_width + ad_space_size);
3016+ ImGui::PushItemWidth (1.5 * slider_icon_width);
3017+ if (ImGui::BBLDragFloat (" ##text_line_gap_input" , &line_gap_value, 1 , min_line_gap, max_line_gap, " %.0f" )) {
3018+ if (std::abs (line_gap_value) < 0 .5f )
3019+ line_gap.reset ();
3020+ else
3021+ line_gap = static_cast <int >(std::lround (line_gap_value));
3022+ m_need_update_text = true ;
3023+ }
29863024}
29873025
29883026void GLGizmoText::init_font_name_texture ()
@@ -3409,6 +3447,8 @@ TextInfo GLGizmoText::get_text_info()
34093447 text_info.m_text_gap = m_text_gap;
34103448 text_info.m_surface_type = m_surface_type;
34113449 text_info.text_configuration = m_ui_text_configuration;
3450+ text_info.text_configuration .style .prop .line_gap = m_style_manager.get_font_prop ().line_gap ;
3451+ text_info.text_configuration .style .prop .char_gap = m_style_manager.get_font_prop ().char_gap ;
34123452 text_info.m_font_version = CUR_FONT_VERSION ;
34133453 return text_info;
34143454}
@@ -3446,6 +3486,8 @@ void GLGizmoText::load_from_text_info(const TextInfo &text_info)
34463486 }
34473487 m_custom_boldness = text_info.text_configuration .style .prop .boldness .value_or (0 .f );
34483488 m_custom_skew = text_info.text_configuration .style .prop .skew .value_or (0 .f );
3489+ m_style_manager.get_font_prop ().line_gap = text_info.text_configuration .style .prop .line_gap ;
3490+ m_style_manager.get_font_prop ().char_gap = text_info.text_configuration .style .prop .char_gap ;
34493491 if (is_text_changed) {
34503492 process (true ,std::nullopt ,false );
34513493 }
0 commit comments