Fix multiline text selection highlight for outline fonts

When selecting multiline text objects with non-default (outline) fonts
in the schematic editor, only a single line-height box was drawn as
the selection highlight. This happened because boxText() called
GetTextExtents() which used StringBoundaryLimits() treating the entire
multiline string as one line, producing a very wide but single-height
bounding box.

Replace the boxText() call with GetBoundingBox() which correctly
computes the bounding box for multiline text by measuring each line
individually and accounting for interline spacing.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/23198

(cherry picked from commit fc8c1e2b44)
This commit is contained in:
Seth Hillbrand
2026-03-04 20:40:13 +00:00
committed by Jeff Young
parent 0a2ae3b526
commit 846bb2790c
+8 -8
View File
@@ -1672,15 +1672,15 @@ void SCH_PAINTER::draw( const SCH_TEXT* aText, int aLayer, bool aDimmed )
if( drawingShadows && font->IsOutline() )
{
VECTOR2I pos( aText->GetDrawPos() );
pos += text_offset;
if( aText->Type() == SCH_TEXT_T )
pos += aText->GetOffsetToMatchSCH_FIELD( nullptr );
// Trying to draw glyph-shaped shadows on outline text is a fool's errand. Just box it.
boxText( *m_gal, shownText, pos, attrs, aText->GetFontMetrics() );
// Use GetBoundingBox() which correctly handles multiline text dimensions.
BOX2I bbox = aText->GetBoundingBox();
bbox.Inflate( attrs.m_StrokeWidth / 2, attrs.m_StrokeWidth * 2 );
m_gal->SetIsFill( true );
m_gal->SetIsStroke( false );
m_gal->DrawRectangle( bbox.GetOrigin(), bbox.GetEnd() );
}
else if( aText->GetLayer() == LAYER_DEVICE )
{