From dacf0b2b969e852945afd2c2690bb8a6885f356a Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 27 May 2023 23:41:43 +0100 Subject: [PATCH] Account for changes to mimic 6.0 text positioning in bounding boxes. This is only a partial fix as knockout text is still busted.... --- common/eda_text.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/common/eda_text.cpp b/common/eda_text.cpp index 07ed25a617..089b266de7 100644 --- a/common/eda_text.cpp +++ b/common/eda_text.cpp @@ -566,11 +566,18 @@ BOX2I EDA_TEXT::GetTextBox( int aLine, bool aInvertY ) const VECTOR2I textsize = VECTOR2I( extents.x, extents.y ); VECTOR2I pos = drawPos; + if( font->IsStroke() ) + { + int fudgeFactor = extents.y * 0.17; + textsize.y += fudgeFactor; + pos.y += fudgeFactor / 2; + } + if( IsMultilineAllowed() && aLine > 0 && aLine < (int) strings.GetCount() ) pos.y -= KiROUND( aLine * font->GetInterline( fontSize.y ) ); if( text.Contains( wxT( "~{" ) ) ) - overbarOffset = extents.y / 14; + overbarOffset = extents.y / 6; if( aInvertY ) pos.y = -pos.y; @@ -578,7 +585,7 @@ BOX2I EDA_TEXT::GetTextBox( int aLine, bool aInvertY ) const bbox.SetOrigin( pos ); // for multiline texts and aLine < 0, merge all rectangles (aLine == -1 signals all lines) - if( IsMultilineAllowed() && aLine < 0 && strings.GetCount() ) + if( IsMultilineAllowed() && aLine < 0 && strings.GetCount() > 1 ) { for( unsigned ii = 1; ii < strings.GetCount(); ii++ ) { @@ -592,6 +599,8 @@ BOX2I EDA_TEXT::GetTextBox( int aLine, bool aInvertY ) const textsize.y += KiROUND( ( strings.GetCount() - 1 ) * font->GetInterline( fontSize.y ) ); } + textsize.y += overbarOffset; + bbox.SetSize( textsize ); /* @@ -623,11 +632,11 @@ BOX2I EDA_TEXT::GetTextBox( int aLine, bool aInvertY ) const break; case GR_TEXT_V_ALIGN_CENTER: - bbox.SetY( bbox.GetY() - ( bbox.GetHeight() + overbarOffset ) / 2 ); + bbox.SetY( bbox.GetY() - bbox.GetHeight() / 2 ); break; case GR_TEXT_V_ALIGN_BOTTOM: - bbox.SetY( bbox.GetY() - ( bbox.GetHeight() + overbarOffset ) ); + bbox.SetY( bbox.GetY() - bbox.GetHeight() ); break; }