diff --git a/pcbnew/pcb_text.cpp b/pcbnew/pcb_text.cpp index ae0d3b7abb..929c63f336 100644 --- a/pcbnew/pcb_text.cpp +++ b/pcbnew/pcb_text.cpp @@ -466,6 +466,7 @@ void PCB_TEXT::TransformTextToPolySet( SHAPE_POLY_SET& aBuffer, int aClearance, KIFONT::FONT* font = getDrawFont(); int penWidth = GetEffectiveTextPenWidth(); TEXT_ATTRIBUTES attrs = GetAttributes(); + wxString shownText = GetShownText( true ); attrs.m_Angle = GetDrawRotation(); @@ -489,7 +490,11 @@ void PCB_TEXT::TransformTextToPolySet( SHAPE_POLY_SET& aBuffer, int aClearance, textShape.Append( point.x, point.y ); } ); - font->Draw( &callback_gal, GetShownText( true ), GetTextPos(), attrs, GetFontMetrics() ); + if( auto* cache = GetRenderCache( font, shownText ) ) + callback_gal.DrawGlyphs( *cache ); + else + font->Draw( &callback_gal, shownText, GetTextPos(), attrs, GetFontMetrics() ); + textShape.Simplify( SHAPE_POLY_SET::PM_FAST ); if( IsKnockout() ) diff --git a/pcbnew/plot_brditems_plotter.cpp b/pcbnew/plot_brditems_plotter.cpp index 76d29d6974..fa1304a5fc 100644 --- a/pcbnew/plot_brditems_plotter.cpp +++ b/pcbnew/plot_brditems_plotter.cpp @@ -36,7 +36,9 @@ #include // for VECTOR2I #include #include - +#include +#include +#include #include // for dyn_cast, PCB_DIMENSION_T #include #include // for GBR_NETLIST_METADATA @@ -551,7 +553,6 @@ void BRDITEMS_PLOTTER::PlotFootprintGraphicItems( const FOOTPRINT* aFootprint ) } -#include void BRDITEMS_PLOTTER::PlotText( const EDA_TEXT* aText, PCB_LAYER_ID aLayer, bool aIsKnockout, const KIFONT::METRICS& aFontMetrics ) { @@ -604,24 +605,46 @@ void BRDITEMS_PLOTTER::PlotText( const EDA_TEXT* aText, PCB_LAYER_ID aLayer, boo for( int ii = 0; ii < finalPoly.OutlineCount(); ++ii ) m_plotter->PlotPoly( finalPoly.Outline( ii ), FILL_T::FILLED_SHAPE, 0, &gbr_metadata ); } - else if( aText->IsMultilineAllowed() ) - { - std::vector positions; - wxArrayString strings_list; - wxStringSplit( shownText, strings_list, '\n' ); - positions.reserve( strings_list.Count() ); - - aText->GetLinePositions( positions, strings_list.Count() ); - - for( unsigned ii = 0; ii < strings_list.Count(); ii++ ) - { - wxString& txt = strings_list.Item( ii ); - m_plotter->PlotText( positions[ii], color, txt, attrs, font, aFontMetrics, &gbr_metadata ); - } - } else { - m_plotter->PlotText( pos, color, shownText, attrs, font, aFontMetrics, &gbr_metadata ); + if( font->IsOutline() ) + { + KIGFX::GAL_DISPLAY_OPTIONS empty_opts; + + CALLBACK_GAL callback_gal( empty_opts, + // Stroke callback + [&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2 ) + { + m_plotter->ThickSegment( aPt1, aPt2, attrs.m_StrokeWidth, FILLED, nullptr ); + }, + // Polygon callback + [&]( const SHAPE_LINE_CHAIN& aPoly ) + { + m_plotter->PlotPoly( aPoly, FILL_T::FILLED_SHAPE, 0, &gbr_metadata ); + } ); + + callback_gal.DrawGlyphs( *aText->GetRenderCache( font, shownText ) ); + } + else if( aText->IsMultilineAllowed() ) + { + std::vector positions; + wxArrayString strings_list; + wxStringSplit( shownText, strings_list, '\n' ); + positions.reserve( strings_list.Count() ); + + aText->GetLinePositions( positions, (int) strings_list.Count() ); + + for( unsigned ii = 0; ii < strings_list.Count(); ii++ ) + { + wxString& txt = strings_list.Item( ii ); + m_plotter->PlotText( positions[ii], color, txt, attrs, font, aFontMetrics, + &gbr_metadata ); + } + } + else + { + m_plotter->PlotText( pos, color, shownText, attrs, font, aFontMetrics, &gbr_metadata ); + } } }