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
This commit is contained in:
parent
4cc29184c2
commit
e332320108
|
@ -542,10 +542,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_text = aResolvedText;
|
||||||
|
m_render_cache_font = aFont;
|
||||||
m_render_cache_angle = aAngle;
|
m_render_cache_angle = aAngle;
|
||||||
|
m_render_cache_offset = aOffset;
|
||||||
m_render_cache.clear();
|
m_render_cache.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -553,6 +556,7 @@ void EDA_TEXT::SetupRenderCache( const wxString& aResolvedText, const EDA_ANGLE&
|
||||||
void EDA_TEXT::AddRenderCacheGlyph( const SHAPE_POLY_SET& aPoly )
|
void EDA_TEXT::AddRenderCacheGlyph( const SHAPE_POLY_SET& aPoly )
|
||||||
{
|
{
|
||||||
m_render_cache.emplace_back( std::make_unique<KIFONT::OUTLINE_GLYPH>( aPoly ) );
|
m_render_cache.emplace_back( std::make_unique<KIFONT::OUTLINE_GLYPH>( aPoly ) );
|
||||||
|
static_cast<KIFONT::OUTLINE_GLYPH*>( m_render_cache.back().get() )->CacheTriangulation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -348,7 +348,8 @@ public:
|
||||||
const VECTOR2I& aOffset = { 0, 0 } ) const;
|
const VECTOR2I& aOffset = { 0, 0 } ) const;
|
||||||
|
|
||||||
// Support for reading the cache from disk.
|
// 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 );
|
void AddRenderCacheGlyph( const SHAPE_POLY_SET& aPoly );
|
||||||
|
|
||||||
int Compare( const EDA_TEXT* aOther ) const;
|
int Compare( const EDA_TEXT* aOther ) const;
|
||||||
|
|
|
@ -1591,7 +1591,7 @@ void PCB_IO_EASYEDAPRO_PARSER::ParseBoard(
|
||||||
if( font != wxS( "default" ) )
|
if( font != wxS( "default" ) )
|
||||||
{
|
{
|
||||||
text->SetFont( KIFONT::FONT::GetFont( font ) );
|
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();
|
//text->AddRenderCacheGlyph();
|
||||||
// TODO: import geometry cache
|
// TODO: import geometry cache
|
||||||
|
|
|
@ -650,7 +650,7 @@ void PCB_IO_KICAD_SEXPR_PARSER::parseRenderCache( EDA_TEXT* text )
|
||||||
wxString cacheText = From_UTF8( CurText() );
|
wxString cacheText = From_UTF8( CurText() );
|
||||||
EDA_ANGLE cacheAngle( parseDouble( "render cache angle" ), DEGREES_T );
|
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() )
|
for( token = NextTok(); token != T_RIGHT; token = NextTok() )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue