diff --git a/common/font/outline_font.cpp b/common/font/outline_font.cpp index 35bfcb13f4..f92c964034 100644 --- a/common/font/outline_font.cpp +++ b/common/font/outline_font.cpp @@ -305,7 +305,8 @@ VECTOR2I OUTLINE_FONT::getTextAsGlyphs( BOX2I* aBBox, std::vector> underscoreGlyphs; + + getTextAsGlyphs( nullptr, &underscoreGlyphs, wxT( "_" ), aSize, { 0, 0 }, ANGLE_0, false, + { 0, 0 }, aTextStyle & ~TEXT_STYLE::OVERBAR ); + + OUTLINE_GLYPH* underscoreGlyph = static_cast( underscoreGlyphs[0].get() ); + EDA_RECT underscoreBBox; + + for( const VECTOR2I& pt : underscoreGlyph->Outline( 0 ).CPoints() ) + underscoreBBox.Merge( pt ); + + int barThickness = underscoreBBox.GetHeight(); + + // Shorten the bar a little so its rounded ends don't make it over-long + double barTrim = barThickness / 2; + VECTOR2I topLeft( aPosition ); VECTOR2I topRight( aPosition ); @@ -449,15 +463,10 @@ VECTOR2I OUTLINE_FONT::getTextAsGlyphs( BOX2I* aBBox, std::vector overbarGlyph = std::make_unique( poly ); aGlyphs->push_back( std::move( overbarGlyph ) );