From bf0f2aa4a84fc3250be3250cc0a99da19de0edf5 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 7 Mar 2022 17:41:46 +0000 Subject: [PATCH] Adjust bitmap text spacing a bit so it's closer to the stroke font. This helps the text better match the highlighting when it gets small enough that we switch to the bitmap font for performance. --- common/gal/graphics_abstraction_layer.cpp | 8 ++++---- eeschema/sch_painter.cpp | 7 ++++--- pcbnew/pcb_painter.cpp | 12 ++++-------- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/common/gal/graphics_abstraction_layer.cpp b/common/gal/graphics_abstraction_layer.cpp index 481f454a63..1b7a6bf0aa 100644 --- a/common/gal/graphics_abstraction_layer.cpp +++ b/common/gal/graphics_abstraction_layer.cpp @@ -268,10 +268,10 @@ void GAL::BitmapText( const wxString& aText, const VECTOR2I& aPosition, const ED attrs.m_Angle = aAngle; attrs.m_Mirrored = m_globalFlipX; // Prevent text flipping when view is flipped - // Bitmap font is slightly smaller and slightly heavier than the stroke font so we - // compensate a bit before stroking - attrs.m_StrokeWidth *= 1.2f; - attrs.m_Size = attrs.m_Size * 0.8; + // Bitmap font has different metrics than the stroke font so we compensate a bit before + // stroking + attrs.m_Size = VECTOR2I( m_attributes.m_Size.x * 1.62, m_attributes.m_Size.y * 1.39 ); + attrs.m_StrokeWidth = m_attributes.m_StrokeWidth * 0.8; font->Draw( this, aText, aPosition, attrs ); } diff --git a/eeschema/sch_painter.cpp b/eeschema/sch_painter.cpp index 885f3c5f02..2b8214823a 100644 --- a/eeschema/sch_painter.cpp +++ b/eeschema/sch_painter.cpp @@ -508,9 +508,10 @@ void SCH_PAINTER::strokeText( const wxString& aText, const VECTOR2D& aPosition, void SCH_PAINTER::bitmapText( const wxString& aText, const VECTOR2D& aPosition, const TEXT_ATTRIBUTES& aAttrs ) { - - m_gal->SetGlyphSize( aAttrs.m_Size ); - m_gal->SetLineWidth( aAttrs.m_StrokeWidth ); + // Bitmap font has different metrics than the stroke font so we compensate a bit before + // stroking + m_gal->SetGlyphSize( VECTOR2I( aAttrs.m_Size.x * 0.60, aAttrs.m_Size.y * 0.72 ) ); + m_gal->SetLineWidth( aAttrs.m_StrokeWidth * 1.2 ); m_gal->SetHorizontalJustify( aAttrs.m_Halign ); m_gal->SetVerticalJustify( aAttrs.m_Valign ); diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index ab2c535c0b..27c37fe42c 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -590,7 +590,7 @@ void PCB_PAINTER::draw( const PCB_TRACK* aTrack, int aLayer ) const wxString& netName = UnescapeString( aTrack->GetShortNetname() ); double textSize = width; - double penWidth = width / 12.0; + double penWidth = textSize / 12.0; VECTOR2D textPosition = ( visibleSeg.A + visibleSeg.B ) / 2.0; // center of the track EDA_ANGLE textOrientation; @@ -609,19 +609,15 @@ void PCB_PAINTER::draw( const PCB_TRACK* aTrack, int aLayer ) if( end.y == start.y ) // horizontal { textOrientation = ANGLE_HORIZONTAL; - textPosition.y += penWidth; } else if( end.x == start.x ) // vertical { textOrientation = ANGLE_VERTICAL; - textPosition.x += penWidth; } else { textOrientation = EDA_ANGLE( visibleSeg.B - visibleSeg.A ) + ANGLE_90; textOrientation.Normalize90(); - textPosition.x += penWidth / 1.4; - textPosition.y += penWidth / 1.4; } m_gal->SetIsStroke( true ); @@ -789,7 +785,7 @@ void PCB_PAINTER::draw( const PCB_VIA* aVia, int aLayer ) tsize = std::min( tsize, size ); // Use a smaller text size to handle interline, pen size.. - tsize *= 0.7; + tsize *= 0.75; VECTOR2D namesize( tsize, tsize ); m_gal->SetGlyphSize( namesize ); @@ -985,7 +981,7 @@ void PCB_PAINTER::draw( const PAD* aPad, int aLayer ) tsize = std::min( tsize, size ); // Use a smaller text size to handle interline, pen size... - tsize *= 0.7; + tsize *= 0.75; VECTOR2D namesize( tsize, tsize ); m_gal->SetGlyphSize( namesize ); @@ -1002,7 +998,7 @@ void PCB_PAINTER::draw( const PAD* aPad, int aLayer ) tsize = std::min( tsize, size ); // Use a smaller text size to handle interline, pen size... - tsize *= 0.7; + tsize *= 0.75; tsize = std::min( tsize, size ); VECTOR2D numsize( tsize, tsize );