mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-13 17:53:11 +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
This commit is contained in:
parent
b8eda55b24
commit
97a3a09c90
@ -545,6 +545,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 ) ),
|
||||
@ -555,6 +556,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
|
||||
{
|
||||
@ -567,33 +569,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;
|
||||
}
|
||||
|
@ -2647,6 +2647,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() )
|
||||
@ -2655,16 +2657,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;
|
||||
KIFONT::OUTLINE_FONT* 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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2675,9 +2674,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() )
|
||||
{
|
||||
EMBEDDED_FILES::EMBEDDED_FILE* file = GetEmbeddedFiles()->AddFile( font->GetFileName(), false );
|
||||
file->type = EMBEDDED_FILES::EMBEDDED_FILE::FILE_TYPE::FONT;
|
||||
|
@ -3867,8 +3867,8 @@ bool FOOTPRINT::cmp_zones::operator()( const ZONE* aFirst, const ZONE* aSecond )
|
||||
}
|
||||
|
||||
|
||||
void FOOTPRINT::TransformPadsToPolySet( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer,
|
||||
int aClearance, int aMaxError, ERROR_LOC aErrorLoc ) const
|
||||
void FOOTPRINT::TransformPadsToPolySet( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
|
||||
int aMaxError, ERROR_LOC aErrorLoc ) const
|
||||
{
|
||||
auto processPad =
|
||||
[&]( const PAD* pad, PCB_LAYER_ID padLayer )
|
||||
@ -3912,8 +3912,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 );
|
||||
}
|
||||
};
|
||||
|
||||
@ -3938,10 +3937,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() )
|
||||
{
|
||||
@ -3964,10 +3962,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 );
|
||||
@ -3996,28 +3991,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;
|
||||
}
|
||||
@ -4025,11 +4025,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;
|
||||
}
|
||||
}
|
||||
@ -4062,20 +4060,17 @@ const COMPONENT_CLASS* FOOTPRINT::GetComponentClass() const
|
||||
wxString FOOTPRINT::GetComponentClassAsString() const
|
||||
{
|
||||
if( !m_componentClassCacheProxy->GetComponentClass()->IsEmpty() )
|
||||
{
|
||||
return m_componentClassCacheProxy->GetComponentClass()->GetName();
|
||||
}
|
||||
|
||||
return wxEmptyString;
|
||||
}
|
||||
|
||||
|
||||
void FOOTPRINT::ResolveComponentClassNames(
|
||||
BOARD* aBoard, const std::unordered_set<wxString>& aComponentClassNames )
|
||||
void FOOTPRINT::ResolveComponentClassNames( BOARD* aBoard,
|
||||
const std::unordered_set<wxString>& aComponentClassNames )
|
||||
{
|
||||
const COMPONENT_CLASS* componentClass =
|
||||
aBoard->GetComponentClassManager().GetEffectiveStaticComponentClass(
|
||||
aComponentClassNames );
|
||||
aBoard->GetComponentClassManager().GetEffectiveStaticComponentClass( aComponentClassNames );
|
||||
SetStaticComponentClass( componentClass );
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user