mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-14 02:03:12 +02:00
Embed fonts used in fields as well as text items.
(Also, don't presume a non-stroke font is an outline font. We may have more types in the future....) Fixes https://gitlab.com/kicad/code/kicad/-/issues/20578 (cherry picked from commit 97a3a09c9089f9a7371ebbb331dea676a2b219ad)
This commit is contained in:
parent
d6241d7279
commit
2c4015c684
@ -550,6 +550,7 @@ const std::vector<wxString>* EMBEDDED_FILES::UpdateFontFiles()
|
||||
return &m_fontFiles;
|
||||
}
|
||||
|
||||
|
||||
// Move constructor
|
||||
EMBEDDED_FILES::EMBEDDED_FILES( EMBEDDED_FILES&& other ) noexcept :
|
||||
m_files( std::move( other.m_files ) ),
|
||||
@ -560,6 +561,7 @@ EMBEDDED_FILES::EMBEDDED_FILES( EMBEDDED_FILES&& other ) noexcept :
|
||||
other.m_embedFonts = false;
|
||||
}
|
||||
|
||||
|
||||
// Move assignment operator
|
||||
EMBEDDED_FILES& EMBEDDED_FILES::operator=(EMBEDDED_FILES&& other) noexcept
|
||||
{
|
||||
@ -572,33 +574,37 @@ EMBEDDED_FILES& EMBEDDED_FILES::operator=(EMBEDDED_FILES&& other) noexcept
|
||||
m_embedFonts = other.m_embedFonts;
|
||||
other.m_embedFonts = false;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
// Copy constructor
|
||||
EMBEDDED_FILES::EMBEDDED_FILES( const EMBEDDED_FILES& other ) : m_embedFonts( other.m_embedFonts )
|
||||
EMBEDDED_FILES::EMBEDDED_FILES( const EMBEDDED_FILES& other ) :
|
||||
m_embedFonts( other.m_embedFonts )
|
||||
{
|
||||
for( const auto& [name, file] : other.m_files )
|
||||
{
|
||||
m_files[name] = new EMBEDDED_FILE( *file );
|
||||
}
|
||||
|
||||
m_fontFiles = other.m_fontFiles;
|
||||
m_fileAddedCallback = other.m_fileAddedCallback;
|
||||
}
|
||||
|
||||
|
||||
// Copy assignment operator
|
||||
EMBEDDED_FILES& EMBEDDED_FILES::operator=( const EMBEDDED_FILES& other )
|
||||
{
|
||||
if( this != &other )
|
||||
{
|
||||
ClearEmbeddedFiles();
|
||||
|
||||
for( const auto& [name, file] : other.m_files )
|
||||
{
|
||||
m_files[name] = new EMBEDDED_FILE( *file );
|
||||
}
|
||||
|
||||
m_fontFiles = other.m_fontFiles;
|
||||
m_fileAddedCallback = other.m_fileAddedCallback;
|
||||
m_embedFonts = other.m_embedFonts;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
@ -2622,6 +2622,8 @@ const EMBEDDED_FILES* BOARD::GetEmbeddedFiles() const
|
||||
|
||||
std::set<KIFONT::OUTLINE_FONT*> BOARD::GetFonts() const
|
||||
{
|
||||
using PERMISSION = KIFONT::OUTLINE_FONT::EMBEDDING_PERMISSION;
|
||||
|
||||
std::set<KIFONT::OUTLINE_FONT*> fonts;
|
||||
|
||||
for( BOARD_ITEM* item : Drawings() )
|
||||
@ -2630,16 +2632,13 @@ std::set<KIFONT::OUTLINE_FONT*> BOARD::GetFonts() const
|
||||
{
|
||||
KIFONT::FONT* font = text->GetFont();
|
||||
|
||||
if( !font || font->IsStroke() )
|
||||
continue;
|
||||
|
||||
using EMBEDDING_PERMISSION = KIFONT::OUTLINE_FONT::EMBEDDING_PERMISSION;
|
||||
auto* outline = static_cast<KIFONT::OUTLINE_FONT*>( font );
|
||||
|
||||
if( outline->GetEmbeddingPermission() == EMBEDDING_PERMISSION::EDITABLE
|
||||
|| outline->GetEmbeddingPermission() == EMBEDDING_PERMISSION::INSTALLABLE )
|
||||
if( font && font->IsOutline() )
|
||||
{
|
||||
fonts.insert( outline );
|
||||
KIFONT::OUTLINE_FONT* outlineFont = static_cast<KIFONT::OUTLINE_FONT*>( font );
|
||||
PERMISSION permission = outlineFont->GetEmbeddingPermission();
|
||||
|
||||
if( permission == PERMISSION::EDITABLE || permission == PERMISSION::INSTALLABLE )
|
||||
fonts.insert( outlineFont );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2650,9 +2649,7 @@ std::set<KIFONT::OUTLINE_FONT*> BOARD::GetFonts() const
|
||||
|
||||
void BOARD::EmbedFonts()
|
||||
{
|
||||
std::set<KIFONT::OUTLINE_FONT*> fonts = GetFonts();
|
||||
|
||||
for( KIFONT::OUTLINE_FONT* font : fonts )
|
||||
for( KIFONT::OUTLINE_FONT* font : GetFonts() )
|
||||
{
|
||||
auto file = GetEmbeddedFiles()->AddFile( font->GetFileName(), false );
|
||||
file->type = EMBEDDED_FILES::EMBEDDED_FILE::FILE_TYPE::FONT;
|
||||
|
@ -3969,8 +3969,7 @@ void FOOTPRINT::TransformPadsToPolySet( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aL
|
||||
}
|
||||
else
|
||||
{
|
||||
pad->TransformShapeToPolygon( aBuffer, padLayer, clearance.x, aMaxError,
|
||||
aErrorLoc );
|
||||
pad->TransformShapeToPolygon( aBuffer, padLayer, clearance.x, aMaxError, aErrorLoc );
|
||||
}
|
||||
};
|
||||
|
||||
@ -3995,10 +3994,9 @@ void FOOTPRINT::TransformPadsToPolySet( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aL
|
||||
}
|
||||
|
||||
|
||||
void FOOTPRINT::TransformFPShapesToPolySet( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer,
|
||||
int aClearance, int aError, ERROR_LOC aErrorLoc,
|
||||
bool aIncludeText, bool aIncludeShapes,
|
||||
bool aIncludePrivateItems ) const
|
||||
void FOOTPRINT::TransformFPShapesToPolySet( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
|
||||
int aError, ERROR_LOC aErrorLoc, bool aIncludeText,
|
||||
bool aIncludeShapes, bool aIncludePrivateItems ) const
|
||||
{
|
||||
for( BOARD_ITEM* item : GraphicalItems() )
|
||||
{
|
||||
@ -4021,10 +4019,7 @@ void FOOTPRINT::TransformFPShapesToPolySet( SHAPE_POLY_SET& aBuffer, PCB_LAYER_I
|
||||
{
|
||||
// border
|
||||
if( textbox->IsBorderEnabled() )
|
||||
{
|
||||
textbox->PCB_SHAPE::TransformShapeToPolygon( aBuffer, aLayer, 0, aError,
|
||||
aErrorLoc );
|
||||
}
|
||||
textbox->PCB_SHAPE::TransformShapeToPolygon( aBuffer, aLayer, 0, aError, aErrorLoc );
|
||||
|
||||
// text
|
||||
textbox->TransformTextToPolySet( aBuffer, 0, aError, aErrorLoc );
|
||||
@ -4053,28 +4048,33 @@ void FOOTPRINT::TransformFPShapesToPolySet( SHAPE_POLY_SET& aBuffer, PCB_LAYER_I
|
||||
|
||||
std::set<KIFONT::OUTLINE_FONT*> FOOTPRINT::GetFonts() const
|
||||
{
|
||||
using OUTLINE_FONT = KIFONT::OUTLINE_FONT;
|
||||
using EMBEDDING_PERMISSION = OUTLINE_FONT::EMBEDDING_PERMISSION;
|
||||
using PERMISSION = KIFONT::OUTLINE_FONT::EMBEDDING_PERMISSION;
|
||||
|
||||
std::set<OUTLINE_FONT*> fonts;
|
||||
std::set<KIFONT::OUTLINE_FONT*> fonts;
|
||||
|
||||
auto processItem =
|
||||
[&]( BOARD_ITEM* item )
|
||||
{
|
||||
if( EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( item ) )
|
||||
{
|
||||
KIFONT::FONT* font = text->GetFont();
|
||||
|
||||
if( font && font->IsOutline() )
|
||||
{
|
||||
KIFONT::OUTLINE_FONT* outlineFont = static_cast<KIFONT::OUTLINE_FONT*>( font );
|
||||
PERMISSION permission = outlineFont->GetEmbeddingPermission();
|
||||
|
||||
if( permission == PERMISSION::EDITABLE || permission == PERMISSION::INSTALLABLE )
|
||||
fonts.insert( outlineFont );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
for( BOARD_ITEM* item : GraphicalItems() )
|
||||
{
|
||||
if( auto* text = dynamic_cast<EDA_TEXT*>( item ) )
|
||||
{
|
||||
if( auto* font = text->GetFont(); font && !font->IsStroke() )
|
||||
{
|
||||
auto* outline = static_cast<OUTLINE_FONT*>( font );
|
||||
auto permission = outline->GetEmbeddingPermission();
|
||||
processItem( item );
|
||||
|
||||
if( permission == EMBEDDING_PERMISSION::EDITABLE
|
||||
|| permission == EMBEDDING_PERMISSION::INSTALLABLE )
|
||||
{
|
||||
fonts.insert( outline );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for( PCB_FIELD* field : GetFields() )
|
||||
processItem( field );
|
||||
|
||||
return fonts;
|
||||
}
|
||||
@ -4082,11 +4082,9 @@ std::set<KIFONT::OUTLINE_FONT*> FOOTPRINT::GetFonts() const
|
||||
|
||||
void FOOTPRINT::EmbedFonts()
|
||||
{
|
||||
std::set<KIFONT::OUTLINE_FONT*> fonts = GetFonts();
|
||||
|
||||
for( auto* font : fonts )
|
||||
for( KIFONT::OUTLINE_FONT* font : GetFonts() )
|
||||
{
|
||||
auto file = GetEmbeddedFiles()->AddFile( font->GetFileName(), false );
|
||||
EMBEDDED_FILES::EMBEDDED_FILE* file = GetEmbeddedFiles()->AddFile( font->GetFileName(), false );
|
||||
file->type = EMBEDDED_FILES::EMBEDDED_FILE::FILE_TYPE::FONT;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user