From a67d8c60df1cc3f456aa6d935652cc077f2f552a Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sun, 2 Sep 2018 22:51:35 +0100 Subject: [PATCH] Fix text size measurement. 5.0 doesn't set the GAL's line width. It gets away with this since it's using the same GAL to measure as to set up the drawing, so the width happens to be set correctly for other reasons. 5.1 uses a separate GAL and so isn't so lucky. --- common/eda_text.cpp | 3 ++- eeschema/sch_text.cpp | 6 +++--- include/eda_text.h | 3 ++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/common/eda_text.cpp b/common/eda_text.cpp index c11c9c1fc3..c5effab570 100644 --- a/common/eda_text.cpp +++ b/common/eda_text.cpp @@ -64,10 +64,11 @@ void EDA_TEXT::SwapEffects( EDA_TEXT& aTradingPartner ) } -int EDA_TEXT::LenSize( const wxString& aLine ) const +int EDA_TEXT::LenSize( const wxString& aLine, int aThickness ) const { basic_gal.SetFontItalic( IsItalic() ); basic_gal.SetFontBold( IsBold() ); + basic_gal.SetLineWidth( aThickness ); basic_gal.SetGlyphSize( VECTOR2D( GetTextSize() ) ); VECTOR2D tsize = basic_gal.GetTextLineSize( aLine ); diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index c4f836f385..eff9ba38cd 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -1019,7 +1019,7 @@ void SCH_GLOBALLABEL::CreateGraphicShape( std::vector & aPoints, const aPoints.clear(); - int symb_len = LenSize( GetShownText() ) + ( TXT_MARGIN * 2 ); + int symb_len = LenSize( GetShownText(), linewidth ) + ( TXT_MARGIN * 2 ); // Create outline shape : 6 points int x = symb_len + linewidth + 3; @@ -1133,7 +1133,7 @@ const EDA_RECT SCH_GLOBALLABEL::GetBoundingBox() const height = ( (GetTextHeight() * 15) / 10 ) + width + 2 * TXT_MARGIN; // text X size add height for triangular shapes(bidirectional) - length = LenSize( GetShownText() ) + height + DANGLING_SYMBOL_SIZE; + length = LenSize( GetShownText(), width ) + height + DANGLING_SYMBOL_SIZE; switch( GetLabelSpinStyle() ) // respect orientation { @@ -1313,7 +1313,7 @@ const EDA_RECT SCH_HIERLABEL::GetBoundingBox() const int width = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness(); height = GetTextHeight() + width + 2 * TXT_MARGIN; - length = LenSize( GetShownText() ) + length = LenSize( GetShownText(), width ) + height // add height for triangular shapes + 2 * DANGLING_SYMBOL_SIZE; diff --git a/include/eda_text.h b/include/eda_text.h index 607a68ba3b..bbb15f2a10 100644 --- a/include/eda_text.h +++ b/include/eda_text.h @@ -305,8 +305,9 @@ public: * @return the text length in internal units * @param aLine : the line of text to consider. * For single line text, this parameter is always m_Text + * @param aThickness : the stroke width of the text */ - int LenSize( const wxString& aLine ) const; + int LenSize( const wxString& aLine, int aThickness ) const; /** * Function GetTextBox