Fix some placement bugs with selection haloes on text.
Fixes: lp:1838841 * https://bugs.launchpad.net/kicad/+bug/1838841
This commit is contained in:
parent
7349fe2e72
commit
5503727d3d
|
@ -169,11 +169,9 @@ wxString EDA_TEXT::ShortenedShownText() const
|
|||
}
|
||||
|
||||
|
||||
int EDA_TEXT::GetInterline( int aTextThickness ) const
|
||||
int EDA_TEXT::GetInterline() const
|
||||
{
|
||||
int thickness = aTextThickness <= 0 ? GetThickness() : aTextThickness;
|
||||
|
||||
return KiROUND( KIGFX::STROKE_FONT::GetInterline( GetTextHeight(), thickness ) );
|
||||
return KiROUND( KIGFX::STROKE_FONT::GetInterline( GetTextHeight() ) );
|
||||
}
|
||||
|
||||
|
||||
|
@ -215,7 +213,7 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY ) const
|
|||
// calculate the H and V size
|
||||
int dx = KiROUND( basic_gal.GetStrokeFont().ComputeStringBoundaryLimits(
|
||||
text, VECTOR2D( GetTextSize() ), double( thickness ) ).x );
|
||||
int dy = GetInterline( thickness );
|
||||
int dy = GetInterline();
|
||||
|
||||
// Creates bounding box (rectangle) for an horizontal
|
||||
// and left and top justified text. the bounding box will be moved later
|
||||
|
@ -317,7 +315,7 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY ) const
|
|||
break;
|
||||
|
||||
case GR_TEXT_VJUSTIFY_BOTTOM:
|
||||
yoffset = linecount * GetInterline( aThickness );
|
||||
yoffset = linecount * GetInterline();
|
||||
rect.SetY( rect.GetY() - yoffset );
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
|
||||
using namespace KIGFX;
|
||||
|
||||
const double STROKE_FONT::INTERLINE_PITCH_RATIO = 1.5;
|
||||
const double STROKE_FONT::INTERLINE_PITCH_RATIO = 1.61;
|
||||
const double STROKE_FONT::OVERBAR_POSITION_FACTOR = 1.22;
|
||||
const double STROKE_FONT::BOLD_FACTOR = 1.3;
|
||||
const double STROKE_FONT::STROKE_FONT_SCALE = 1.0 / 21.0;
|
||||
|
@ -124,15 +124,11 @@ bool STROKE_FONT::LoadNewStrokeFont( const char* const aNewStrokeFont[], int aNe
|
|||
|
||||
|
||||
// Static function:
|
||||
double STROKE_FONT::GetInterline( double aGlyphHeight, double aGlyphThickness )
|
||||
double STROKE_FONT::GetInterline( double aGlyphHeight )
|
||||
{
|
||||
return ( aGlyphHeight * INTERLINE_PITCH_RATIO ) + aGlyphThickness;
|
||||
}
|
||||
|
||||
|
||||
int STROKE_FONT::getInterline() const
|
||||
{
|
||||
return KiROUND( GetInterline( m_gal->GetGlyphSize().y, m_gal->GetLineWidth() ) );
|
||||
// Do not add the glyph thickness to the interline. This makes bold text line-spacing
|
||||
// different from normal text, which is poor typography.
|
||||
return ( aGlyphHeight * INTERLINE_PITCH_RATIO );
|
||||
}
|
||||
|
||||
|
||||
|
@ -172,7 +168,7 @@ void STROKE_FONT::Draw( const UTF8& aText, const VECTOR2D& aPosition, double aRo
|
|||
m_gal->Rotate( -aRotationAngle );
|
||||
|
||||
// Single line height
|
||||
int lineHeight = getInterline( );
|
||||
int lineHeight = KiROUND( GetInterline( m_gal->GetGlyphSize().y ) );
|
||||
int lineCount = linesCount( aText );
|
||||
const VECTOR2D& glyphSize = m_gal->GetGlyphSize();
|
||||
|
||||
|
@ -450,7 +446,7 @@ VECTOR2D STROKE_FONT::ComputeStringBoundaryLimits( const UTF8& aText, const VECT
|
|||
string_bbox.x = std::max( maxX, curX );
|
||||
string_bbox.x *= aGlyphSize.x;
|
||||
string_bbox.x += aGlyphThickness;
|
||||
string_bbox.y = line_count * GetInterline( aGlyphSize.y, aGlyphThickness );
|
||||
string_bbox.y = line_count * GetInterline( aGlyphSize.y );
|
||||
|
||||
// For italic correction, take in account italic tilt
|
||||
if( m_gal->IsFontItalic() )
|
||||
|
|
|
@ -156,8 +156,8 @@ void SCH_DRAW_PANEL::setDefaultLayerDeps()
|
|||
m_view->SetLayerTarget( LAYER_WORKSHEET, KIGFX::TARGET_NONCACHED );
|
||||
m_view->SetLayerDisplayOnly( LAYER_WORKSHEET ) ;
|
||||
|
||||
m_view->SetLayerTarget( LAYER_SELECTION_SHADOWS, KIGFX::TARGET_NONCACHED );
|
||||
m_view->SetLayerDisplayOnly( LAYER_SELECTION_SHADOWS ) ;
|
||||
// m_view->SetLayerTarget( LAYER_SELECTION_SHADOWS, KIGFX::TARGET_NONCACHED );
|
||||
// m_view->SetLayerDisplayOnly( LAYER_SELECTION_SHADOWS ) ;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -821,6 +821,9 @@ void SCH_PAINTER::draw( LIB_PIN *aPin, int aLayer )
|
|||
{
|
||||
for( float& t : thickness )
|
||||
t += getShadowWidth();
|
||||
|
||||
insideOffset -= KiROUND( getShadowWidth() / 2 );
|
||||
outsideOffset -= KiROUND( getShadowWidth() / 2 );
|
||||
}
|
||||
|
||||
#define SET_DC( i ) \
|
||||
|
@ -1127,9 +1130,34 @@ void SCH_PAINTER::draw( SCH_TEXT *aText, int aLayer )
|
|||
m_gal->SetStrokeColor( color );
|
||||
m_gal->SetTextAttributes( aText );
|
||||
|
||||
wxPoint text_offset = aText->GetTextPos() + aText->GetSchematicTextOffset();
|
||||
VECTOR2D text_offset = aText->GetTextPos() + aText->GetSchematicTextOffset();
|
||||
wxString shownText( aText->GetShownText() );
|
||||
|
||||
if( drawingShadows )
|
||||
{
|
||||
switch( aText->GetLabelSpinStyle() )
|
||||
{
|
||||
case 0:
|
||||
if( aText->Type() == SCH_LABEL_T || aText->Type() == SCH_TEXT_T )
|
||||
text_offset.x -= getShadowWidth() / 2;
|
||||
else
|
||||
text_offset.x += getShadowWidth() / 2;
|
||||
break;
|
||||
case 1:
|
||||
text_offset.y += getShadowWidth() / 2;
|
||||
break;
|
||||
case 2:
|
||||
if( aText->Type() == SCH_LABEL_T || aText->Type() == SCH_TEXT_T )
|
||||
text_offset.x += getShadowWidth() / 2;
|
||||
else
|
||||
text_offset.x -= getShadowWidth() / 2;
|
||||
break;
|
||||
case 3:
|
||||
text_offset.y -= getShadowWidth() / 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( !shownText.IsEmpty() )
|
||||
m_gal->StrokeText( shownText, text_offset, aText->GetTextAngleRadians() );
|
||||
|
||||
|
@ -1446,6 +1474,20 @@ void SCH_PAINTER::draw( SCH_SHEET *aSheet, int aLayer )
|
|||
if( aSheet->IsVerticalOrientation() )
|
||||
nameAngle = M_PI/2;
|
||||
|
||||
if( drawingShadows )
|
||||
{
|
||||
if( aSheet->IsVerticalOrientation() )
|
||||
{
|
||||
pos_sheetname.y += getShadowWidth() / 2;
|
||||
pos_filename.y += getShadowWidth() / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
pos_sheetname.x -= getShadowWidth() / 2;
|
||||
pos_filename.x -= getShadowWidth() / 2;
|
||||
}
|
||||
}
|
||||
|
||||
m_gal->SetStrokeColor( getRenderColor( aSheet, LAYER_SHEETNAME, drawingShadows ) );
|
||||
|
||||
auto text = wxT( "Sheet: " ) + aSheet->GetName();
|
||||
|
|
|
@ -389,7 +389,7 @@ int SCH_SHEET::GetPenSize() const
|
|||
wxPoint SCH_SHEET::GetSheetNamePosition()
|
||||
{
|
||||
wxPoint pos = m_pos;
|
||||
int margin = KiROUND( GetPenSize() / 2.0 + 4 + m_sheetNameSize * 0.3 );
|
||||
int margin = KiROUND( GetPenSize() / 2.0 + 4 + m_sheetNameSize * 0.3 );
|
||||
|
||||
if( IsVerticalOrientation() )
|
||||
{
|
||||
|
|
|
@ -861,7 +861,7 @@ void SCH_GLOBALLABEL::CreateGraphicShape( std::vector <wxPoint>& aPoints, const
|
|||
#define OVERBAR_V_MARGIN 1.2
|
||||
// Note: this factor is due to the fact we need a margin for the graphic symbol.
|
||||
if( hasOverBar )
|
||||
y = KiROUND( KIGFX::STROKE_FONT::GetInterline( halfSize, linewidth ) * OVERBAR_V_MARGIN );
|
||||
y = KiROUND( KIGFX::STROKE_FONT::GetInterline( halfSize ) * OVERBAR_V_MARGIN );
|
||||
|
||||
// Gives room for line thickess and margin
|
||||
y += linewidth; // for line thickess
|
||||
|
|
|
@ -324,17 +324,11 @@ public:
|
|||
/**
|
||||
* Return the distance between two lines of text.
|
||||
*
|
||||
* <p>
|
||||
* Calculates the distance (pitch) between two lines of text. This distance includes the
|
||||
* interline distance plus room for characters like j, {, and [. It also used for single
|
||||
* line text, to calculate the text bounding box.
|
||||
* </p>
|
||||
*
|
||||
* @param aTextThickness Overrides the current thickness when greater than 0.
|
||||
* this is needed when the current m_Thickness is 0 and a default line thickness
|
||||
* is used
|
||||
*/
|
||||
int GetInterline( int aTextThickness = -1 ) const;
|
||||
int GetInterline() const;
|
||||
|
||||
/**
|
||||
* Function GetTextStyleName
|
||||
|
|
|
@ -108,10 +108,9 @@ public:
|
|||
* @brief Compute the distance (interline) between 2 lines of text (for multiline texts).
|
||||
*
|
||||
* @param aGlyphHeight is the height (vertical size) of the text.
|
||||
* @param aGlyphThickness is the thickness of the lines used to draw the text.
|
||||
* @return the interline.
|
||||
*/
|
||||
static double GetInterline( double aGlyphHeight, double aGlyphThickness );
|
||||
static double GetInterline( double aGlyphHeight );
|
||||
|
||||
|
||||
|
||||
|
@ -136,13 +135,6 @@ private:
|
|||
*/
|
||||
double computeOverbarVerticalPosition() const;
|
||||
|
||||
/**
|
||||
* @brief Returns a single line height using current settings.
|
||||
*
|
||||
* @return The line height.
|
||||
*/
|
||||
int getInterline() const;
|
||||
|
||||
/**
|
||||
* @brief Compute the bounding box of a given glyph.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue