Pcbnew, Knockout texts: fix issues seen with rotated texts.

Fixes #11085
https://gitlab.com/kicad/code/kicad/issues/11085
This commit is contained in:
jean-pierre charras 2022-03-09 11:22:05 +01:00
parent 2df80c6473
commit e7f379c31d
3 changed files with 13 additions and 8 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( bool aTriangulate ) const
std::shared_ptr<SHAPE_COMPOUND> EDA_TEXT::GetEffectiveTextShape( bool aTriangulate,
bool aUseTextRotation ) const
{
std::shared_ptr<SHAPE_COMPOUND> shape = std::make_shared<SHAPE_COMPOUND>();
KIGFX::GAL_DISPLAY_OPTIONS empty_opts;
KIFONT::FONT* font = GetDrawFont();
int penWidth = GetEffectiveTextPenWidth();
TEXT_ATTRIBUTES attrs = GetAttributes();
attrs.m_Angle = GetDrawRotation();
attrs.m_Angle = aUseTextRotation ? GetDrawRotation() : ANGLE_0;
if( aTriangulate )
{
@ -947,7 +948,7 @@ void EDA_TEXT::TransformBoundingBoxWithClearanceToPolygon( SHAPE_POLY_SET* aCorn
// TrueType bounding boxes aren't guaranteed to include all descenders, diacriticals, etc.
// Since we use this for zone knockouts and DRC, we need something more accurate.
if( GetDrawFont()->IsOutline() )
rect = GetEffectiveTextShape()->BBox();
rect = GetEffectiveTextShape( false, false )->BBox();
rect.Inflate( aClearanceValue );
@ -964,9 +965,7 @@ void EDA_TEXT::TransformBoundingBoxWithClearanceToPolygon( SHAPE_POLY_SET* aCorn
for( VECTOR2I& corner : corners )
{
// Rotate if we're using GetEffectiveTextShape()
if( GetDrawFont()->IsOutline() )
RotatePoint( corner, GetDrawPos(), GetDrawRotation() );
RotatePoint( corner, GetDrawPos(), GetDrawRotation() );
aCornerBuffer->Append( corner.x, corner.y );
}

View File

@ -235,7 +235,14 @@ public:
void TransformBoundingBoxWithClearanceToPolygon( SHAPE_POLY_SET* aCornerBuffer,
int aClearanceValue ) const;
std::shared_ptr<SHAPE_COMPOUND> GetEffectiveTextShape( bool aTriangulate = true ) const;
/**
* build a list of segments (SHAPE_SEGMENT) to describe a text shape.
* @param aTriangulate: true to build also the triangulation of each shape
* @param aUseTextRotation: true to use the actual text draw rotation.
* false to build a list of shape for a not rotated text ("native" shapes).
*/
std::shared_ptr<SHAPE_COMPOUND> GetEffectiveTextShape( bool aTriangulate = true,
bool aUseTextRotation = true ) const;
/**
* Test if \a aPoint is within the bounds of this object.

View File

@ -828,7 +828,6 @@ void BRDITEMS_PLOTTER::PlotPcbText( const EDA_TEXT* aText, PCB_LAYER_ID aLayer,
int margin = attrs.m_StrokeWidth * 1.5;
aText->TransformBoundingBoxWithClearanceToPolygon( &finalPoly, margin );
finalPoly.Rotate( -aText->GetDrawRotation(), aText->GetTextPos() );
finalPoly.BooleanSubtract( knockouts, SHAPE_POLY_SET::PM_FAST );
finalPoly.Fracture( SHAPE_POLY_SET::PM_FAST );