mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-21 22:03:47 +00:00
Plot from render cache if fonts aren't embedded.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/18672
This commit is contained in:
parent
d9d927e80c
commit
3d9784ded3
@ -514,6 +514,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();
|
||||
|
||||
@ -537,7 +538,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();
|
||||
|
||||
if( IsKnockout() )
|
||||
|
@ -36,7 +36,9 @@
|
||||
#include <math/vector2d.h> // for VECTOR2I
|
||||
#include <plotters/plotter_gerber.h>
|
||||
#include <trigo.h>
|
||||
|
||||
#include <font/stroke_font.h>
|
||||
#include <gal/gal_display_options.h>
|
||||
#include <callback_gal.h>
|
||||
#include <core/typeinfo.h> // for dyn_cast, PCB_DIMENSION_T
|
||||
#include <gbr_metadata.h>
|
||||
#include <gbr_netlist_metadata.h> // for GBR_NETLIST_METADATA
|
||||
@ -665,7 +667,6 @@ void BRDITEMS_PLOTTER::PlotFootprintGraphicItems( const FOOTPRINT* aFootprint )
|
||||
}
|
||||
|
||||
|
||||
#include <font/stroke_font.h>
|
||||
void BRDITEMS_PLOTTER::PlotText( const EDA_TEXT* aText, PCB_LAYER_ID aLayer, bool aIsKnockout,
|
||||
const KIFONT::METRICS& aFontMetrics, bool aStrikeout )
|
||||
{
|
||||
@ -738,31 +739,52 @@ 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<VECTOR2I> 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 );
|
||||
}
|
||||
|
||||
if( aStrikeout && strings_list.Count() == 1 )
|
||||
strikeoutText( static_cast<const PCB_TEXT*>( aText ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_plotter->PlotText( pos, color, shownText, attrs, font, aFontMetrics, &gbr_metadata );
|
||||
if( font->IsOutline() && !m_board->GetEmbeddedFiles()->GetAreFontsEmbedded() )
|
||||
{
|
||||
KIGFX::GAL_DISPLAY_OPTIONS empty_opts;
|
||||
|
||||
if( aStrikeout )
|
||||
strikeoutText( static_cast<const PCB_TEXT*>( aText ) );
|
||||
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<VECTOR2I> 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 );
|
||||
}
|
||||
|
||||
if( aStrikeout && strings_list.Count() == 1 )
|
||||
strikeoutText( static_cast<const PCB_TEXT*>( aText ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_plotter->PlotText( pos, color, shownText, attrs, font, aFontMetrics, &gbr_metadata );
|
||||
|
||||
if( aStrikeout )
|
||||
strikeoutText( static_cast<const PCB_TEXT*>( aText ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user