Don't presume all cached glyphs are outline glyphs.

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

(cherry picked from commit 949458bbe1)
This commit is contained in:
Jeff Young 2023-08-26 16:12:12 +01:00
parent 27657e00fe
commit 75daa1afec
1 changed files with 8 additions and 4 deletions

View File

@ -92,8 +92,10 @@ SCH_FIELD::SCH_FIELD( const SCH_FIELD& aField ) :
for( const std::unique_ptr<KIFONT::GLYPH>& glyph : aField.m_renderCache )
{
KIFONT::OUTLINE_GLYPH* outline_glyph = static_cast<KIFONT::OUTLINE_GLYPH*>( glyph.get() );
m_renderCache.emplace_back( std::make_unique<KIFONT::OUTLINE_GLYPH>( *outline_glyph ) );
if( KIFONT::OUTLINE_GLYPH* outline = dynamic_cast<KIFONT::OUTLINE_GLYPH*>( glyph.get() ) )
m_renderCache.emplace_back( std::make_unique<KIFONT::OUTLINE_GLYPH>( *outline ) );
else if( KIFONT::STROKE_GLYPH* stroke = dynamic_cast<KIFONT::STROKE_GLYPH*>( glyph.get() ) )
m_renderCache.emplace_back( std::make_unique<KIFONT::STROKE_GLYPH>( *stroke ) );
}
m_renderCacheValid = aField.m_renderCacheValid;
@ -116,8 +118,10 @@ SCH_FIELD& SCH_FIELD::operator=( const SCH_FIELD& aField )
for( const std::unique_ptr<KIFONT::GLYPH>& glyph : aField.m_renderCache )
{
KIFONT::OUTLINE_GLYPH* outline_glyph = static_cast<KIFONT::OUTLINE_GLYPH*>( glyph.get() );
m_renderCache.emplace_back( std::make_unique<KIFONT::OUTLINE_GLYPH>( *outline_glyph ) );
if( KIFONT::OUTLINE_GLYPH* outline = dynamic_cast<KIFONT::OUTLINE_GLYPH*>( glyph.get() ) )
m_renderCache.emplace_back( std::make_unique<KIFONT::OUTLINE_GLYPH>( *outline ) );
else if( KIFONT::STROKE_GLYPH* stroke = dynamic_cast<KIFONT::STROKE_GLYPH*>( glyph.get() ) )
m_renderCache.emplace_back( std::make_unique<KIFONT::STROKE_GLYPH>( *stroke ) );
}
m_renderCacheValid = aField.m_renderCacheValid;