From 662c1ce88f1cc6eb7836b5172213e7d294fde0e9 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 25 Apr 2022 16:33:43 +0100 Subject: [PATCH] Improve outline font overbar metrics. --- common/font/outline_font.cpp | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) 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 ) );