From 082c6f5bd6c361a446ff8e5a721f444198ef45a1 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Thu, 10 Feb 2022 20:32:02 +0000 Subject: [PATCH] Make sure plotter uses default font when specified. --- common/plotters/common_plot_functions.cpp | 2 +- eeschema/lib_field.cpp | 2 +- eeschema/lib_pin.cpp | 68 +++++++++++---------- eeschema/lib_text.cpp | 3 +- eeschema/sch_field.cpp | 2 +- eeschema/sch_label.cpp | 3 +- include/plotters/plotter.h | 4 +- pcbnew/exporters/gen_drill_report_files.cpp | 6 +- 8 files changed, 48 insertions(+), 42 deletions(-) diff --git a/common/plotters/common_plot_functions.cpp b/common/plotters/common_plot_functions.cpp index 18992e9256..e22d7635e6 100644 --- a/common/plotters/common_plot_functions.cpp +++ b/common/plotters/common_plot_functions.cpp @@ -120,7 +120,7 @@ void PlotDrawingSheet( PLOTTER* plotter, const PROJECT* aProject, const TITLE_BL plotter->Text( text->GetTextPos(), plotColor, text->GetShownText(), text->GetTextAngle(), text->GetTextSize(), text->GetHorizJustify(), text->GetVertJustify(), penWidth, text->IsItalic(), text->IsBold(), - text->IsMultilineAllowed(), text->GetFont() ); + text->IsMultilineAllowed(), text->GetDrawFont() ); } break; diff --git a/eeschema/lib_field.cpp b/eeschema/lib_field.cpp index 3c80702080..d2f9a25d9c 100644 --- a/eeschema/lib_field.cpp +++ b/eeschema/lib_field.cpp @@ -329,7 +329,7 @@ void LIB_FIELD::Plot( PLOTTER* aPlotter, bool aBackground, const VECTOR2I& aOffs int penWidth = GetEffectivePenWidth( aPlotter->RenderSettings() ); aPlotter->Text( textpos, color, GetShownText(), orient, GetTextSize(), hjustify, vjustify, - penWidth, IsItalic(), IsBold() ); + penWidth, IsItalic(), IsBold(), false, GetDrawFont() ); } diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp index 92c3c1c7d3..b6e8ceaf8e 100644 --- a/eeschema/lib_pin.cpp +++ b/eeschema/lib_pin.cpp @@ -707,14 +707,10 @@ void LIB_PIN::PlotPinTexts( PLOTTER* aPlotter, const VECTOR2I& aPinPos, int aPin return; int x, y; - wxSize pinNameSize = wxSize( m_nameTextSize, m_nameTextSize ); - wxSize pinNumSize = wxSize( m_numTextSize, m_numTextSize ); - int namePenWidth = std::max( Clamp_Text_PenSize( GetPenWidth(), m_nameTextSize, false ), aPlotter->RenderSettings()->GetDefaultPenWidth() ); int numPenWidth = std::max( Clamp_Text_PenSize( GetPenWidth(), m_numTextSize, false ), aPlotter->RenderSettings()->GetDefaultPenWidth() ); - int name_offset = Mils2iu( PIN_TEXT_MARGIN ) + namePenWidth; int num_offset = Mils2iu( PIN_TEXT_MARGIN ) + numPenWidth; @@ -733,6 +729,15 @@ void LIB_PIN::PlotPinTexts( PLOTTER* aPlotter, const VECTOR2I& aPinPos, int aPin case PIN_RIGHT: x1 += m_length; break; } + auto plotText = + [&]( int x, int y, const COLOR4D& color, const wxString& text, const EDA_ANGLE& angle, + int size, GR_TEXT_H_ALIGN_T hJustify, GR_TEXT_V_ALIGN_T vJustify, int penWidth ) + + { + aPlotter->Text( VECTOR2I( x, y ), color, text, angle, VECTOR2I( size, size ), + hJustify, vJustify, penWidth, false, false, false, GetDrawFont() ); + }; + /* Draw the text inside, but the pin numbers outside. */ if( aTextInside ) { @@ -752,14 +757,15 @@ void LIB_PIN::PlotPinTexts( PLOTTER* aPlotter, const VECTOR2I& aPinPos, int aPin hjustify = GR_TEXT_H_ALIGN_RIGHT; } - aPlotter->Text( VECTOR2I( x, y1 ), nameColor, name, ANGLE_HORIZONTAL, pinNameSize, - hjustify, GR_TEXT_V_ALIGN_CENTER, namePenWidth, false, false ); + plotText( x, y1, nameColor, name, ANGLE_HORIZONTAL, m_nameTextSize, hjustify, + GR_TEXT_V_ALIGN_CENTER, namePenWidth ); } + if( aDrawPinNum ) { - aPlotter->Text( VECTOR2I( ( x1 + aPinPos.x) / 2, y1 - num_offset ), numColor, - number, ANGLE_HORIZONTAL, pinNumSize, GR_TEXT_H_ALIGN_CENTER, - GR_TEXT_V_ALIGN_BOTTOM, numPenWidth, false, false ); + plotText( ( x1 + aPinPos.x) / 2, y1 - num_offset, numColor, number, + ANGLE_HORIZONTAL, m_numTextSize, GR_TEXT_H_ALIGN_CENTER, + GR_TEXT_V_ALIGN_BOTTOM, numPenWidth ); } } else /* Its a vertical line. */ @@ -769,15 +775,16 @@ void LIB_PIN::PlotPinTexts( PLOTTER* aPlotter, const VECTOR2I& aPinPos, int aPin y = y1 + aTextInside; if( aDrawPinName ) - aPlotter->Text( VECTOR2I( x1, y ), nameColor, name, ANGLE_VERTICAL, - pinNameSize, GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_CENTER, - namePenWidth, false, false ); + { + plotText( x1, y, nameColor, name, ANGLE_VERTICAL, m_nameTextSize, + GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_CENTER, namePenWidth ); + } if( aDrawPinNum ) { - aPlotter->Text( VECTOR2I( x1 - num_offset, ( y1 + aPinPos.y) / 2 ), numColor, - number, ANGLE_VERTICAL, pinNumSize, GR_TEXT_H_ALIGN_CENTER, - GR_TEXT_V_ALIGN_BOTTOM, numPenWidth, false, false ); + plotText( x1 - num_offset, ( y1 + aPinPos.y) / 2, numColor, number, + ANGLE_VERTICAL, m_nameTextSize, GR_TEXT_H_ALIGN_CENTER, + GR_TEXT_V_ALIGN_BOTTOM, numPenWidth ); } } else /* PIN_UP */ @@ -786,16 +793,15 @@ void LIB_PIN::PlotPinTexts( PLOTTER* aPlotter, const VECTOR2I& aPinPos, int aPin if( aDrawPinName ) { - aPlotter->Text( VECTOR2I( x1, y ), nameColor, name, ANGLE_VERTICAL, - pinNameSize, GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER, - namePenWidth, false, false ); + plotText( x1, y, nameColor, name, ANGLE_VERTICAL, m_nameTextSize, + GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER, namePenWidth ); } if( aDrawPinNum ) { - aPlotter->Text( VECTOR2I( x1 - num_offset, ( y1 + aPinPos.y) / 2 ), numColor, - number, ANGLE_VERTICAL, pinNumSize, GR_TEXT_H_ALIGN_CENTER, - GR_TEXT_V_ALIGN_BOTTOM, numPenWidth, false, false ); + plotText( x1 - num_offset, ( y1 + aPinPos.y) / 2, numColor, number, + ANGLE_VERTICAL, m_numTextSize, GR_TEXT_H_ALIGN_CENTER, + GR_TEXT_V_ALIGN_BOTTOM, numPenWidth ); } } } @@ -808,17 +814,15 @@ void LIB_PIN::PlotPinTexts( PLOTTER* aPlotter, const VECTOR2I& aPinPos, int aPin if( aDrawPinName ) { x = ( x1 + aPinPos.x) / 2; - aPlotter->Text( VECTOR2I( x, y1 - name_offset ), nameColor, name, ANGLE_HORIZONTAL, - pinNameSize, GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM, - namePenWidth, false, false ); + plotText( x, y1 - name_offset, nameColor, name, ANGLE_HORIZONTAL, m_nameTextSize, + GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM, namePenWidth ); } if( aDrawPinNum ) { x = ( x1 + aPinPos.x ) / 2; - aPlotter->Text( VECTOR2I( x, y1 + num_offset ), numColor, number, ANGLE_HORIZONTAL, - pinNumSize, GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP, - numPenWidth, false, false ); + plotText( x, y1 + num_offset, numColor, number, ANGLE_HORIZONTAL, m_numTextSize, + GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP, numPenWidth ); } } else /* Its a vertical line. */ @@ -826,16 +830,14 @@ void LIB_PIN::PlotPinTexts( PLOTTER* aPlotter, const VECTOR2I& aPinPos, int aPin if( aDrawPinName ) { y = ( y1 + aPinPos.y ) / 2; - aPlotter->Text( VECTOR2I( x1 - name_offset, y ), nameColor, name, ANGLE_VERTICAL, - pinNameSize, GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM, - namePenWidth, false, false ); + plotText( x1 - name_offset, y, nameColor, name, ANGLE_VERTICAL, m_nameTextSize, + GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM, namePenWidth ); } if( aDrawPinNum ) { - aPlotter->Text( VECTOR2I( x1 + num_offset, ( y1 + aPinPos.y ) / 2 ), numColor, - number, ANGLE_VERTICAL, pinNumSize, GR_TEXT_H_ALIGN_CENTER, - GR_TEXT_V_ALIGN_TOP, numPenWidth, false, false ); + plotText( x1 + num_offset, ( y1 + aPinPos.y ) / 2, numColor, number, ANGLE_VERTICAL, + m_numTextSize, GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP, numPenWidth ); } } } diff --git a/eeschema/lib_text.cpp b/eeschema/lib_text.cpp index 8c2d9ebebb..83d92a1aa8 100644 --- a/eeschema/lib_text.cpp +++ b/eeschema/lib_text.cpp @@ -288,7 +288,8 @@ void LIB_TEXT::Plot( PLOTTER* plotter, bool aBackground, const VECTOR2I& offset, int penWidth = std::max( GetEffectiveTextPenWidth(), settings->GetMinPenWidth() ); plotter->Text( pos, color, GetText(), t1 ? ANGLE_HORIZONTAL : ANGLE_VERTICAL, GetTextSize(), - GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_CENTER, penWidth, IsItalic(), IsBold() ); + GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_CENTER, penWidth, IsItalic(), IsBold(), + true, GetDrawFont() ); } diff --git a/eeschema/sch_field.cpp b/eeschema/sch_field.cpp index 1604ac7ddb..d768046e12 100644 --- a/eeschema/sch_field.cpp +++ b/eeschema/sch_field.cpp @@ -956,7 +956,7 @@ void SCH_FIELD::Plot( PLOTTER* aPlotter, bool aBackground ) const VECTOR2I textpos = GetBoundingBox().Centre(); aPlotter->Text( textpos, color, GetShownText(), orient, GetTextSize(), hjustify, vjustify, - penWidth, IsItalic(), IsBold() ); + penWidth, IsItalic(), IsBold(), false, GetDrawFont() ); } diff --git a/eeschema/sch_label.cpp b/eeschema/sch_label.cpp index 338e81d5a1..e5b4fe24bc 100644 --- a/eeschema/sch_label.cpp +++ b/eeschema/sch_label.cpp @@ -826,7 +826,8 @@ void SCH_LABEL_BASE::Plot( PLOTTER* aPlotter, bool aBackground ) const else { aPlotter->Text( textpos, color, GetShownText(), GetTextAngle(), GetTextSize(), - GetHorizJustify(), GetVertJustify(), penWidth, IsItalic(), IsBold() ); + GetHorizJustify(), GetVertJustify(), penWidth, IsItalic(), IsBold(), + false, GetDrawFont() ); if( s_poly.size() ) aPlotter->PlotPoly( s_poly, FILL_T::NO_FILL, penWidth ); diff --git a/include/plotters/plotter.h b/include/plotters/plotter.h index 2a79ea09ce..63b873d5d0 100644 --- a/include/plotters/plotter.h +++ b/include/plotters/plotter.h @@ -421,8 +421,8 @@ public: int aPenWidth, bool aItalic, bool aBold, - bool aMultilineAllowed = false, - KIFONT::FONT* aFont = nullptr, + bool aMultilineAllowed, + KIFONT::FONT* aFont, void* aData = nullptr ); /** diff --git a/pcbnew/exporters/gen_drill_report_files.cpp b/pcbnew/exporters/gen_drill_report_files.cpp index 12d47eaa9b..dbb6a70148 100644 --- a/pcbnew/exporters/gen_drill_report_files.cpp +++ b/pcbnew/exporters/gen_drill_report_files.cpp @@ -257,7 +257,8 @@ bool GENDRILL_WRITER_BASE::genDrillMapFile( const wxString& aFullFileName, PLOT_ wxString Text = wxT( "Drill Map:" ); plotter->Text( VECTOR2I( plotX, plotY ), COLOR4D::UNSPECIFIED, Text, ANGLE_HORIZONTAL, wxSize( KiROUND( charSize * charScale ), KiROUND( charSize * charScale ) ), - GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER, TextWidth, false, false ); + GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER, TextWidth, false, false, + false, nullptr /* stroke font */ ); // For some formats (PS, PDF SVG) we plot the drill size list on more than one column // because the list must be contained inside the printed page @@ -318,7 +319,8 @@ bool GENDRILL_WRITER_BASE::genDrillMapFile( const wxString& aFullFileName, PLOT_ plotter->Text( VECTOR2I( plotX, y ), COLOR4D::UNSPECIFIED, msg, ANGLE_HORIZONTAL, VECTOR2I( KiROUND( charSize * charScale ), KiROUND( charSize * charScale ) ), - GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER, TextWidth, false, false ); + GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER, TextWidth, false, false, + false, nullptr /* stroke font */ ); intervalle = KiROUND( ( ( charSize * charScale ) + TextWidth ) * 1.2 );