Handle font when reading render cache.

(Also fixes a bug where the cache's triangulation wasn't
cached.)

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

(cherry picked from commit e332320108)
This commit is contained in:
Jeff Young 2024-05-21 11:30:53 +01:00
parent 1869da0e7d
commit 561b2d490d
4 changed files with 9 additions and 4 deletions

View File

@ -528,10 +528,13 @@ EDA_TEXT::GetRenderCache( const KIFONT::FONT* aFont, const wxString& forResolved
}
void EDA_TEXT::SetupRenderCache( const wxString& aResolvedText, const EDA_ANGLE& aAngle )
void EDA_TEXT::SetupRenderCache( const wxString& aResolvedText, const KIFONT::FONT* aFont,
const EDA_ANGLE& aAngle, const VECTOR2I& aOffset )
{
m_render_cache_text = aResolvedText;
m_render_cache_font = aFont;
m_render_cache_angle = aAngle;
m_render_cache_offset = aOffset;
m_render_cache.clear();
}
@ -539,6 +542,7 @@ void EDA_TEXT::SetupRenderCache( const wxString& aResolvedText, const EDA_ANGLE&
void EDA_TEXT::AddRenderCacheGlyph( const SHAPE_POLY_SET& aPoly )
{
m_render_cache.emplace_back( std::make_unique<KIFONT::OUTLINE_GLYPH>( aPoly ) );
static_cast<KIFONT::OUTLINE_GLYPH*>( m_render_cache.back().get() )->CacheTriangulation();
}

View File

@ -348,7 +348,8 @@ public:
const VECTOR2I& aOffset = { 0, 0 } ) const;
// Support for reading the cache from disk.
void SetupRenderCache( const wxString& aResolvedText, const EDA_ANGLE& aAngle );
void SetupRenderCache( const wxString& aResolvedText, const KIFONT::FONT* aFont,
const EDA_ANGLE& aAngle, const VECTOR2I& aOffset );
void AddRenderCacheGlyph( const SHAPE_POLY_SET& aPoly );
int Compare( const EDA_TEXT* aOther ) const;

View File

@ -1503,7 +1503,7 @@ void PCB_IO_EASYEDAPRO_PARSER::ParseBoard(
if( font != wxS( "default" ) )
{
text->SetFont( KIFONT::FONT::GetFont( font ) );
//text->SetupRenderCache( text->GetShownText(), EDA_ANGLE( angle, DEGREES_T ) );
//text->SetupRenderCache( text->GetShownText(), text->GetFont(), EDA_ANGLE( angle, DEGREES_T ) );
//text->AddRenderCacheGlyph();
// TODO: import geometry cache

View File

@ -640,7 +640,7 @@ void PCB_IO_KICAD_SEXPR_PARSER::parseRenderCache( EDA_TEXT* text )
wxString cacheText = From_UTF8( CurText() );
EDA_ANGLE cacheAngle( parseDouble( "render cache angle" ), DEGREES_T );
text->SetupRenderCache( cacheText, cacheAngle );
text->SetupRenderCache( cacheText, text->GetFont(), cacheAngle, { 0, 0 } );
for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{