mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-15 10:43:15 +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;
|
return &m_fontFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Move constructor
|
// Move constructor
|
||||||
EMBEDDED_FILES::EMBEDDED_FILES( EMBEDDED_FILES&& other ) noexcept :
|
EMBEDDED_FILES::EMBEDDED_FILES( EMBEDDED_FILES&& other ) noexcept :
|
||||||
m_files( std::move( other.m_files ) ),
|
m_files( std::move( other.m_files ) ),
|
||||||
@ -555,6 +556,7 @@ EMBEDDED_FILES::EMBEDDED_FILES( EMBEDDED_FILES&& other ) noexcept :
|
|||||||
other.m_embedFonts = false;
|
other.m_embedFonts = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Move assignment operator
|
// Move assignment operator
|
||||||
EMBEDDED_FILES& EMBEDDED_FILES::operator=(EMBEDDED_FILES&& other) noexcept
|
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;
|
m_embedFonts = other.m_embedFonts;
|
||||||
other.m_embedFonts = false;
|
other.m_embedFonts = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Copy constructor
|
// 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 )
|
for( const auto& [name, file] : other.m_files )
|
||||||
{
|
|
||||||
m_files[name] = new EMBEDDED_FILE( *file );
|
m_files[name] = new EMBEDDED_FILE( *file );
|
||||||
}
|
|
||||||
m_fontFiles = other.m_fontFiles;
|
m_fontFiles = other.m_fontFiles;
|
||||||
m_fileAddedCallback = other.m_fileAddedCallback;
|
m_fileAddedCallback = other.m_fileAddedCallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Copy assignment operator
|
// Copy assignment operator
|
||||||
EMBEDDED_FILES& EMBEDDED_FILES::operator=( const EMBEDDED_FILES& other )
|
EMBEDDED_FILES& EMBEDDED_FILES::operator=( const EMBEDDED_FILES& other )
|
||||||
{
|
{
|
||||||
if( this != &other )
|
if( this != &other )
|
||||||
{
|
{
|
||||||
ClearEmbeddedFiles();
|
ClearEmbeddedFiles();
|
||||||
|
|
||||||
for( const auto& [name, file] : other.m_files )
|
for( const auto& [name, file] : other.m_files )
|
||||||
{
|
|
||||||
m_files[name] = new EMBEDDED_FILE( *file );
|
m_files[name] = new EMBEDDED_FILE( *file );
|
||||||
}
|
|
||||||
m_fontFiles = other.m_fontFiles;
|
m_fontFiles = other.m_fontFiles;
|
||||||
m_fileAddedCallback = other.m_fileAddedCallback;
|
m_fileAddedCallback = other.m_fileAddedCallback;
|
||||||
m_embedFonts = other.m_embedFonts;
|
m_embedFonts = other.m_embedFonts;
|
||||||
}
|
}
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -2647,6 +2647,8 @@ const EMBEDDED_FILES* BOARD::GetEmbeddedFiles() const
|
|||||||
|
|
||||||
std::set<KIFONT::OUTLINE_FONT*> BOARD::GetFonts() const
|
std::set<KIFONT::OUTLINE_FONT*> BOARD::GetFonts() const
|
||||||
{
|
{
|
||||||
|
using PERMISSION = KIFONT::OUTLINE_FONT::EMBEDDING_PERMISSION;
|
||||||
|
|
||||||
std::set<KIFONT::OUTLINE_FONT*> fonts;
|
std::set<KIFONT::OUTLINE_FONT*> fonts;
|
||||||
|
|
||||||
for( BOARD_ITEM* item : Drawings() )
|
for( BOARD_ITEM* item : Drawings() )
|
||||||
@ -2655,16 +2657,13 @@ std::set<KIFONT::OUTLINE_FONT*> BOARD::GetFonts() const
|
|||||||
{
|
{
|
||||||
KIFONT::FONT* font = text->GetFont();
|
KIFONT::FONT* font = text->GetFont();
|
||||||
|
|
||||||
if( !font || font->IsStroke() )
|
if( font && font->IsOutline() )
|
||||||
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 )
|
|
||||||
{
|
{
|
||||||
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()
|
void BOARD::EmbedFonts()
|
||||||
{
|
{
|
||||||
std::set<KIFONT::OUTLINE_FONT*> fonts = GetFonts();
|
for( KIFONT::OUTLINE_FONT* font : GetFonts() )
|
||||||
|
|
||||||
for( KIFONT::OUTLINE_FONT* font : fonts )
|
|
||||||
{
|
{
|
||||||
EMBEDDED_FILES::EMBEDDED_FILE* 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;
|
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,
|
void FOOTPRINT::TransformPadsToPolySet( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
|
||||||
int aClearance, int aMaxError, ERROR_LOC aErrorLoc ) const
|
int aMaxError, ERROR_LOC aErrorLoc ) const
|
||||||
{
|
{
|
||||||
auto processPad =
|
auto processPad =
|
||||||
[&]( const PAD* pad, PCB_LAYER_ID padLayer )
|
[&]( const PAD* pad, PCB_LAYER_ID padLayer )
|
||||||
@ -3912,8 +3912,7 @@ void FOOTPRINT::TransformPadsToPolySet( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aL
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pad->TransformShapeToPolygon( aBuffer, padLayer, clearance.x, aMaxError,
|
pad->TransformShapeToPolygon( aBuffer, padLayer, clearance.x, aMaxError, aErrorLoc );
|
||||||
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,
|
void FOOTPRINT::TransformFPShapesToPolySet( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
|
||||||
int aClearance, int aError, ERROR_LOC aErrorLoc,
|
int aError, ERROR_LOC aErrorLoc, bool aIncludeText,
|
||||||
bool aIncludeText, bool aIncludeShapes,
|
bool aIncludeShapes, bool aIncludePrivateItems ) const
|
||||||
bool aIncludePrivateItems ) const
|
|
||||||
{
|
{
|
||||||
for( BOARD_ITEM* item : GraphicalItems() )
|
for( BOARD_ITEM* item : GraphicalItems() )
|
||||||
{
|
{
|
||||||
@ -3964,10 +3962,7 @@ void FOOTPRINT::TransformFPShapesToPolySet( SHAPE_POLY_SET& aBuffer, PCB_LAYER_I
|
|||||||
{
|
{
|
||||||
// border
|
// border
|
||||||
if( textbox->IsBorderEnabled() )
|
if( textbox->IsBorderEnabled() )
|
||||||
{
|
textbox->PCB_SHAPE::TransformShapeToPolygon( aBuffer, aLayer, 0, aError, aErrorLoc );
|
||||||
textbox->PCB_SHAPE::TransformShapeToPolygon( aBuffer, aLayer, 0, aError,
|
|
||||||
aErrorLoc );
|
|
||||||
}
|
|
||||||
|
|
||||||
// text
|
// text
|
||||||
textbox->TransformTextToPolySet( aBuffer, 0, aError, aErrorLoc );
|
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
|
std::set<KIFONT::OUTLINE_FONT*> FOOTPRINT::GetFonts() const
|
||||||
{
|
{
|
||||||
using OUTLINE_FONT = KIFONT::OUTLINE_FONT;
|
using PERMISSION = KIFONT::OUTLINE_FONT::EMBEDDING_PERMISSION;
|
||||||
using EMBEDDING_PERMISSION = 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() )
|
for( BOARD_ITEM* item : GraphicalItems() )
|
||||||
{
|
processItem( item );
|
||||||
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();
|
|
||||||
|
|
||||||
if( permission == EMBEDDING_PERMISSION::EDITABLE
|
for( PCB_FIELD* field : GetFields() )
|
||||||
|| permission == EMBEDDING_PERMISSION::INSTALLABLE )
|
processItem( field );
|
||||||
{
|
|
||||||
fonts.insert( outline );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return fonts;
|
return fonts;
|
||||||
}
|
}
|
||||||
@ -4025,11 +4025,9 @@ std::set<KIFONT::OUTLINE_FONT*> FOOTPRINT::GetFonts() const
|
|||||||
|
|
||||||
void FOOTPRINT::EmbedFonts()
|
void FOOTPRINT::EmbedFonts()
|
||||||
{
|
{
|
||||||
std::set<KIFONT::OUTLINE_FONT*> fonts = GetFonts();
|
for( KIFONT::OUTLINE_FONT* font : GetFonts() )
|
||||||
|
|
||||||
for( auto* font : fonts )
|
|
||||||
{
|
{
|
||||||
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;
|
file->type = EMBEDDED_FILES::EMBEDDED_FILE::FILE_TYPE::FONT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4062,20 +4060,17 @@ const COMPONENT_CLASS* FOOTPRINT::GetComponentClass() const
|
|||||||
wxString FOOTPRINT::GetComponentClassAsString() const
|
wxString FOOTPRINT::GetComponentClassAsString() const
|
||||||
{
|
{
|
||||||
if( !m_componentClassCacheProxy->GetComponentClass()->IsEmpty() )
|
if( !m_componentClassCacheProxy->GetComponentClass()->IsEmpty() )
|
||||||
{
|
|
||||||
return m_componentClassCacheProxy->GetComponentClass()->GetName();
|
return m_componentClassCacheProxy->GetComponentClass()->GetName();
|
||||||
}
|
|
||||||
|
|
||||||
return wxEmptyString;
|
return wxEmptyString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void FOOTPRINT::ResolveComponentClassNames(
|
void FOOTPRINT::ResolveComponentClassNames( BOARD* aBoard,
|
||||||
BOARD* aBoard, const std::unordered_set<wxString>& aComponentClassNames )
|
const std::unordered_set<wxString>& aComponentClassNames )
|
||||||
{
|
{
|
||||||
const COMPONENT_CLASS* componentClass =
|
const COMPONENT_CLASS* componentClass =
|
||||||
aBoard->GetComponentClassManager().GetEffectiveStaticComponentClass(
|
aBoard->GetComponentClassManager().GetEffectiveStaticComponentClass( aComponentClassNames );
|
||||||
aComponentClassNames );
|
|
||||||
SetStaticComponentClass( componentClass );
|
SetStaticComponentClass( componentClass );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user