From e7ddcca5692d3d4ec5888a7c7b48fd2d3d134c67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristoffer=20=C3=96dmark?= Date: Sun, 7 Jan 2018 16:00:29 +0100 Subject: [PATCH] Fix some netname rendering issues Fixes: lp:1739074 * https://bugs.launchpad.net/kicad/+bug/1739074 --- common/gal/opengl/opengl_gal.cpp | 8 ++++---- pcbnew/pcb_painter.cpp | 11 ++++++++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/common/gal/opengl/opengl_gal.cpp b/common/gal/opengl/opengl_gal.cpp index ec98fe7718..cbb7e8e469 100644 --- a/common/gal/opengl/opengl_gal.cpp +++ b/common/gal/opengl/opengl_gal.cpp @@ -1676,6 +1676,7 @@ std::pair OPENGL_GAL::computeBitmapTextSize( const UTF8& aText { VECTOR2D textSize( 0, 0 ); float commonOffset = std::numeric_limits::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 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( textSize.y, font_information.max_y - glyph->miny ); - commonOffset = std::min( font_information.max_y - glyph->maxy, commonOffset ); } } + textSize.y = std::max( textSize.y, font_information.max_y - defaultGlyph->miny ); + commonOffset = std::min( font_information.max_y - defaultGlyph->maxy, commonOffset ); textSize.y -= commonOffset; return std::make_pair( textSize, commonOffset ); diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index 1d807aa4e3..9266df6afc 100644 --- a/pcbnew/pcb_painter.cpp +++ b/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 );