Fix some netname rendering issues

Fixes: lp:1739074
* https://bugs.launchpad.net/kicad/+bug/1739074
This commit is contained in:
Kristoffer Ödmark 2018-01-07 16:00:29 +01:00 committed by Maciej Suminski
parent 89cbb079a9
commit e7ddcca569
2 changed files with 14 additions and 5 deletions

View File

@ -1676,6 +1676,7 @@ std::pair<VECTOR2D, float> OPENGL_GAL::computeBitmapTextSize( const UTF8& aText
{
VECTOR2D textSize( 0, 0 );
float commonOffset = std::numeric_limits<float>::max();
static const auto defaultGlyph = LookupGlyph( '(' ); // for strange chars
for( UTF8::uni_iter chIt = aText.ubegin(), end = aText.uend(); chIt < end; ++chIt )
{
@ -1688,18 +1689,17 @@ std::pair<VECTOR2D, float> OPENGL_GAL::computeBitmapTextSize( const UTF8& aText
if( !glyph || // Not coded in font
c == '-' || c == '_' ) // Strange size of these 2 chars
{
c = 'x'; // For calculation of the char size, replace by a medium sized char
glyph = LookupGlyph( c );
glyph = defaultGlyph;
}
if( glyph )
{
textSize.x += glyph->advance;
textSize.y = std::max<float>( textSize.y, font_information.max_y - glyph->miny );
commonOffset = std::min<float>( font_information.max_y - glyph->maxy, commonOffset );
}
}
textSize.y = std::max<float>( textSize.y, font_information.max_y - defaultGlyph->miny );
commonOffset = std::min<float>( font_information.max_y - defaultGlyph->maxy, commonOffset );
textSize.y -= commonOffset;
return std::make_pair( textSize, commonOffset );

View File

@ -352,7 +352,16 @@ void PCB_PAINTER::draw( const TRACK* aTrack, int aLayer )
const wxString& netName = aTrack->GetShortNetname();
VECTOR2D textPosition = start + line / 2.0; // center of the track
double textOrientation = -atan( line.y / line.x );
double textOrientation;
if( end.y == start.y ) // horizontal
textOrientation = 0;
else if( end.x == start.x ) // vertical
textOrientation = M_PI / 2;
else
textOrientation = -atan( line.y / line.x );
double textSize = width;
m_gal->SetIsStroke( true );