From e7f379c31d0f76d214597a5bce84f980caa5b67f Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Wed, 9 Mar 2022 11:22:05 +0100 Subject: [PATCH] Pcbnew, Knockout texts: fix issues seen with rotated texts. Fixes #11085 https://gitlab.com/kicad/code/kicad/issues/11085 --- common/eda_text.cpp | 11 +++++------ include/eda_text.h | 9 ++++++++- pcbnew/plot_brditems_plotter.cpp | 1 - 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/common/eda_text.cpp b/common/eda_text.cpp index a3c9d86d49..061ec0acf6 100644 --- a/common/eda_text.cpp +++ b/common/eda_text.cpp @@ -847,14 +847,15 @@ void EDA_TEXT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControl } -std::shared_ptr EDA_TEXT::GetEffectiveTextShape( bool aTriangulate ) const +std::shared_ptr EDA_TEXT::GetEffectiveTextShape( bool aTriangulate, + bool aUseTextRotation ) const { std::shared_ptr shape = std::make_shared(); 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 ); } diff --git a/include/eda_text.h b/include/eda_text.h index 0123c83c3f..e241ab4729 100644 --- a/include/eda_text.h +++ b/include/eda_text.h @@ -235,7 +235,14 @@ public: void TransformBoundingBoxWithClearanceToPolygon( SHAPE_POLY_SET* aCornerBuffer, int aClearanceValue ) const; - std::shared_ptr 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 GetEffectiveTextShape( bool aTriangulate = true, + bool aUseTextRotation = true ) const; /** * Test if \a aPoint is within the bounds of this object. diff --git a/pcbnew/plot_brditems_plotter.cpp b/pcbnew/plot_brditems_plotter.cpp index f6ba98f513..0c586c7f71 100644 --- a/pcbnew/plot_brditems_plotter.cpp +++ b/pcbnew/plot_brditems_plotter.cpp @@ -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 );