File format changes for fonts.

This commit is contained in:
Ola Rinta-Koski 2022-01-03 01:17:42 +00:00 committed by Jeff Young
parent 9b406c1da4
commit 72b69e8d7f
7 changed files with 66 additions and 9 deletions

View File

@ -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<EDA_TEXT, wxString>( _HKI( "Text" ),
&EDA_TEXT::SetText, &EDA_TEXT::GetText ) );
&EDA_TEXT::SetText,
&EDA_TEXT::GetText ) );
propMgr.AddProperty( new PROPERTY<EDA_TEXT, int>( _HKI( "Thickness" ),
&EDA_TEXT::SetTextThickness,
&EDA_TEXT::GetTextThickness,

View File

@ -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

View File

@ -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

View File

@ -37,6 +37,7 @@
#include <lib_pin.h>
#include <lib_text.h>
#include <math/util.h> // KiROUND, Clamp
#include <font/font.h>
#include <string_utils.h>
#include <sch_bitmap.h>
#include <sch_bus_entry.h>
@ -540,6 +541,7 @@ void SCH_SEXPR_PARSER::parseEDA_TEXT( EDA_TEXT* aText, bool aConvertOverbarSynta
aText->SetText( ConvertToNewOverbarNotation( aText->GetText() ) );
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:

View File

@ -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

View File

@ -42,7 +42,7 @@
#include <pcb_target.h>
#include <footprint.h>
#include <geometry/shape_line_chain.h>
#include <font/font.h>
#include <ignore.h>
#include <netclass.h>
#include <pad.h>
@ -414,6 +414,7 @@ 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;
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:

View File

@ -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