Browse Source

SVG import: import unclosed, filled shapes as a separate fill and stroke object

This means that validly unclosed paths can be imported correctly.

Fixes: https://gitlab.com/kicad/code/kicad/-/issues/18477
pcb_db
John Beard 10 months ago
parent
commit
10485848b8
  1. 17
      common/import_gfx/svg_import_plugin.cpp

17
common/import_gfx/svg_import_plugin.cpp

@ -189,9 +189,22 @@ bool SVG_IMPORT_PLUGIN::Import()
for( NSVGpath* path = shape->paths; path != nullptr; path = path->next )
{
bool closed = path->closed || filled || rule == GRAPHICS_IMPORTER::PF_EVEN_ODD;
if( filled && !path->closed )
{
// KiCad doesn't support a single object representing a filled shape that is not closed
// so create a filled, closed shape for the fill, and an unfilled, open shape for the outline
IMPORTED_STROKE noStroke( 0, LINE_STYLE::SOLID, COLOR4D::UNSPECIFIED );
DrawPath( path->pts, path->npts, true, noStroke, true, fillColor );
DrawPath( path->pts, path->npts, false, stroke, false, COLOR4D::UNSPECIFIED );
}
else
{
// Either the shape has fill and no stroke, so we implicitly close it (for no difference),
// or it's really closed
const bool closed = path->closed || filled;
DrawPath( path->pts, path->npts, closed, stroke, filled, fillColor );
DrawPath( path->pts, path->npts, closed, stroke, filled, fillColor );
}
}
}

Loading…
Cancel
Save