eeschema: fix a readability issue for small texts.

Texts were drawn with a minimal line thickness = GetDefaultPenWidth().
The default pen width can be to large for small texts.
So the actual text thickness is now always clamped.
This commit is contained in:
jean-pierre charras 2020-04-30 08:59:43 +02:00
parent d10c8cd75b
commit 687c2f3e82
5 changed files with 19 additions and 13 deletions

View File

@ -149,15 +149,19 @@ void EDA_TEXT::SwapEffects( EDA_TEXT& aTradingPartner )
}
int EDA_TEXT::GetEffectiveTextPenWidth() const
int EDA_TEXT::GetEffectiveTextPenWidth( int aDefaultWidth ) const
{
int width = GetTextThickness();
if( width <= 0 )
if( width <= 1 )
{
width = aDefaultWidth;
if( IsBold() )
width = GetPenSizeForBold( GetTextWidth() );
else
// Avoid using a 0 width for text: it can create issues when drawing it
if( width <= 1 )
width = 1;
}

View File

@ -146,7 +146,7 @@ void SCH_FIELD::Print( RENDER_SETTINGS* aSettings, const wxPoint& aOffset )
COLOR4D color = aSettings->GetLayerColor( IsForceVisible() ? LAYER_HIDDEN : m_Layer );
int orient;
wxPoint textpos;
int penWidth = std::max( GetEffectiveTextPenWidth(), aSettings->GetDefaultPenWidth() );
int penWidth = GetEffectiveTextPenWidth( aSettings->GetDefaultPenWidth() );
if( ( !IsVisible() && !IsForceVisible() ) || IsVoid() )
return;
@ -483,8 +483,8 @@ bool SCH_FIELD::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy )
void SCH_FIELD::Plot( PLOTTER* aPlotter )
{
COLOR4D color = aPlotter->RenderSettings()->GetLayerColor( GetLayer() );
int penWidth = std::max( GetEffectiveTextPenWidth(),
aPlotter->RenderSettings()->GetDefaultPenWidth() );
int penWidth = GetEffectiveTextPenWidth(
aPlotter->RenderSettings()->GetDefaultPenWidth() );
if( !IsVisible() )
return;

View File

@ -325,8 +325,7 @@ float SCH_PAINTER::getLineWidth( const SCH_ITEM* aItem, bool aDrawingShadows )
float SCH_PAINTER::getTextThickness( const SCH_TEXT* aItem, bool aDrawingShadows )
{
float width = (float) std::max( aItem->GetEffectiveTextPenWidth(),
m_schSettings.GetDefaultPenWidth() );
float width = (float) aItem->GetEffectiveTextPenWidth( m_schSettings.GetDefaultPenWidth() );
if( aItem->IsSelected() && aDrawingShadows )
width += getShadowWidth();
@ -337,8 +336,7 @@ float SCH_PAINTER::getTextThickness( const SCH_TEXT* aItem, bool aDrawingShadows
float SCH_PAINTER::getTextThickness( const SCH_FIELD* aItem, bool aDrawingShadows )
{
float width = (float) std::max( aItem->GetEffectiveTextPenWidth(),
m_schSettings.GetDefaultPenWidth() );
float width = (float) aItem->GetEffectiveTextPenWidth( m_schSettings.GetDefaultPenWidth() );
if( aItem->IsSelected() && aDrawingShadows )
width += getShadowWidth();

View File

@ -592,8 +592,7 @@ void SCH_TEXT::Plot( PLOTTER* aPlotter )
{
static std::vector<wxPoint> Poly;
COLOR4D color = aPlotter->RenderSettings()->GetLayerColor( GetLayer() );
int penWidth = std::max( GetEffectiveTextPenWidth(),
aPlotter->RenderSettings()->GetDefaultPenWidth() );
int penWidth = GetEffectiveTextPenWidth( aPlotter->RenderSettings()->GetDefaultPenWidth() );
aPlotter->SetCurrentLineWidth( penWidth );

View File

@ -156,7 +156,12 @@ public:
*/
void SetTextThickness( int aWidth ) { m_e.penwidth = aWidth; };
int GetTextThickness() const { return m_e.penwidth; };
int GetEffectiveTextPenWidth() const;
/**
* The EffectiveTextPenWidth uses the text thickness if > 1 or
* aDefaultWidth.
*/
int GetEffectiveTextPenWidth( int aDefaultWidth = 0 ) const;
virtual void SetTextAngle( double aAngle )
{