diff --git a/common/base_struct.cpp b/common/base_struct.cpp index b2ef720adb..d16aa121f8 100644 --- a/common/base_struct.cpp +++ b/common/base_struct.cpp @@ -193,7 +193,7 @@ EDA_TextStruct::~EDA_TextStruct() */ int EDA_TextStruct::LenSize( const wxString& aLine ) const { - return TextWidth(aLine, m_Size.x, m_Italic, m_Bold ) + m_Width; + return ReturnGraphicTextWidth(aLine, m_Size.x, m_Italic, m_Bold ) + m_Width; } diff --git a/common/drawtxt.cpp b/common/drawtxt.cpp index b9d61c8402..d805688702 100644 --- a/common/drawtxt.cpp +++ b/common/drawtxt.cpp @@ -20,7 +20,7 @@ #define EDA_DRAWBASE #include "hershey_fonts.h" -#define HERSHEY_SIZE 32.0 +#define HERSHEY_SIZE 32.0 // size factor used to calculate actual size of shapes from hershey fonts /* Functions to draw / plot a string. * texts have only one line. @@ -67,7 +67,7 @@ static const char* get_hershey_recipe( int AsciiCode, bool bold ) } -int TextWidth( const wxString& aText, int size_h, bool italic, bool bold ) +int ReturnGraphicTextWidth( const wxString& aText, int aXSize, bool italic, bool bold ) { int tally = 0; int char_count = aText.length(); @@ -85,13 +85,13 @@ int TextWidth( const wxString& aText, int size_h, bool italic, bool bold ) /* Get metrics */ int xsta = *ptcar++ - 'R'; int xsto = *ptcar++ - 'R'; - tally += wxRound( size_h * (xsto - xsta) / HERSHEY_SIZE ); + tally += wxRound( aXSize * (xsto - xsta) / HERSHEY_SIZE ); } /* Italic correction, 1/8em */ if( italic ) { - tally += wxRound( size_h * 0.125 ); + tally += wxRound( aXSize * 0.125 ); } return tally; } @@ -130,7 +130,7 @@ static void DrawGraphicTextPline( static int overbar_position( int size_v, int thickness ) { - return wxRound( (double) size_v * 30.0 / HERSHEY_SIZE + (double) thickness ); + return wxRound( ((double) size_v * 26/HERSHEY_SIZE ) + ((double) thickness * 1.5) ); } @@ -228,7 +228,7 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel, current_char_pos = aPos; - dx = TextWidth( aText, size_h, aItalic, aBold ); + dx = ReturnGraphicTextWidth( aText, size_h, aItalic, aBold ); dy = size_v; /* Do not draw the text if out of draw area! */ diff --git a/eeschema/class_pin.cpp b/eeschema/class_pin.cpp index cb5f700bac..988aa5dfc2 100644 --- a/eeschema/class_pin.cpp +++ b/eeschema/class_pin.cpp @@ -456,7 +456,6 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel, int x, y, x1, y1; wxString StringPinNum; EDA_Colors NameColor, NumColor; - int PinTxtLen; wxSize PinNameSize( m_PinNameSize, m_PinNameSize ); wxSize PinNumSize( m_PinNumSize, m_PinNumSize ); @@ -491,9 +490,7 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel, x1 += m_PinLen; break; } - PinTxtLen = TextWidth( m_PinName, PinNameSize.x, false, false) + LineWidth; - - if( PinTxtLen == 0 ) + if( m_PinName.IsEmpty() ) DrawPinName = FALSE; if( TextInside ) /* Draw the text inside, but the pin numbers outside. */ @@ -658,7 +655,6 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos, int x, y, x1, y1; wxString StringPinNum; EDA_Colors NameColor, NumColor; - int PinTxtLen = 0; wxSize PinNameSize = wxSize( m_PinNameSize, m_PinNameSize ); wxSize PinNumSize = wxSize( m_PinNumSize, m_PinNumSize ); bool plot_color = (g_PlotFormat == PLOT_FORMAT_POST) @@ -687,8 +683,7 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos, x1 += m_PinLen; break; } - PinTxtLen = TextWidth( m_PinName, PinNameSize.x, false, false) + aWidth; - if( PinTxtLen == 0 ) + if( m_PinName.IsEmpty() ) DrawPinName = FALSE; if( TextInside ) /* Draw the text inside, but the pin numbers outside. */ diff --git a/include/drawtxt.h b/include/drawtxt.h index d573f16b69..3d1cf1b080 100644 --- a/include/drawtxt.h +++ b/include/drawtxt.h @@ -9,7 +9,11 @@ class WinEDA_DrawPanel; -int TextWidth(const wxString& aText, int size_h, bool italic, bool bold ); +/** Function ReturnGraphicTextWidth + * @return the X size of the graphic text + * the full X size is ReturnGraphicTextWidth + the thickness of graphic lines + */ +int ReturnGraphicTextWidth(const wxString& aText, int size_h, bool italic, bool bold ); /** Function NegableTextLength * Return the text length of a negable string, excluding the ~ markers */