From 22dc0b1212c170fc947268fd25a82d39d73123b8 Mon Sep 17 00:00:00 2001 From: Noisyfox Date: Wed, 22 Jan 2025 10:01:54 +0800 Subject: [PATCH] Update Emboss font preview alignment (#8013) * Fix style preview size per resolution (cherry picked from commit b67c4785f0d300b5615126ea1df1d518dd6d00b0) * Align font preview to left. (closer to font name) (cherry picked from commit eb9b8c0c2b112f0f7649e58f4f6d7977380b8442) --------- Co-authored-by: Filip Sykala - NTB T15p --- src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp | 6 +++--- src/slic3r/GUI/Jobs/CreateFontNameImageJob.cpp | 5 +++-- src/slic3r/GUI/Jobs/CreateFontStyleImagesJob.cpp | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp b/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp index 2f101b09e..03077677a 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp @@ -3598,7 +3598,7 @@ GuiCfg create_gui_configuration() float space = line_height_with_spacing - line_height; const ImGuiStyle &style = ImGui::GetStyle(); - cfg.max_style_name_width = ImGui::CalcTextSize("Maximal font name, extended").x; + cfg.max_style_name_width = ImGui::CalcTextSize("Maximal style name..").x; cfg.icon_width = static_cast(std::ceil(line_height)); // make size pair number @@ -3692,11 +3692,11 @@ GuiCfg create_gui_configuration() // "Text is to object" + radio buttons cfg.height_of_volume_type_selector = separator_height + line_height_with_spacing + input_height; - int max_style_image_width = static_cast(std::round(cfg.max_style_name_width/2 - 2 * style.FramePadding.x)); + int max_style_image_width = static_cast(std::round(cfg.max_style_name_width - 2 * style.FramePadding.x)); int max_style_image_height = static_cast(std::round(input_height)); cfg.max_style_image_size = Vec2i32(max_style_image_width, line_height); cfg.face_name_size = Vec2i32(cfg.input_width, line_height_with_spacing); - cfg.face_name_texture_offset_x = cfg.face_name_size.x() + space; + cfg.face_name_texture_offset_x = cfg.face_name_size.x() + style.WindowPadding.x + space; cfg.max_tooltip_width = ImGui::GetFontSize() * 20.0f; diff --git a/src/slic3r/GUI/Jobs/CreateFontNameImageJob.cpp b/src/slic3r/GUI/Jobs/CreateFontNameImageJob.cpp index 417eb0ea4..c452018a7 100644 --- a/src/slic3r/GUI/Jobs/CreateFontNameImageJob.cpp +++ b/src/slic3r/GUI/Jobs/CreateFontNameImageJob.cpp @@ -142,8 +142,9 @@ void CreateFontImageJob::finalize(bool canceled, std::exception_ptr &) glsafe(::glBindTexture(target, m_input.texture_id)); GLsizei w = m_tex_size.x(), h = m_tex_size.y(); - GLint xoffset = m_input.size.x() - m_tex_size.x(), // arrange right - yoffset = m_input.size.y() * m_input.index; + GLint xoffset = 0; // align to left + // GLint xoffset = m_input.size.x() - m_tex_size.x(); // align right + GLint yoffset = m_input.size.y() * m_input.index; glsafe(::glTexSubImage2D(target, m_input.level, xoffset, yoffset, w, h, m_input.format, m_input.type, m_result.data())); diff --git a/src/slic3r/GUI/Jobs/CreateFontStyleImagesJob.cpp b/src/slic3r/GUI/Jobs/CreateFontStyleImagesJob.cpp index 8b25b183d..f988f622c 100644 --- a/src/slic3r/GUI/Jobs/CreateFontStyleImagesJob.cpp +++ b/src/slic3r/GUI/Jobs/CreateFontStyleImagesJob.cpp @@ -42,12 +42,12 @@ void CreateFontStyleImagesJob::process(Ctl &ctl) // create image description StyleManager::StyleImage &image = m_images[index]; BoundingBox &bounding_box = image.bounding_box; - for (ExPolygon &shape : shapes) + for (const ExPolygon &shape : shapes) bounding_box.merge(BoundingBox(shape.contour.points)); for (ExPolygon &shape : shapes) shape.translate(-bounding_box.min); // calculate conversion from FontPoint to screen pixels by size of font - double scale = get_text_shape_scale(item.prop, *item.font.font_file); + double scale = get_text_shape_scale(item.prop, *item.font.font_file) * m_input.ppm; scales[index] = scale; //double scale = font_prop.size_in_mm * SCALING_FACTOR;