Browse Source

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.
pull/16/head
jean-pierre charras 6 years ago
parent
commit
687c2f3e82
  1. 10
      common/eda_text.cpp
  2. 6
      eeschema/sch_field.cpp
  3. 6
      eeschema/sch_painter.cpp
  4. 3
      eeschema/sch_text.cpp
  5. 7
      include/eda_text.h

10
common/eda_text.cpp

@ -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;
}

6
eeschema/sch_field.cpp

@ -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;

6
eeschema/sch_painter.cpp

@ -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();

3
eeschema/sch_text.cpp

@ -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 );

7
include/eda_text.h

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

Loading…
Cancel
Save