Change GetEffectiveTextShape() to return outline

instead of triangulated polygon
This commit is contained in:
qu1ck 2022-02-25 04:44:59 -08:00 committed by Seth Hillbrand
parent c9746fb34b
commit b06c2585d9
3 changed files with 27 additions and 11 deletions

View File

@ -847,14 +847,15 @@ void EDA_TEXT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControl
} }
std::shared_ptr<SHAPE_COMPOUND> EDA_TEXT::GetEffectiveTextShape( ) const std::shared_ptr<SHAPE_COMPOUND> EDA_TEXT::GetEffectiveTextShape( bool aTriangulate ) const
{ {
std::shared_ptr<SHAPE_COMPOUND> shape = std::make_shared<SHAPE_COMPOUND>(); std::shared_ptr<SHAPE_COMPOUND> shape = std::make_shared<SHAPE_COMPOUND>();
KIGFX::GAL_DISPLAY_OPTIONS empty_opts; KIGFX::GAL_DISPLAY_OPTIONS empty_opts;
KIFONT::FONT* font = GetDrawFont(); KIFONT::FONT* font = GetDrawFont();
int penWidth = GetEffectiveTextPenWidth(); int penWidth = GetEffectiveTextPenWidth();
CALLBACK_GAL callback_gal( empty_opts, CALLBACK_GAL callback_gal(
empty_opts,
// Stroke callback // Stroke callback
[&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2 ) [&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2 )
{ {
@ -871,6 +872,15 @@ std::shared_ptr<SHAPE_COMPOUND> EDA_TEXT::GetEffectiveTextShape( ) const
shape->AddShape( triShape ); shape->AddShape( triShape );
} ); } );
if( !aTriangulate )
{
callback_gal.SetOutlineCallback(
[&]( const SHAPE_LINE_CHAIN& aPoly )
{
shape->AddShape( aPoly.Clone() );
} );
}
TEXT_ATTRIBUTES attrs = GetAttributes(); TEXT_ATTRIBUTES attrs = GetAttributes();
attrs.m_Angle = GetDrawRotation(); attrs.m_Angle = GetDrawRotation();

View File

@ -55,6 +55,12 @@ public:
m_triangulate = false; m_triangulate = false;
} }
void SetOutlineCallback( std::function<void( const SHAPE_LINE_CHAIN& aPoly )> aOutlineCallback )
{
m_outlineCallback = aOutlineCallback;
m_triangulate = false;
}
/** /**
* Draw a polygon representing an outline font glyph. * Draw a polygon representing an outline font glyph.
*/ */

View File

@ -235,7 +235,7 @@ public:
void TransformBoundingBoxWithClearanceToPolygon( SHAPE_POLY_SET* aCornerBuffer, void TransformBoundingBoxWithClearanceToPolygon( SHAPE_POLY_SET* aCornerBuffer,
int aClearanceValue ) const; int aClearanceValue ) const;
std::shared_ptr<SHAPE_COMPOUND> GetEffectiveTextShape() const; std::shared_ptr<SHAPE_COMPOUND> GetEffectiveTextShape( bool aTriangulate = true ) const;
/** /**
* Test if \a aPoint is within the bounds of this object. * Test if \a aPoint is within the bounds of this object.