Browse Source

Fix some netname rendering issues

Fixes: lp:1739074
* https://bugs.launchpad.net/kicad/+bug/1739074
pull/5/merge
Kristoffer Ödmark 8 years ago
committed by Maciej Suminski
parent
commit
e7ddcca569
  1. 8
      common/gal/opengl/opengl_gal.cpp
  2. 11
      pcbnew/pcb_painter.cpp

8
common/gal/opengl/opengl_gal.cpp

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

11
pcbnew/pcb_painter.cpp

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

Loading…
Cancel
Save