Changed default text size to 50mils

- Text size is now always written to file
- Unspecified text sizes are read as 60mils

Fixes lp:1737878

https://bugs.launchpad.net/kicad/+bug/1737878
This commit is contained in:
Oliver Walters 2017-12-21 09:11:19 +11:00 committed by Wayne Stambaugh
parent 1396ab0941
commit 900ddca0b4
3 changed files with 48 additions and 49 deletions

View File

@ -400,9 +400,7 @@ wxString EDA_TEXT::GetTextStyleName()
bool EDA_TEXT::IsDefaultFormatting() const bool EDA_TEXT::IsDefaultFormatting() const
{ {
return ( GetTextWidth() == Mils2iu( DEFAULT_SIZE_TEXT ) return ( IsVisible()
&& GetTextHeight() == Mils2iu( DEFAULT_SIZE_TEXT )
&& IsVisible()
&& !IsMirrored() && !IsMirrored()
&& GetHorizJustify() == GR_TEXT_HJUSTIFY_CENTER && GetHorizJustify() == GR_TEXT_HJUSTIFY_CENTER
&& GetVertJustify() == GR_TEXT_VJUSTIFY_CENTER && GetVertJustify() == GR_TEXT_VJUSTIFY_CENTER
@ -419,61 +417,49 @@ void EDA_TEXT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControl
#ifndef GERBVIEW // Gerbview does not use EDA_TEXT::Format #ifndef GERBVIEW // Gerbview does not use EDA_TEXT::Format
// and does not define FMT_IU, used here // and does not define FMT_IU, used here
// however this function should exist // however this function should exist
if( !IsDefaultFormatting() )
{
aFormatter->Print( aNestLevel+1, "(effects" );
if( ( GetTextWidth() != Mils2iu( DEFAULT_SIZE_TEXT ) ) aFormatter->Print( aNestLevel + 1, "(effects" );
|| ( GetTextHeight() != Mils2iu( DEFAULT_SIZE_TEXT ) )
|| ( GetThickness() != 0 ) || IsBold() || IsItalic() )
{
aFormatter->Print( 0, " (font" );
// Add font support here at some point in the future. // Text size
aFormatter->Print( 0, " (font" );
if( GetTextWidth() != Mils2iu( DEFAULT_SIZE_TEXT ) aFormatter->Print( 0, " (size %s %s)",
|| GetTextHeight() != Mils2iu( DEFAULT_SIZE_TEXT ) ) FMT_IU( GetTextHeight() ).c_str(),
{ FMT_IU( GetTextWidth() ).c_str() );
aFormatter->Print( 0, " (size %s %s)",
FMT_IU( GetTextHeight() ).c_str(),
FMT_IU( GetTextWidth() ).c_str()
);
}
if( GetThickness() ) if( GetThickness() )
aFormatter->Print( 0, " (thickness %s)", FMT_IU( GetThickness() ).c_str() ); aFormatter->Print( 0, " (thickness %s)", FMT_IU( GetThickness() ).c_str() );
if( IsBold() ) if( IsBold() )
aFormatter->Print( 0, " bold" ); aFormatter->Print( 0, " bold" );
if( IsItalic() ) if( IsItalic() )
aFormatter->Print( 0, " italic" ); aFormatter->Print( 0, " italic" );
aFormatter->Print( 0, ")"); aFormatter->Print( 0, ")"); // (font
}
if( IsMirrored() || ( GetHorizJustify() != GR_TEXT_HJUSTIFY_CENTER ) if( IsMirrored() ||
|| ( GetVertJustify() != GR_TEXT_VJUSTIFY_CENTER ) ) GetHorizJustify() != GR_TEXT_HJUSTIFY_CENTER ||
{ GetVertJustify() != GR_TEXT_VJUSTIFY_CENTER )
aFormatter->Print( 0, " (justify"); {
aFormatter->Print( 0, " (justify");
if( GetHorizJustify() != GR_TEXT_HJUSTIFY_CENTER ) if( GetHorizJustify() != GR_TEXT_HJUSTIFY_CENTER )
aFormatter->Print( 0, (GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT) ? " left" : " right" ); aFormatter->Print( 0, (GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT) ? " left" : " right" );
if( GetVertJustify() != GR_TEXT_VJUSTIFY_CENTER ) if( GetVertJustify() != GR_TEXT_VJUSTIFY_CENTER )
aFormatter->Print( 0, (GetVertJustify() == GR_TEXT_VJUSTIFY_TOP) ? " top" : " bottom" ); aFormatter->Print( 0, (GetVertJustify() == GR_TEXT_VJUSTIFY_TOP) ? " top" : " bottom" );
if( IsMirrored() ) if( IsMirrored() )
aFormatter->Print( 0, " mirror" ); aFormatter->Print( 0, " mirror" );
aFormatter->Print( 0, ")" ); // (justify
}
aFormatter->Print( 0, ")" ); if( !(aControlBits & CTL_OMIT_HIDE) && !IsVisible() )
} aFormatter->Print( 0, " hide" );
if( !(aControlBits & CTL_OMIT_HIDE) && !IsVisible() ) aFormatter->Print( 0, ")\n" ); // (justify
aFormatter->Print( 0, " hide" );
aFormatter->Print( 0, ")\n" );
}
#endif #endif
} }

View File

@ -67,11 +67,9 @@ enum EDA_DRAW_MODE_T {
/** This is the "default-of-the-default" hardcoded text size; individual /** This is the "default-of-the-default" hardcoded text size; individual
* application define their own default policy starting with this * application define their own default policy starting with this
* (usually with a user option or project). DO NOT change this value if * (usually with a user option or project).
* you do not fully realize the effect it has on sexp serialization **/
* (text size equal to this is not explicitly wrote, so it would change #define DEFAULT_SIZE_TEXT 50 // default text height (in mils, i.e. 1/1000")
* subsequent reads) */
#define DEFAULT_SIZE_TEXT 60 // default text height (in mils, i.e. 1/1000")
#define DIM_ANCRE_TEXTE 2 // Anchor size for text #define DIM_ANCRE_TEXTE 2 // Anchor size for text

View File

@ -242,6 +242,10 @@ void PCB_PARSER::parseEDA_TEXT( EDA_TEXT* aText )
T token; T token;
// 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;
for( token = NextTok(); token != T_RIGHT; token = NextTok() ) for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{ {
if( token == T_LEFT ) if( token == T_LEFT )
@ -264,6 +268,8 @@ void PCB_PARSER::parseEDA_TEXT( EDA_TEXT* aText )
sz.SetWidth( parseBoardUnits( "text width" ) ); sz.SetWidth( parseBoardUnits( "text width" ) );
aText->SetTextSize( sz ); aText->SetTextSize( sz );
NeedRIGHT(); NeedRIGHT();
foundTextSize = true;
} }
break; break;
@ -329,6 +335,15 @@ void PCB_PARSER::parseEDA_TEXT( EDA_TEXT* aText )
Expecting( "font, justify, or hide" ); Expecting( "font, justify, or hide" );
} }
} }
// Text size was not specified in file, force legacy default units
// 60mils is 1.524mm
if( !foundTextSize )
{
const float defaultTextSize = 1.524f * IU_PER_MM;
aText->SetTextSize( wxSize( defaultTextSize, defaultTextSize ) );
}
} }