From e1f32f13a288cc7a3468fc99a81440361736cb67 Mon Sep 17 00:00:00 2001 From: Tomasz Wlostowski Date: Thu, 30 Dec 2021 03:48:44 +0100 Subject: [PATCH] pcbnew: SVG importer support for even-odd fill rule --- pcbnew/import_gfx/svg_import_plugin.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pcbnew/import_gfx/svg_import_plugin.cpp b/pcbnew/import_gfx/svg_import_plugin.cpp index 418ffcaee2..552cb7c73e 100644 --- a/pcbnew/import_gfx/svg_import_plugin.cpp +++ b/pcbnew/import_gfx/svg_import_plugin.cpp @@ -76,6 +76,17 @@ bool SVG_IMPORT_PLUGIN::Import() { double lineWidth = shape->strokeWidth; + GRAPHICS_IMPORTER::POLY_FILL_RULE rule = GRAPHICS_IMPORTER::PF_NONZERO; + + switch( shape->fillRule ) + { + case NSVG_FILLRULE_NONZERO: rule = GRAPHICS_IMPORTER::PF_NONZERO; break; + case NSVG_FILLRULE_EVENODD: rule = GRAPHICS_IMPORTER::PF_EVEN_ODD; break; + default: break; + } + + m_importer->NewShape( rule ); + for( NSVGpath* path = shape->paths; path != nullptr; path = path->next ) DrawPath( path->pts, path->npts, path->closed, shape->fill.type == NSVG_PAINT_COLOR, lineWidth ); @@ -117,7 +128,7 @@ void SVG_IMPORT_PLUGIN::DrawPath( const float* aPoints, int aNumPoints, bool aCl if( aNumPoints > 0 ) DrawCubicBezierPath( aPoints, aNumPoints, collectedPathPoints ); - if( aFilled && aClosedPath ) + if( aFilled ) DrawPolygon( collectedPathPoints, aLineWidth ); else DrawLineSegments( collectedPathPoints, aLineWidth );