Allow reading of 0 text sizes.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/16902
This commit is contained in:
Jeff Young 2024-02-07 16:46:27 +00:00
parent bce372c8a3
commit 8efd90e6e8
4 changed files with 15 additions and 11 deletions

View File

@ -355,13 +355,15 @@ void EDA_TEXT::SetLineSpacing( double aLineSpacing )
}
void EDA_TEXT::SetTextSize( VECTOR2I aNewSize )
{
if( m_IuScale.get().IU_PER_MM != unityScale.IU_PER_MM )
void EDA_TEXT::SetTextSize( VECTOR2I aNewSize, bool aEnforceMinTextSize )
{
// Plotting uses unityScale and independently scales the text. If we clamp here we'll
// clamp to *really* small values.
if( m_IuScale.get().IU_PER_MM == unityScale.IU_PER_MM )
aEnforceMinTextSize = false;
if( aEnforceMinTextSize )
{
int min = m_IuScale.get().MilsToIU( TEXT_MIN_SIZE_MILS );
int max = m_IuScale.get().MilsToIU( TEXT_MAX_SIZE_MILS );

View File

@ -678,7 +678,8 @@ void SCH_IO_KICAD_SEXPR_PARSER::parseFill( FILL_PARAMS& aFill )
}
void SCH_IO_KICAD_SEXPR_PARSER::parseEDA_TEXT( EDA_TEXT* aText, bool aConvertOverbarSyntax )
void SCH_IO_KICAD_SEXPR_PARSER::parseEDA_TEXT( EDA_TEXT* aText, bool aConvertOverbarSyntax,
bool aEnforceMinTextSize )
{
wxCHECK_RET( aText && ( CurTok() == T_effects || CurTok() == T_href ),
"Cannot parse " + GetTokenString( CurTok() ) + " as an EDA_TEXT." );
@ -723,7 +724,7 @@ void SCH_IO_KICAD_SEXPR_PARSER::parseEDA_TEXT( EDA_TEXT* aText, bool aConvertOve
VECTOR2I sz;
sz.y = parseInternalUnits( "text height" );
sz.x = parseInternalUnits( "text width" );
aText->SetTextSize( sz );
aText->SetTextSize( sz, aEnforceMinTextSize );
NeedRIGHT();
break;
}
@ -1540,7 +1541,7 @@ LIB_PIN* SCH_IO_KICAD_SEXPR_PARSER::parsePin()
// so duplicate parsing is not required.
EDA_TEXT text( schIUScale );
parseEDA_TEXT( &text, true );
parseEDA_TEXT( &text, true, false );
pin->SetNameTextSize( text.GetTextHeight() );
NeedRIGHT();
}
@ -1574,7 +1575,7 @@ LIB_PIN* SCH_IO_KICAD_SEXPR_PARSER::parsePin()
// so duplicate parsing is not required.
EDA_TEXT text( schIUScale );
parseEDA_TEXT( &text, false );
parseEDA_TEXT( &text, false, false );
pin->SetNumberTextSize( text.GetTextHeight() );
NeedRIGHT();
}

View File

@ -180,7 +180,8 @@ private:
void parseFill( FILL_PARAMS& aFill );
void parseEDA_TEXT( EDA_TEXT* aText, bool aConvertOverbarSyntax );
void parseEDA_TEXT( EDA_TEXT* aText, bool aConvertOverbarSyntax,
bool aEnforceMinTextSize = true );
void parsePinNames( std::unique_ptr<LIB_SYMBOL>& aSymbol );
LIB_FIELD* parseProperty( std::unique_ptr<LIB_SYMBOL>& aSymbol );

View File

@ -214,7 +214,7 @@ public:
void SetLineSpacing( double aLineSpacing );
double GetLineSpacing() const { return m_attributes.m_LineSpacing; }
void SetTextSize( VECTOR2I aNewSize );
void SetTextSize( VECTOR2I aNewSize, bool aEnforceMinTextSize = true );
VECTOR2I GetTextSize() const { return m_attributes.m_Size; }
void SetTextWidth( int aWidth );