7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-20 00:21:31 +00:00

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
This commit is contained in:
Dhineshkumar S 2024-11-13 02:14:19 +00:00 committed by Seth Hillbrand
parent 9bc5fd534b
commit 43b1bc52db
3 changed files with 19 additions and 2 deletions

View File

@ -249,9 +249,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
{

View File

@ -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 )
{
}

View File

@ -145,6 +145,7 @@ public:
// If true, keep rotation angle between -90...90 degrees for readability
bool m_KeepUpright;
int m_StoredStrokeWidth;
};