From af4d14b66c87f467908d4c8920e6070ee28bc9e1 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 13 May 2025 17:47:33 +0100 Subject: [PATCH] 0 width means 0 width when plotting text. There's no such thing as a default line width for text. Fixes https://gitlab.com/kicad/code/kicad/-/issues/20916 --- common/plotters/PDF_plotter.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/common/plotters/PDF_plotter.cpp b/common/plotters/PDF_plotter.cpp index b99e965dd7..7c95b040df 100644 --- a/common/plotters/PDF_plotter.cpp +++ b/common/plotters/PDF_plotter.cpp @@ -1732,21 +1732,21 @@ void PDF_PLOTTER::Text( const VECTOR2I& aPos, VECTOR2I t_size( std::abs( aSize.x ), std::abs( aSize.y ) ); bool textMirrored = aSize.x < 0; + computeTextParameters( aPos, aText, aOrient, t_size, textMirrored, aH_justify, aV_justify, + aWidth, aItalic, aBold, &wideningFactor, &ctm_a, &ctm_b, &ctm_c, &ctm_d, + &ctm_e, &ctm_f, &heightFactor ); + SetColor( aColor ); SetCurrentLineWidth( aWidth, aData ); - computeTextParameters( aPos, aText, aOrient, t_size, textMirrored, aH_justify, aV_justify, - GetCurrentLineWidth(), aItalic, aBold, &wideningFactor, - &ctm_a, &ctm_b, &ctm_c, &ctm_d, &ctm_e, &ctm_f, &heightFactor ); - wxStringTokenizer str_tok( aText, " ", wxTOKEN_RET_DELIMS ); // If aFont is not specilied (== nullptr), use the default kicad stroke font if( !aFont ) aFont = KIFONT::FONT::GetFont(); - VECTOR2I full_box( aFont->StringBoundaryLimits( aText, t_size, GetCurrentLineWidth(), - aBold, aItalic, aFontMetrics ) ); + VECTOR2I full_box( aFont->StringBoundaryLimits( aText, t_size, aWidth, aBold, aItalic, + aFontMetrics ) ); if( textMirrored ) full_box.x *= -1; @@ -1772,12 +1772,12 @@ void PDF_PLOTTER::Text( const VECTOR2I& aPos, wxString word = str_tok.GetNextToken(); computeTextParameters( pos, word, aOrient, t_size, textMirrored, GR_TEXT_H_ALIGN_LEFT, - GR_TEXT_V_ALIGN_BOTTOM, GetCurrentLineWidth(), aItalic, aBold, &wideningFactor, + GR_TEXT_V_ALIGN_BOTTOM, aWidth, aItalic, aBold, &wideningFactor, &ctm_a, &ctm_b, &ctm_c, &ctm_d, &ctm_e, &ctm_f, &heightFactor ); // Extract the changed width and rotate by the orientation to get the offset for the // next word - VECTOR2I bbox( aFont->StringBoundaryLimits( word, t_size, GetCurrentLineWidth(), + VECTOR2I bbox( aFont->StringBoundaryLimits( word, t_size, aWidth, aBold, aItalic, aFontMetrics ).x, 0 ); if( textMirrored ) @@ -1808,8 +1808,8 @@ void PDF_PLOTTER::Text( const VECTOR2I& aPos, } // Plot the stroked text (if requested) - PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, GetCurrentLineWidth(), - aItalic, aBold, aMultilineAllowed, aFont, aFontMetrics ); + PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, aWidth, aItalic, + aBold, aMultilineAllowed, aFont, aFontMetrics ); }