diff --git a/common/eda_text.cpp b/common/eda_text.cpp index 3dfe0120b6..12d600b6f0 100644 --- a/common/eda_text.cpp +++ b/common/eda_text.cpp @@ -513,11 +513,20 @@ void EDA_TEXT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControl aFormatter->Print( 0, " (font" ); + if( GetFont() && !GetFont()->Name().IsEmpty() ) + aFormatter->Print( 0, " (face \"%s\")", GetFont()->NameAsToken() ); + // Text size aFormatter->Print( 0, " (size %s %s)", FormatInternalUnits( GetTextHeight() ).c_str(), FormatInternalUnits( GetTextWidth() ).c_str() ); + if( GetLineSpacing() != 1.0 ) + { + aFormatter->Print( 0, " (line_spacing %s)", + Double2Str( GetLineSpacing() ).c_str() ); + } + if( GetTextThickness() ) { aFormatter->Print( 0, " (thickness %s)", @@ -719,7 +728,8 @@ static struct EDA_TEXT_DESC PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance(); REGISTER_TYPE( EDA_TEXT ); propMgr.AddProperty( new PROPERTY( _HKI( "Text" ), - &EDA_TEXT::SetText, &EDA_TEXT::GetText ) ); + &EDA_TEXT::SetText, + &EDA_TEXT::GetText ) ); propMgr.AddProperty( new PROPERTY( _HKI( "Thickness" ), &EDA_TEXT::SetTextThickness, &EDA_TEXT::GetTextThickness, diff --git a/common/pcb.keywords b/common/pcb.keywords index c410ee1ed1..849d081728 100644 --- a/common/pcb.keywords +++ b/common/pcb.keywords @@ -101,6 +101,7 @@ extension_height extension_offset fab_layers_line_width fab_layers_text_dims +face feature1 feature2 fill @@ -162,6 +163,7 @@ leader leader_length left linear +line_spacing links locked loss_tangent diff --git a/eeschema/sch_file_versions.h b/eeschema/sch_file_versions.h index 66f7d45430..effce115d1 100644 --- a/eeschema/sch_file_versions.h +++ b/eeschema/sch_file_versions.h @@ -41,7 +41,8 @@ //#define SEXPR_SYMBOL_LIB_FILE_VERSION 20201005 // Separate ki_fp_filters by spaces. //#define SEXPR_SYMBOL_LIB_FILE_VERSION 20210619 // Change pin overbar syntax from `~...~` to `~{...}`. //#define SEXPR_SYMBOL_LIB_FILE_VERSION 20211014 // Arc formatting. -#define SEXPR_SYMBOL_LIB_FILE_VERSION 20220101 // Class flags. +//#define SEXPR_SYMBOL_LIB_FILE_VERSION 20220101 // Class flags. +#define SEXPR_SYMBOL_LIB_FILE_VERSION 20220102 // Fonts. /** @@ -70,4 +71,5 @@ //#define SEXPR_SCHEMATIC_FILE_VERSION 20211123 // R/W uuids for junctions. //#define SEXPR_SCHEMATIC_FILE_VERSION 20220101 // Circles, arcs, rects, polys & beziers //#define SEXPR_SCHEMATIC_FILE_VERSION 20220102 // Dash-dot-dot -#define SEXPR_SCHEMATIC_FILE_VERSION 20220103 // Label fields +//#define SEXPR_SCHEMATIC_FILE_VERSION 20220103 // Label fields +#define SEXPR_SCHEMATIC_FILE_VERSION 20220104 // Fonts diff --git a/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp b/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp index e64ab6241e..6d74d80df6 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp +++ b/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp @@ -37,6 +37,7 @@ #include #include #include // KiROUND, Clamp +#include #include #include #include @@ -539,7 +540,8 @@ void SCH_SEXPR_PARSER::parseEDA_TEXT( EDA_TEXT* aText, bool aConvertOverbarSynta if( aConvertOverbarSyntax && m_requiredVersion < 20210606 ) aText->SetText( ConvertToNewOverbarNotation( aText->GetText() ) ); - T token; + T token; + wxString faceName; for( token = NextTok(); token != T_RIGHT; token = NextTok() ) { @@ -556,6 +558,12 @@ void SCH_SEXPR_PARSER::parseEDA_TEXT( EDA_TEXT* aText, bool aConvertOverbarSynta switch( token ) { + case T_face: + NeedSYMBOL(); + faceName = FromUTF8(); + NeedRIGHT(); + break; + case T_size: { wxSize sz; @@ -579,11 +587,23 @@ void SCH_SEXPR_PARSER::parseEDA_TEXT( EDA_TEXT* aText, bool aConvertOverbarSynta aText->SetItalic( true ); break; + case T_line_spacing: + aText->SetLineSpacing( parseDouble( "line spacing" ) ); + NeedRIGHT(); + break; + default: - Expecting( "size, bold, or italic" ); + Expecting( "face, size, thickness, line_spacing, bold, or italic" ); } } + if( !faceName.IsEmpty() ) + { + // FONT TODO: notify user about missing font + aText->SetFont( KIFONT::FONT::GetFont( faceName, aText->IsBold(), + aText->IsItalic() ) ); + } + break; case T_justify: diff --git a/eeschema/schematic.keywords b/eeschema/schematic.keywords index e4e43105d1..e294f80ea7 100644 --- a/eeschema/schematic.keywords +++ b/eeschema/schematic.keywords @@ -31,6 +31,7 @@ edge_clock_high effects end extends +face fields_autoplaced fill font @@ -61,6 +62,7 @@ lib_id lib_name lib_symbols line +line_spacing members mid mirror diff --git a/pcbnew/plugins/kicad/pcb_parser.cpp b/pcbnew/plugins/kicad/pcb_parser.cpp index 3f52a1b423..3db7659bd9 100644 --- a/pcbnew/plugins/kicad/pcb_parser.cpp +++ b/pcbnew/plugins/kicad/pcb_parser.cpp @@ -42,7 +42,7 @@ #include #include #include - +#include #include #include #include @@ -413,7 +413,8 @@ void PCB_PARSER::parseEDA_TEXT( EDA_TEXT* aText ) // Prior to v5.0 text size was omitted from file format if equal to 60mils // Now, it is always explicitly written to file - bool foundTextSize = false; + bool foundTextSize = false; + wxString faceName; for( token = NextTok(); token != T_RIGHT; token = NextTok() ) { @@ -430,6 +431,12 @@ void PCB_PARSER::parseEDA_TEXT( EDA_TEXT* aText ) switch( token ) { + case T_face: + NeedSYMBOL(); + faceName = FromUTF8(); + NeedRIGHT(); + break; + case T_size: { wxSize sz; @@ -442,6 +449,11 @@ void PCB_PARSER::parseEDA_TEXT( EDA_TEXT* aText ) break; } + case T_line_spacing: + aText->SetLineSpacing( parseDouble( "line spacing" ) ); + NeedRIGHT(); + break; + case T_thickness: aText->SetTextThickness( parseBoardUnits( "text thickness" ) ); NeedRIGHT(); @@ -456,9 +468,17 @@ void PCB_PARSER::parseEDA_TEXT( EDA_TEXT* aText ) break; default: - Expecting( "size, bold, or italic" ); + Expecting( "face, size, line_spacing, thickness, bold, or italic" ); } } + + if( !faceName.IsEmpty() ) + { + // FONT TODO: notify user about missing font + aText->SetFont( KIFONT::FONT::GetFont( faceName, aText->IsBold(), + aText->IsItalic() ) ); + } + break; case T_justify: diff --git a/pcbnew/plugins/kicad/pcb_plugin.h b/pcbnew/plugins/kicad/pcb_plugin.h index b33cfa37fd..3f1cfecddc 100644 --- a/pcbnew/plugins/kicad/pcb_plugin.h +++ b/pcbnew/plugins/kicad/pcb_plugin.h @@ -108,7 +108,8 @@ class PCB_TEXT; //#define SEXPR_BOARD_FILE_VERSION 20211228 // Add allow_soldermask_bridges footprint attribute //#define SEXPR_BOARD_FILE_VERSION 20211229 // Stroke formatting //#define SEXPR_BOARD_FILE_VERSION 20211230 // Dimensions in footprints -#define SEXPR_BOARD_FILE_VERSION 20221231 // Private footprint layers +//#define SEXPR_BOARD_FILE_VERSION 20221231 // Private footprint layers +#define SEXPR_BOARD_FILE_VERSION 20221232 // Fonts #define BOARD_FILE_HOST_VERSION 20200825 ///< Earlier files than this include the host tag #define LEGACY_ARC_FORMATTING 20210925 ///< These were the last to use old arc formatting