Commit: 3620c9ebf8d65fd818acdf8164aa16a0072e70a3
Author: Antonio Vazquez
Date:   Sun Aug 9 17:45:58 2020 +0200
Branches: greasepencil-object
https://developer.blender.org/rB3620c9ebf8d65fd818acdf8164aa16a0072e70a3

GPencil: Support unicode paths in Windows for SVG export

Also some small cleaunp.

===================================================================

M       source/blender/io/gpencil/intern/gpencil_io_base.cc
M       source/blender/io/gpencil/intern/gpencil_io_svg.cc

===================================================================

diff --git a/source/blender/io/gpencil/intern/gpencil_io_base.cc 
b/source/blender/io/gpencil/intern/gpencil_io_base.cc
index 56405685dff..76e92476bd9 100644
--- a/source/blender/io/gpencil/intern/gpencil_io_base.cc
+++ b/source/blender/io/gpencil/intern/gpencil_io_base.cc
@@ -33,8 +33,6 @@
 
 #include "BLI_blenlib.h"
 #include "BLI_math.h"
-#include "BLI_path_util.h"
-#include "BLI_string.h"
 #include "BLI_utildefines.h"
 
 #include "DNA_gpencil_types.h"
@@ -42,10 +40,6 @@
 #include "DNA_object_types.h"
 #include "DNA_screen_types.h"
 
-#ifdef WIN32
-#  include "utfconv.h"
-#endif
-
 #include "UI_view2d.h"
 
 #include "ED_view3d.h"
@@ -91,8 +85,6 @@ GpencilExporter::GpencilExporter(const struct 
GpencilExportParams *iparams)
   gpd = (bGPdata *)params_.obact->data;
   const bool is_storyboard = ((params_.flag & GP_EXPORT_STORYBOARD_MODE) != 0);
 
-  Scene *scene = CTX_data_scene(params_.C);
-
   /* Load list of selected objects. */
   create_object_list();
 
@@ -131,8 +123,8 @@ GpencilExporter::GpencilExporter(const struct 
GpencilExportParams *iparams)
       rctf boundbox;
       get_select_boundbox(&boundbox);
 
-      render_x_ = boundbox.xmax - boundbox.xmin;  // winx_;
-      render_y_ = boundbox.ymax - boundbox.ymin;  // winy_;
+      render_x_ = boundbox.xmax - boundbox.xmin;
+      render_y_ = boundbox.ymax - boundbox.ymin;
       offset_[0] = boundbox.xmin;
       offset_[1] = boundbox.ymin;
     }
@@ -199,10 +191,6 @@ void GpencilExporter::set_out_filename(char *filename)
 {
   BLI_strncpy(out_filename_, filename, FILE_MAX);
   BLI_path_abs(out_filename_, BKE_main_blendfile_path(bmain));
-
-  //#ifdef WIN32
-  //  UTF16_ENCODE(svg_filename);
-  //#endif
 }
 
 /* Convert to screen space. */
diff --git a/source/blender/io/gpencil/intern/gpencil_io_svg.cc 
b/source/blender/io/gpencil/intern/gpencil_io_svg.cc
index 8e9561731d4..be630e63c3a 100644
--- a/source/blender/io/gpencil/intern/gpencil_io_svg.cc
+++ b/source/blender/io/gpencil/intern/gpencil_io_svg.cc
@@ -75,6 +75,7 @@ bool GpencilExporterSVG::write(std::string subfix,
                                const bool body,
                                const bool savepage)
 {
+  bool result = true;
   /* Create new document and add header. */
   if (newpage) {
     create_document_header();
@@ -94,10 +95,22 @@ bool GpencilExporterSVG::write(std::string subfix,
       frame_file.replace(found, 8, subfix + ".svg");
     }
 
-    return doc.save_file(frame_file.c_str());
+/* Support unicode character paths on Windows. */
+#ifdef WIN32
+    char filename_cstr[FILE_MAX];
+    BLI_strncpy(filename_cstr, frame_file.c_str(), FILE_MAX);
+
+    UTF16_ENCODE(filename_cstr);
+    std::wstring wstr(filename_cstr_16);
+    result = doc.save_file(wstr.c_str());
+
+    UTF16_UN_ENCODE(filename_cstr);
+#else
+    result = doc.save_file(frame_file.c_str());
+#endif
   }
 
-  return true;
+  return result;
 }
 
 /* Create document header and main svg node. */

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to