better size scale factor for Hershey fonts
This commit is contained in:
parent
91bceadf7c
commit
c7fc091a42
|
@ -19,8 +19,12 @@
|
||||||
|
|
||||||
#define EDA_DRAWBASE
|
#define EDA_DRAWBASE
|
||||||
#include "hershey_fonts.h"
|
#include "hershey_fonts.h"
|
||||||
|
/* factor used to calculate actual size of shapes from hershey fonts (could be adjusted depending on the font name)
|
||||||
#define HERSHEY_SIZE 32.0 // size factor used to calculate actual size of shapes from hershey fonts
|
* Its value is choosen in order to have letters like M, P .. vertical size equal to the vertical char size parameter
|
||||||
|
* Of course some shapes can be bigger or smaller than the vertical char size parameter
|
||||||
|
*/
|
||||||
|
#define HERSHEY_SCALE_FACTOR 1/21.0
|
||||||
|
double s_HerscheyScaleFactor = HERSHEY_SCALE_FACTOR;
|
||||||
|
|
||||||
/* Functions to draw / plot a string.
|
/* Functions to draw / plot a string.
|
||||||
* texts have only one line.
|
* texts have only one line.
|
||||||
|
@ -102,7 +106,7 @@ int ReturnGraphicTextWidth( const wxString& aText, int aXSize, bool italic, bool
|
||||||
/* Get metrics */
|
/* Get metrics */
|
||||||
int xsta = *ptcar++ - 'R';
|
int xsta = *ptcar++ - 'R';
|
||||||
int xsto = *ptcar++ - 'R';
|
int xsto = *ptcar++ - 'R';
|
||||||
tally += wxRound( aXSize * (xsto - xsta) / HERSHEY_SIZE );
|
tally += wxRound( aXSize * (xsto - xsta) * s_HerscheyScaleFactor );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Italic correction, 1/8em */
|
/* Italic correction, 1/8em */
|
||||||
|
@ -147,7 +151,7 @@ static void DrawGraphicTextPline(
|
||||||
|
|
||||||
static int overbar_position( int size_v, int thickness )
|
static int overbar_position( int size_v, int thickness )
|
||||||
{
|
{
|
||||||
return wxRound( ((double) size_v * 26/HERSHEY_SIZE ) + ((double) thickness * 1.5) );
|
return wxRound( ((double) size_v * 26 * s_HerscheyScaleFactor ) + ((double) thickness * 1.5) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -167,7 +171,7 @@ static int clamp_text_pen_size( int width, int size_h, bool bold )
|
||||||
* quantum unit, otherwise the line pairs will be visible! */
|
* quantum unit, otherwise the line pairs will be visible! */
|
||||||
if( bold )
|
if( bold )
|
||||||
{
|
{
|
||||||
int minWidth = wxRound( ABS( size_h ) * 1.42 / HERSHEY_SIZE + 0.5 );
|
int minWidth = wxRound( ABS( size_h ) * 1.42 * s_HerscheyScaleFactor + 0.5 );
|
||||||
if( width < minWidth )
|
if( width < minWidth )
|
||||||
{
|
{
|
||||||
width = minWidth;
|
width = minWidth;
|
||||||
|
@ -416,8 +420,8 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel,
|
||||||
{
|
{
|
||||||
wxPoint currpoint;
|
wxPoint currpoint;
|
||||||
hc1 -= xsta; hc2 -= 11; /* Align the midpoint */
|
hc1 -= xsta; hc2 -= 11; /* Align the midpoint */
|
||||||
hc1 = wxRound( hc1 * size_h / HERSHEY_SIZE );
|
hc1 = wxRound( hc1 * size_h * s_HerscheyScaleFactor );
|
||||||
hc2 = wxRound( hc2 * size_v / HERSHEY_SIZE );
|
hc2 = wxRound( hc2 * size_v * s_HerscheyScaleFactor );
|
||||||
|
|
||||||
// To simulate an italic font, add a x offset depending on the y offset
|
// To simulate an italic font, add a x offset depending on the y offset
|
||||||
if( aItalic )
|
if( aItalic )
|
||||||
|
@ -437,7 +441,7 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel,
|
||||||
ptr++;
|
ptr++;
|
||||||
|
|
||||||
// Apply the advance width
|
// Apply the advance width
|
||||||
current_char_pos.x += wxRound( size_h * (xsto - xsta) / HERSHEY_SIZE );
|
current_char_pos.x += wxRound( size_h * (xsto - xsta) * s_HerscheyScaleFactor );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( overbars % 2 )
|
if( overbars % 2 )
|
||||||
|
|
|
@ -714,8 +714,6 @@ void SCH_HIERLABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offs
|
||||||
{
|
{
|
||||||
static std::vector <wxPoint> Poly;
|
static std::vector <wxPoint> Poly;
|
||||||
EDA_Colors color;
|
EDA_Colors color;
|
||||||
wxPoint text_offset = offset + GetSchematicTextOffset();
|
|
||||||
|
|
||||||
int width = MAX( m_Width, g_DrawMinimunLineWidth );
|
int width = MAX( m_Width, g_DrawMinimunLineWidth );
|
||||||
|
|
||||||
if( Color >= 0 )
|
if( Color >= 0 )
|
||||||
|
@ -726,6 +724,7 @@ void SCH_HIERLABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offs
|
||||||
GRSetDrawMode( DC, DrawMode );
|
GRSetDrawMode( DC, DrawMode );
|
||||||
|
|
||||||
EXCHG( width, m_Width ); // Set the minimum width
|
EXCHG( width, m_Width ); // Set the minimum width
|
||||||
|
wxPoint text_offset = offset + GetSchematicTextOffset();
|
||||||
EDA_TextStruct::Draw( panel, DC, text_offset, color, DrawMode, FILLED, UNSPECIFIED_COLOR );
|
EDA_TextStruct::Draw( panel, DC, text_offset, color, DrawMode, FILLED, UNSPECIFIED_COLOR );
|
||||||
EXCHG( width, m_Width ); // set initial value
|
EXCHG( width, m_Width ); // set initial value
|
||||||
|
|
||||||
|
@ -775,7 +774,7 @@ EDA_Rect SCH_HIERLABEL::GetBoundingBox()
|
||||||
dx = dy = 0;
|
dx = dy = 0;
|
||||||
|
|
||||||
int width = MAX( m_Width, g_DrawMinimunLineWidth );
|
int width = MAX( m_Width, g_DrawMinimunLineWidth );
|
||||||
height = m_Size.y + 2 * TXTMARGE;
|
height = m_Size.y + width + 2 * TXTMARGE;
|
||||||
length = LenSize( m_Text )
|
length = LenSize( m_Text )
|
||||||
+ height // add height for triangular shapes
|
+ height // add height for triangular shapes
|
||||||
+ 2 * DANGLING_SYMBOL_SIZE;
|
+ 2 * DANGLING_SYMBOL_SIZE;
|
||||||
|
@ -829,7 +828,6 @@ void SCH_GLOBALLABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& aO
|
||||||
EDA_Colors color;
|
EDA_Colors color;
|
||||||
wxPoint text_offset = aOffset + GetSchematicTextOffset();
|
wxPoint text_offset = aOffset + GetSchematicTextOffset();
|
||||||
|
|
||||||
int width = MAX( m_Width, g_DrawMinimunLineWidth );
|
|
||||||
|
|
||||||
if( Color >= 0 )
|
if( Color >= 0 )
|
||||||
color = (EDA_Colors) Color;
|
color = (EDA_Colors) Color;
|
||||||
|
@ -838,6 +836,7 @@ void SCH_GLOBALLABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& aO
|
||||||
|
|
||||||
GRSetDrawMode( DC, DrawMode );
|
GRSetDrawMode( DC, DrawMode );
|
||||||
|
|
||||||
|
int width = MAX( m_Width, g_DrawMinimunLineWidth );
|
||||||
EXCHG( width, m_Width ); // Set the minimum width
|
EXCHG( width, m_Width ); // Set the minimum width
|
||||||
EDA_TextStruct::Draw( panel, DC, text_offset, color, DrawMode, FILLED, UNSPECIFIED_COLOR );
|
EDA_TextStruct::Draw( panel, DC, text_offset, color, DrawMode, FILLED, UNSPECIFIED_COLOR );
|
||||||
EXCHG( width, m_Width ); // set initial value
|
EXCHG( width, m_Width ); // set initial value
|
||||||
|
@ -996,7 +995,7 @@ EDA_Rect SCH_TEXT::GetBoundingBox()
|
||||||
y = m_Pos.y;
|
y = m_Pos.y;
|
||||||
int width = MAX( m_Width, g_DrawMinimunLineWidth );
|
int width = MAX( m_Width, g_DrawMinimunLineWidth );
|
||||||
length = LenSize( m_Text );
|
length = LenSize( m_Text );
|
||||||
height = m_Size.y;
|
height = m_Size.y + width;
|
||||||
dx = dy = 0;
|
dx = dy = 0;
|
||||||
|
|
||||||
switch( m_SchematicOrientation )
|
switch( m_SchematicOrientation )
|
||||||
|
|
Loading…
Reference in New Issue