Account for changes to mimic 6.0 text positioning in bounding boxes.

This is only a partial fix as knockout text is still busted....

(cherry picked from commit dacf0b2b96)
This commit is contained in:
Jeff Young 2023-05-27 23:41:43 +01:00
parent f3c5c458c6
commit ae0534cbb4
1 changed files with 13 additions and 4 deletions

View File

@ -564,11 +564,18 @@ BOX2I EDA_TEXT::GetTextBox( int aLine, bool aInvertY ) const
wxSize textsize = wxSize( extents.x, extents.y ); wxSize textsize = wxSize( extents.x, extents.y );
VECTOR2I pos = drawPos; 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() ) if( IsMultilineAllowed() && aLine > 0 && aLine < (int) strings.GetCount() )
pos.y -= KiROUND( aLine * font->GetInterline( fontSize.y ) ); pos.y -= KiROUND( aLine * font->GetInterline( fontSize.y ) );
if( text.Contains( wxT( "~{" ) ) ) if( text.Contains( wxT( "~{" ) ) )
overbarOffset = extents.y / 14; overbarOffset = extents.y / 6;
if( aInvertY ) if( aInvertY )
pos.y = -pos.y; pos.y = -pos.y;
@ -576,7 +583,7 @@ BOX2I EDA_TEXT::GetTextBox( int aLine, bool aInvertY ) const
bbox.SetOrigin( pos ); bbox.SetOrigin( pos );
// for multiline texts and aLine < 0, merge all rectangles (aLine == -1 signals all lines) // 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++ ) for( unsigned ii = 1; ii < strings.GetCount(); ii++ )
{ {
@ -590,6 +597,8 @@ BOX2I EDA_TEXT::GetTextBox( int aLine, bool aInvertY ) const
textsize.y += KiROUND( ( strings.GetCount() - 1 ) * font->GetInterline( fontSize.y ) ); textsize.y += KiROUND( ( strings.GetCount() - 1 ) * font->GetInterline( fontSize.y ) );
} }
textsize.y += overbarOffset;
bbox.SetSize( textsize ); bbox.SetSize( textsize );
/* /*
@ -621,11 +630,11 @@ BOX2I EDA_TEXT::GetTextBox( int aLine, bool aInvertY ) const
break; break;
case GR_TEXT_V_ALIGN_CENTER: case GR_TEXT_V_ALIGN_CENTER:
bbox.SetY( bbox.GetY() - ( bbox.GetHeight() + overbarOffset ) / 2 ); bbox.SetY( bbox.GetY() - bbox.GetHeight() / 2 );
break; break;
case GR_TEXT_V_ALIGN_BOTTOM: case GR_TEXT_V_ALIGN_BOTTOM:
bbox.SetY( bbox.GetY() - ( bbox.GetHeight() + overbarOffset ) ); bbox.SetY( bbox.GetY() - bbox.GetHeight() );
break; break;
} }