Fix switching bold option on and off alters text thickness
Currently, unselecting the bold option resets the thickness to the
standard size instead of reverting to the original thickness.
To address this, the original thickness should be preserved so it
can be restored when bold is turned off.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/18975
(cherry picked from commit 43b1bc52db)
This commit is contained in:
committed by
Wayne Stambaugh
parent
c8f7887cf8
commit
335bb8792f
+16
-1
@@ -251,9 +251,24 @@ void EDA_TEXT::SetBold( bool aBold )
|
||||
const int size = std::min( m_attributes.m_Size.x, m_attributes.m_Size.y );
|
||||
|
||||
if( aBold )
|
||||
{
|
||||
m_attributes.m_StoredStrokeWidth = m_attributes.m_StrokeWidth;
|
||||
m_attributes.m_StrokeWidth = GetPenSizeForBold( size );
|
||||
}
|
||||
else
|
||||
m_attributes.m_StrokeWidth = GetPenSizeForNormal( size );
|
||||
{
|
||||
// Restore the original stroke width from `m_StoredStrokeWidth` if it was previously stored,
|
||||
// resetting the width after unbolding.
|
||||
if( m_attributes.m_StoredStrokeWidth )
|
||||
m_attributes.m_StrokeWidth = m_attributes.m_StoredStrokeWidth;
|
||||
else
|
||||
{
|
||||
m_attributes.m_StrokeWidth = GetPenSizeForNormal( size );
|
||||
// Sets `m_StrokeWidth` to the normal pen size and stores it in `m_StoredStrokeWidth`
|
||||
// as the default, but only if the bold option was applied before this feature was implemented.
|
||||
m_attributes.m_StoredStrokeWidth = m_attributes.m_StrokeWidth;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -35,7 +35,8 @@ TEXT_ATTRIBUTES::TEXT_ATTRIBUTES( KIFONT::FONT* aFont ) :
|
||||
m_Visible( true ),
|
||||
m_Mirrored( false ),
|
||||
m_Multiline( true ),
|
||||
m_KeepUpright( false )
|
||||
m_KeepUpright( false ),
|
||||
m_StoredStrokeWidth( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -85,6 +85,7 @@ public:
|
||||
|
||||
// If true, keep rotation angle between -90...90 degrees for readability
|
||||
bool m_KeepUpright;
|
||||
int m_StoredStrokeWidth;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user