From bcb11789542b09220d2867e9bb6377a7aaf34232 Mon Sep 17 00:00:00 2001 From: Filip Sykala - NTB T15p Date: Wed, 14 Aug 2024 09:23:44 +0200 Subject: [PATCH 1/4] Fix encoding of font descriptor --- src/slic3r/Utils/WxFontUtils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/slic3r/Utils/WxFontUtils.cpp b/src/slic3r/Utils/WxFontUtils.cpp index d99e6b09f2..0547ce3e8c 100644 --- a/src/slic3r/Utils/WxFontUtils.cpp +++ b/src/slic3r/Utils/WxFontUtils.cpp @@ -186,7 +186,7 @@ std::string WxFontUtils::store_wxFont(const wxFont &font) "IsFixedWidth(" << font.IsFixedWidth() << "), " << "IsUsingSizeInPixels(" << font.IsUsingSizeInPixels() << "), " << "Encoding(" << (int)font.GetEncoding() << "), " ; - return std::string(font_descriptor.c_str()); + return std::string(font_descriptor.ToUTF8().data()); } wxFont WxFontUtils::load_wxFont(const std::string &font_descriptor) From 79dc95d3e8c47c85e0d414e1930abff469783525 Mon Sep 17 00:00:00 2001 From: Filip Sykala - NTB T15p Date: Wed, 14 Aug 2024 12:27:57 +0200 Subject: [PATCH 2/4] Fix UTF8 encoding for SVG "save as" --- src/slic3r/GUI/Gizmos/GLGizmoSVG.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSVG.cpp b/src/slic3r/GUI/Gizmos/GLGizmoSVG.cpp index c96a215943..34b13e6473 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSVG.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSVG.cpp @@ -1595,7 +1595,7 @@ void GLGizmoSVG::draw_filename(){ if (dlg.ShowModal() == wxID_OK ){ last_used_directory = dlg.GetDirectory(); wxString out_path = dlg.GetPath(); - std::string path{out_path.c_str()}; + std::string path{out_path.ToUTF8().data()}; //Slic3r::save(*m_volume_shape.svg_file.image, path); std::ofstream stream(path); From de43802ca884f79a88bda3fb67c8c496baef67ac Mon Sep 17 00:00:00 2001 From: Filip Sykala - NTB T15p Date: Wed, 14 Aug 2024 12:57:22 +0200 Subject: [PATCH 3/4] Fix human readable name of font for non UTF8 fonts --- src/slic3r/Utils/WxFontUtils.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/slic3r/Utils/WxFontUtils.cpp b/src/slic3r/Utils/WxFontUtils.cpp index 0547ce3e8c..76a04a314c 100644 --- a/src/slic3r/Utils/WxFontUtils.cpp +++ b/src/slic3r/Utils/WxFontUtils.cpp @@ -166,12 +166,12 @@ std::string WxFontUtils::get_human_readable_name(const wxFont &font) if (!font.IsOk()) return "Font is NOT ok."; // Face name is optional in wxFont if (!font.GetFaceName().empty()) { - return std::string(font.GetFaceName().c_str()); + return std::string(font.GetFaceName().ToUTF8().data()); } else { return std::string((font.GetFamilyString() + " " + font.GetStyleString() + " " + font.GetWeightString()) - .c_str()); + .ToUTF8().data()); } } @@ -193,7 +193,7 @@ wxFont WxFontUtils::load_wxFont(const std::string &font_descriptor) { BOOST_LOG_TRIVIAL(trace) << "'" << font_descriptor << "'font descriptor string param of load_wxFont()"; wxString font_descriptor_wx(font_descriptor); - BOOST_LOG_TRIVIAL(trace) << "'" << font_descriptor_wx.c_str() << "' wx string descriptor"; + BOOST_LOG_TRIVIAL(trace) << "'" << font_descriptor_wx.ToUTF8().data() << "' wx string descriptor"; wxFont wx_font(font_descriptor_wx); BOOST_LOG_TRIVIAL(trace) << "loaded font is '" << get_human_readable_name(wx_font) << "'."; return wx_font; From 0534afd6aaa14513e1e0a7f417b5af4de64e78da Mon Sep 17 00:00:00 2001 From: Filip Sykala - NTB T15p Date: Wed, 21 Aug 2024 15:55:02 +0200 Subject: [PATCH 4/4] Use not utf8 std::string for open output stream (SPE-2442) --- src/slic3r/GUI/Gizmos/GLGizmoSVG.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSVG.cpp b/src/slic3r/GUI/Gizmos/GLGizmoSVG.cpp index 34b13e6473..8e27d4d1f7 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSVG.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSVG.cpp @@ -1595,20 +1595,21 @@ void GLGizmoSVG::draw_filename(){ if (dlg.ShowModal() == wxID_OK ){ last_used_directory = dlg.GetDirectory(); wxString out_path = dlg.GetPath(); - std::string path{out_path.ToUTF8().data()}; - //Slic3r::save(*m_volume_shape.svg_file.image, path); - - std::ofstream stream(path); + //Slic3r::save(*m_volume_shape.svg_file.image, out_path.ToUTF8().data()); + + // Be carefull out_path_str is not UTF8 on purpose - storing into not ut6 filepath + std::string out_path_str(out_path.c_str()); + std::ofstream stream(out_path_str); if (stream.is_open()){ stream << *svg.file_data; // change source file m_filename_preview.clear(); - m_volume_shape.svg_file->path = path; + m_volume_shape.svg_file->path = out_path.ToUTF8().data(); m_volume_shape.svg_file->path_in_3mf.clear(); // possible change name m_volume->emboss_shape->svg_file = m_volume_shape.svg_file; // copy - write changes into volume } else { - BOOST_LOG_TRIVIAL(error) << "Opening file: \"" << path << "\" Failed"; + BOOST_LOG_TRIVIAL(error) << "Opening file: \"" << out_path_str << "\" Failed"; } }