Fix some more pen width issues from global removal.

Fixes https://gitlab.com/kicad/code/kicad/issues/4408
This commit is contained in:
Jeff Young 2020-05-12 15:02:24 +01:00
parent 06dea92bcb
commit 301ac3461c
5 changed files with 30 additions and 8 deletions

View File

@ -159,10 +159,8 @@ int EDA_TEXT::GetEffectiveTextPenWidth( int aDefaultWidth ) const
if( IsBold() )
width = GetPenSizeForBold( GetTextWidth() );
// Avoid using a 0 width for text: it can create issues when drawing it
if( width <= 1 )
width = 1;
else if( width <= 1 )
width = GetPenSizeForNormal( GetTextWidth() );
}
// Clip pen size for small texts:

View File

@ -54,6 +54,12 @@ int GetPenSizeForBold( int aTextSize )
}
int GetPenSizeForNormal( int aTextSize )
{
return KiROUND( aTextSize / 8.0 );
}
/**
* Function Clamp_Text_PenSize
* Don't allow text to become cluttered up in its own fatness. Bold fonts are generally around

View File

@ -31,6 +31,7 @@
#include <gr_basic.h>
#include <macros.h>
#include <sch_draw_panel.h>
#include <sch_painter.h>
#include <plotter.h>
#include <base_units.h>
#include <eeschema_config.h>
@ -743,12 +744,22 @@ bool SCH_LINE::doIsConnected( const wxPoint& aPosition ) const
void SCH_LINE::Plot( PLOTTER* aPlotter )
{
auto* settings = static_cast<KIGFX::SCH_RENDER_SETTINGS*>( aPlotter->RenderSettings() );
int penWidth;
if( m_color != COLOR4D::UNSPECIFIED )
aPlotter->SetColor( m_color );
else
aPlotter->SetColor( aPlotter->RenderSettings()->GetLayerColor( GetLayer() ) );
int penWidth = std::max( GetPenWidth(), aPlotter->RenderSettings()->GetDefaultPenWidth() );
switch( m_Layer )
{
case LAYER_WIRE: penWidth = settings->m_DefaultWireThickness; break;
case LAYER_BUS: penWidth = settings->m_DefaultBusThickness; break;
default: penWidth = GetPenWidth(); break;
}
penWidth = std::max( penWidth, aPlotter->RenderSettings()->GetDefaultPenWidth() );
aPlotter->SetCurrentLineWidth( penWidth );
aPlotter->SetDash( GetLineStyle() );

View File

@ -823,19 +823,19 @@ void SCH_SCREEN::Plot( PLOTTER* aPlotter )
// Bitmaps are drawn first to ensure they are in the background
// This is particularly important for the wxPostscriptDC (used in *nix printers) as
// the bitmap PS command clears the screen
for( auto item : bitmaps )
for( SCH_ITEM* item : bitmaps )
{
aPlotter->SetCurrentLineWidth( std::max( item->GetPenWidth(), defaultPenWidth ) );
item->Plot( aPlotter );
}
for( auto item : other )
for( SCH_ITEM* item : other )
{
aPlotter->SetCurrentLineWidth( std::max( item->GetPenWidth(), defaultPenWidth ) );
item->Plot( aPlotter );
}
for( auto item : junctions )
for( SCH_ITEM* item : junctions )
{
aPlotter->SetCurrentLineWidth( std::max( item->GetPenWidth(), defaultPenWidth ) );
item->Plot( aPlotter );

View File

@ -73,6 +73,13 @@ int Clamp_Text_PenSize( int aPenSize, wxSize aSize, bool aBold = true );
*/
int GetPenSizeForBold( int aTextSize );
/**
* Function GetPensizeForNormal
* @return the "best" value for a pen size to draw/plot a non-bold text
* @param aTextSize = the char size (height or width)
*/
int GetPenSizeForNormal( int aTextSize );
/**
* Function GraphicTextWidth
* @return the X size of the graphic text