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:
parent
d10c8cd75b
commit
687c2f3e82
|
@ -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();
|
int width = GetTextThickness();
|
||||||
|
|
||||||
if( width <= 0 )
|
if( width <= 1 )
|
||||||
{
|
{
|
||||||
|
width = aDefaultWidth;
|
||||||
|
|
||||||
if( IsBold() )
|
if( IsBold() )
|
||||||
width = GetPenSizeForBold( GetTextWidth() );
|
width = GetPenSizeForBold( GetTextWidth() );
|
||||||
else
|
|
||||||
|
// Avoid using a 0 width for text: it can create issues when drawing it
|
||||||
|
if( width <= 1 )
|
||||||
width = 1;
|
width = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -146,7 +146,7 @@ void SCH_FIELD::Print( RENDER_SETTINGS* aSettings, const wxPoint& aOffset )
|
||||||
COLOR4D color = aSettings->GetLayerColor( IsForceVisible() ? LAYER_HIDDEN : m_Layer );
|
COLOR4D color = aSettings->GetLayerColor( IsForceVisible() ? LAYER_HIDDEN : m_Layer );
|
||||||
int orient;
|
int orient;
|
||||||
wxPoint textpos;
|
wxPoint textpos;
|
||||||
int penWidth = std::max( GetEffectiveTextPenWidth(), aSettings->GetDefaultPenWidth() );
|
int penWidth = GetEffectiveTextPenWidth( aSettings->GetDefaultPenWidth() );
|
||||||
|
|
||||||
if( ( !IsVisible() && !IsForceVisible() ) || IsVoid() )
|
if( ( !IsVisible() && !IsForceVisible() ) || IsVoid() )
|
||||||
return;
|
return;
|
||||||
|
@ -483,8 +483,8 @@ bool SCH_FIELD::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy )
|
||||||
void SCH_FIELD::Plot( PLOTTER* aPlotter )
|
void SCH_FIELD::Plot( PLOTTER* aPlotter )
|
||||||
{
|
{
|
||||||
COLOR4D color = aPlotter->RenderSettings()->GetLayerColor( GetLayer() );
|
COLOR4D color = aPlotter->RenderSettings()->GetLayerColor( GetLayer() );
|
||||||
int penWidth = std::max( GetEffectiveTextPenWidth(),
|
int penWidth = GetEffectiveTextPenWidth(
|
||||||
aPlotter->RenderSettings()->GetDefaultPenWidth() );
|
aPlotter->RenderSettings()->GetDefaultPenWidth() );
|
||||||
|
|
||||||
if( !IsVisible() )
|
if( !IsVisible() )
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -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 SCH_PAINTER::getTextThickness( const SCH_TEXT* aItem, bool aDrawingShadows )
|
||||||
{
|
{
|
||||||
float width = (float) std::max( aItem->GetEffectiveTextPenWidth(),
|
float width = (float) aItem->GetEffectiveTextPenWidth( m_schSettings.GetDefaultPenWidth() );
|
||||||
m_schSettings.GetDefaultPenWidth() );
|
|
||||||
|
|
||||||
if( aItem->IsSelected() && aDrawingShadows )
|
if( aItem->IsSelected() && aDrawingShadows )
|
||||||
width += getShadowWidth();
|
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 SCH_PAINTER::getTextThickness( const SCH_FIELD* aItem, bool aDrawingShadows )
|
||||||
{
|
{
|
||||||
float width = (float) std::max( aItem->GetEffectiveTextPenWidth(),
|
float width = (float) aItem->GetEffectiveTextPenWidth( m_schSettings.GetDefaultPenWidth() );
|
||||||
m_schSettings.GetDefaultPenWidth() );
|
|
||||||
|
|
||||||
if( aItem->IsSelected() && aDrawingShadows )
|
if( aItem->IsSelected() && aDrawingShadows )
|
||||||
width += getShadowWidth();
|
width += getShadowWidth();
|
||||||
|
|
|
@ -592,8 +592,7 @@ void SCH_TEXT::Plot( PLOTTER* aPlotter )
|
||||||
{
|
{
|
||||||
static std::vector<wxPoint> Poly;
|
static std::vector<wxPoint> Poly;
|
||||||
COLOR4D color = aPlotter->RenderSettings()->GetLayerColor( GetLayer() );
|
COLOR4D color = aPlotter->RenderSettings()->GetLayerColor( GetLayer() );
|
||||||
int penWidth = std::max( GetEffectiveTextPenWidth(),
|
int penWidth = GetEffectiveTextPenWidth( aPlotter->RenderSettings()->GetDefaultPenWidth() );
|
||||||
aPlotter->RenderSettings()->GetDefaultPenWidth() );
|
|
||||||
|
|
||||||
aPlotter->SetCurrentLineWidth( penWidth );
|
aPlotter->SetCurrentLineWidth( penWidth );
|
||||||
|
|
||||||
|
|
|
@ -156,7 +156,12 @@ public:
|
||||||
*/
|
*/
|
||||||
void SetTextThickness( int aWidth ) { m_e.penwidth = aWidth; };
|
void SetTextThickness( int aWidth ) { m_e.penwidth = aWidth; };
|
||||||
int GetTextThickness() const { return m_e.penwidth; };
|
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 )
|
virtual void SetTextAngle( double aAngle )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue