From 12e326839eb8e3b893cadfd1d37fa649f3c4d2c3 Mon Sep 17 00:00:00 2001 From: Antonio Vazquez Date: Thu, 11 May 2023 11:10:04 +0200 Subject: [PATCH] Fix 107810: SVG exported line thickness wrong Due a limitation in the precission of the thickness calculation, the result could be wrong. As the code tried to use the real thickness, in some cases this was wrong. Related to old fix for #103061 --- source/blender/io/gpencil/intern/gpencil_io_export_pdf.cc | 8 +++++--- source/blender/io/gpencil/intern/gpencil_io_export_svg.cc | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/source/blender/io/gpencil/intern/gpencil_io_export_pdf.cc b/source/blender/io/gpencil/intern/gpencil_io_export_pdf.cc index 583f6f4ce84..69c1ebb0a76 100644 --- a/source/blender/io/gpencil/intern/gpencil_io_export_pdf.cc +++ b/source/blender/io/gpencil/intern/gpencil_io_export_pdf.cc @@ -238,9 +238,11 @@ void GpencilExporterPDF::export_stroke_to_polyline(bGPDlayer *gpl, if (is_stroke && !do_fill) { HPDF_Page_SetLineJoin(page_, HPDF_ROUND_JOIN); - const float width = MAX2( - MAX2(gps->thickness + gpl->line_change, (radius * 2.0f) + gpl->line_change), 1.0f); - HPDF_Page_SetLineWidth(page_, width); + const float defined_width = (gps->thickness * avg_pressure) + gpl->line_change; + const float estimated_width = (radius * 2.0f) + gpl->line_change; + const float final_width = (avg_pressure == 1.0f) ? MAX2(defined_width, estimated_width) : + estimated_width; + HPDF_Page_SetLineWidth(page_, MAX2(final_width, 1.0f)); } /* Loop all points. */ diff --git a/source/blender/io/gpencil/intern/gpencil_io_export_svg.cc b/source/blender/io/gpencil/intern/gpencil_io_export_svg.cc index 8430f417b6e..61c88a21828 100644 --- a/source/blender/io/gpencil/intern/gpencil_io_export_svg.cc +++ b/source/blender/io/gpencil/intern/gpencil_io_export_svg.cc @@ -308,9 +308,11 @@ void GpencilExporterSVG::export_stroke_to_polyline(bGPDlayer *gpl, color_string_set(gpl, gps, node_gps, do_fill); if (is_stroke && !do_fill) { - const float width = MAX2( - MAX2(gps->thickness + gpl->line_change, (radius * 2.0f) + gpl->line_change), 1.0f); - node_gps.append_attribute("stroke-width").set_value(width); + const float defined_width = (gps->thickness * avg_pressure) + gpl->line_change; + const float estimated_width = (radius * 2.0f) + gpl->line_change; + const float final_width = (avg_pressure == 1.0f) ? MAX2(defined_width, estimated_width) : + estimated_width; + node_gps.append_attribute("stroke-width").set_value(MAX2(final_width, 1.0f)); } std::string txt; -- 2.30.2