From a29968fa91f602a44d2b19afd5cb07bcc13700c8 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Thu, 24 Feb 2022 18:15:47 +0000 Subject: [PATCH] Make sure bitmap fallback is only used for non-cached text. Also fixes backwards vertical justification for bitmap text. Fixes https://gitlab.com/kicad/code/kicad/issues/10956 --- common/gal/opengl/opengl_gal.cpp | 4 ++-- eeschema/sch_painter.cpp | 18 +++++++++++++----- eeschema/sch_painter.h | 3 +++ 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/common/gal/opengl/opengl_gal.cpp b/common/gal/opengl/opengl_gal.cpp index cc87c2570b..f899cd940a 100644 --- a/common/gal/opengl/opengl_gal.cpp +++ b/common/gal/opengl/opengl_gal.cpp @@ -1340,8 +1340,6 @@ void OPENGL_GAL::BitmapText( const wxString& aText, const VECTOR2I& aPosition, switch( GetVerticalJustify() ) { case GR_TEXT_V_ALIGN_TOP: - Translate( VECTOR2D( 0, -textSize.y ) ); - overbarHeight = -textSize.y / 2.0; break; case GR_TEXT_V_ALIGN_CENTER: @@ -1350,6 +1348,8 @@ void OPENGL_GAL::BitmapText( const wxString& aText, const VECTOR2I& aPosition, break; case GR_TEXT_V_ALIGN_BOTTOM: + Translate( VECTOR2D( 0, -textSize.y ) ); + overbarHeight = -textSize.y / 2.0; break; } diff --git a/eeschema/sch_painter.cpp b/eeschema/sch_painter.cpp index 7c6441fc88..e6bc6dadba 100644 --- a/eeschema/sch_painter.cpp +++ b/eeschema/sch_painter.cpp @@ -255,6 +255,14 @@ bool SCH_PAINTER::Draw( const VIEW_ITEM *aItem, int aLayer ) #define BITMAP_FONT_LOD_THRESHOLD 3.5 +bool SCH_PAINTER::nonCached( const EDA_ITEM* aItem ) +{ + // TODO: it would be nice to have a more definitive test for this, but we've currently got + // no access to the VIEW_GROUP to see if it's cached or not. + return aItem->IsSelected(); +} + + bool SCH_PAINTER::underLODThreshold( int aFontSize ) { return aFontSize * m_gal->GetWorldScale() < BITMAP_FONT_LOD_THRESHOLD; @@ -875,7 +883,7 @@ void SCH_PAINTER::draw( const LIB_FIELD *aField, int aLayer ) attrs.m_Valign = GR_TEXT_V_ALIGN_CENTER; attrs.m_StrokeWidth = getTextThickness( aField, drawingShadows ); - if( underLODThreshold( aField->GetTextHeight() ) ) + if( nonCached( aField ) && underLODThreshold( aField->GetTextHeight() ) ) bitmapText( UnescapeString( aField->GetText() ), textpos, attrs ); else strokeText( UnescapeString( aField->GetText() ), textpos, attrs ); @@ -943,7 +951,7 @@ void SCH_PAINTER::draw( const LIB_TEXT* aText, int aLayer ) attrs.m_Halign = GR_TEXT_H_ALIGN_CENTER; attrs.m_Valign = GR_TEXT_V_ALIGN_CENTER; - if( underLODThreshold( aText->GetTextHeight() ) ) + if( nonCached( aText ) && underLODThreshold( aText->GetTextHeight() ) ) bitmapText( aText->GetText(), pos, attrs ); else strokeText( aText->GetText(), pos, attrs ); @@ -1405,7 +1413,7 @@ void SCH_PAINTER::draw( LIB_PIN *aPin, int aLayer ) { boxText( text[i], aPos, attrs ); } - else if( underLODThreshold( size[i] ) ) + else if( nonCached( aPin ) && underLODThreshold( size[i] ) ) { bitmapText( text[i], aPos, attrs ); } @@ -1830,7 +1838,7 @@ void SCH_PAINTER::draw( const SCH_TEXT *aText, int aLayer ) attrs.m_Angle = aText->GetDrawRotation(); attrs.m_StrokeWidth = getTextThickness( aText, drawingShadows ); - if( underLODThreshold( aText->GetTextHeight() ) ) + if( nonCached( aText ) && underLODThreshold( aText->GetTextHeight() ) ) { bitmapText( shownText, aText->GetDrawPos() + text_offset, attrs ); } @@ -2179,7 +2187,7 @@ void SCH_PAINTER::draw( const SCH_FIELD *aField, int aLayer ) attributes.m_StrokeWidth = getTextThickness( aField, drawingShadows ); attributes.m_Angle = orient; - if( underLODThreshold( aField->GetTextHeight() ) ) + if( nonCached( aField ) && underLODThreshold( aField->GetTextHeight() ) ) { bitmapText( shownText, textpos, attributes ); } diff --git a/eeschema/sch_painter.h b/eeschema/sch_painter.h index 41efafe50d..902edc138a 100644 --- a/eeschema/sch_painter.h +++ b/eeschema/sch_painter.h @@ -183,6 +183,9 @@ private: int internalPinDecoSize( const LIB_PIN &aPin ); int externalPinDecoSize( const LIB_PIN &aPin ); + // Indicates the item is drawn on a non-cached layer in OpenGL + bool nonCached( const EDA_ITEM* aItem ); + bool underLODThreshold( int aFontSize ); bool isUnitAndConversionShown( const LIB_ITEM* aItem ) const;