Plot fonts in outline mode, not triangulated

Putting 1,000s of tiny triangles on a gerber file will cause mfg fits.
Instead, we use easy outline plotting for plots and triangulation for
everything else.
This commit is contained in:
Seth Hillbrand 2022-01-13 17:04:14 -08:00
parent 33a4c9b08e
commit e7d0318fb2
3 changed files with 36 additions and 12 deletions

View File

@ -44,9 +44,22 @@ void CALLBACK_GAL::DrawGlyph( const KIFONT::GLYPH& aGlyph, int aNth, int aTotal
}
else if( aGlyph.IsOutline() )
{
const KIFONT::OUTLINE_GLYPH& glyph = static_cast<const KIFONT::OUTLINE_GLYPH&>( aGlyph );
if( m_triangulate )
{
const KIFONT::OUTLINE_GLYPH& glyph = static_cast<const KIFONT::OUTLINE_GLYPH&>( aGlyph );
glyph.Triangulate( m_triangleCallback );
glyph.Triangulate( m_triangleCallback );
}
else
{
KIFONT::OUTLINE_GLYPH glyph = static_cast<const KIFONT::OUTLINE_GLYPH&>( aGlyph );
if( glyph.HasHoles() )
glyph.Fracture( SHAPE_POLY_SET::POLYGON_MODE::PM_FAST );
for( int ii = 0; ii < glyph.OutlineCount(); ++ii )
m_outlineCallback( glyph.Outline( ii ) );
}
}
}

View File

@ -686,16 +686,10 @@ void PLOTTER::Text( const VECTOR2I& aPos,
LineTo( (wxPoint) aPt2 );
PenFinish();
},
// Triangulation callback
[&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2, const VECTOR2I& aPt3 )
// Polygon callback
[&]( const SHAPE_LINE_CHAIN& aPoly )
{
std::vector<VECTOR2I> cornerList;
cornerList.reserve( 3 );
for( const VECTOR2I& pt : { aPt1, aPt2, aPt3, aPt1 } )
cornerList.emplace_back( pt );
PlotPoly( cornerList, FILL_T::FILLED_SHAPE, 0, aData );
PlotPoly( aPoly, FILL_T::FILLED_SHAPE, 0, aData );
} );
TEXT_ATTRIBUTES attributes;

View File

@ -26,7 +26,6 @@
#include <gal/graphics_abstraction_layer.h>
class CALLBACK_GAL: public KIGFX::GAL
{
public:
@ -40,6 +39,20 @@ public:
{
m_strokeCallback = aStrokeCallback;
m_triangleCallback = aTriangleCallback;
m_outlineCallback = [](const SHAPE_LINE_CHAIN&){};
m_triangulate = true;
}
CALLBACK_GAL( KIGFX::GAL_DISPLAY_OPTIONS& aDisplayOptions,
std::function<void( const VECTOR2I& aPt1,
const VECTOR2I& aPt2 )> aStrokeCallback,
std::function<void( const SHAPE_LINE_CHAIN& aPoly )> aOutlineCallback ) :
GAL( aDisplayOptions )
{
m_strokeCallback = aStrokeCallback;
m_triangleCallback = []( const VECTOR2I&, const VECTOR2I&, const VECTOR2I& ){};
m_outlineCallback = aOutlineCallback;
m_triangulate = false;
}
/**
@ -54,6 +67,10 @@ private:
std::function<void( const VECTOR2I& aPt1,
const VECTOR2I& aPt2,
const VECTOR2I& aPt3 )> m_triangleCallback;
std::function<void( const SHAPE_LINE_CHAIN& aPoly )> m_outlineCallback;
bool m_triangulate;
};