Allow reading of 0 text sizes.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/16902
This commit is contained in:
parent
bce372c8a3
commit
8efd90e6e8
|
@ -355,13 +355,15 @@ void EDA_TEXT::SetLineSpacing( double aLineSpacing )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EDA_TEXT::SetTextSize( VECTOR2I aNewSize )
|
void EDA_TEXT::SetTextSize( VECTOR2I aNewSize, bool aEnforceMinTextSize )
|
||||||
{
|
{
|
||||||
if( m_IuScale.get().IU_PER_MM != unityScale.IU_PER_MM )
|
// Plotting uses unityScale and independently scales the text. If we clamp here we'll
|
||||||
{
|
// clamp to *really* small values.
|
||||||
// Plotting uses unityScale and independently scales the text. If we clamp here we'll
|
if( m_IuScale.get().IU_PER_MM == unityScale.IU_PER_MM )
|
||||||
// clamp to *really* small values.
|
aEnforceMinTextSize = false;
|
||||||
|
|
||||||
|
if( aEnforceMinTextSize )
|
||||||
|
{
|
||||||
int min = m_IuScale.get().MilsToIU( TEXT_MIN_SIZE_MILS );
|
int min = m_IuScale.get().MilsToIU( TEXT_MIN_SIZE_MILS );
|
||||||
int max = m_IuScale.get().MilsToIU( TEXT_MAX_SIZE_MILS );
|
int max = m_IuScale.get().MilsToIU( TEXT_MAX_SIZE_MILS );
|
||||||
|
|
||||||
|
|
|
@ -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 ),
|
wxCHECK_RET( aText && ( CurTok() == T_effects || CurTok() == T_href ),
|
||||||
"Cannot parse " + GetTokenString( CurTok() ) + " as an EDA_TEXT." );
|
"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;
|
VECTOR2I sz;
|
||||||
sz.y = parseInternalUnits( "text height" );
|
sz.y = parseInternalUnits( "text height" );
|
||||||
sz.x = parseInternalUnits( "text width" );
|
sz.x = parseInternalUnits( "text width" );
|
||||||
aText->SetTextSize( sz );
|
aText->SetTextSize( sz, aEnforceMinTextSize );
|
||||||
NeedRIGHT();
|
NeedRIGHT();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1540,7 +1541,7 @@ LIB_PIN* SCH_IO_KICAD_SEXPR_PARSER::parsePin()
|
||||||
// so duplicate parsing is not required.
|
// so duplicate parsing is not required.
|
||||||
EDA_TEXT text( schIUScale );
|
EDA_TEXT text( schIUScale );
|
||||||
|
|
||||||
parseEDA_TEXT( &text, true );
|
parseEDA_TEXT( &text, true, false );
|
||||||
pin->SetNameTextSize( text.GetTextHeight() );
|
pin->SetNameTextSize( text.GetTextHeight() );
|
||||||
NeedRIGHT();
|
NeedRIGHT();
|
||||||
}
|
}
|
||||||
|
@ -1574,7 +1575,7 @@ LIB_PIN* SCH_IO_KICAD_SEXPR_PARSER::parsePin()
|
||||||
// so duplicate parsing is not required.
|
// so duplicate parsing is not required.
|
||||||
EDA_TEXT text( schIUScale );
|
EDA_TEXT text( schIUScale );
|
||||||
|
|
||||||
parseEDA_TEXT( &text, false );
|
parseEDA_TEXT( &text, false, false );
|
||||||
pin->SetNumberTextSize( text.GetTextHeight() );
|
pin->SetNumberTextSize( text.GetTextHeight() );
|
||||||
NeedRIGHT();
|
NeedRIGHT();
|
||||||
}
|
}
|
||||||
|
|
|
@ -180,7 +180,8 @@ private:
|
||||||
|
|
||||||
void parseFill( FILL_PARAMS& aFill );
|
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 );
|
void parsePinNames( std::unique_ptr<LIB_SYMBOL>& aSymbol );
|
||||||
|
|
||||||
LIB_FIELD* parseProperty( std::unique_ptr<LIB_SYMBOL>& aSymbol );
|
LIB_FIELD* parseProperty( std::unique_ptr<LIB_SYMBOL>& aSymbol );
|
||||||
|
|
|
@ -214,7 +214,7 @@ public:
|
||||||
void SetLineSpacing( double aLineSpacing );
|
void SetLineSpacing( double aLineSpacing );
|
||||||
double GetLineSpacing() const { return m_attributes.m_LineSpacing; }
|
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; }
|
VECTOR2I GetTextSize() const { return m_attributes.m_Size; }
|
||||||
|
|
||||||
void SetTextWidth( int aWidth );
|
void SetTextWidth( int aWidth );
|
||||||
|
|
Loading…
Reference in New Issue