Fixes: lp:1629387 (pagelayout text sometimes shrinking)
https://bugs.launchpad.net/kicad/+bug/1629387
This commit is contained in:
parent
e0fb7f89f4
commit
fdebcd8a6d
|
@ -409,7 +409,7 @@ VECTOR2D STROKE_FONT::ComputeStringBoundaryLimits( const UTF8& aText, VECTOR2D a
|
||||||
double aGlyphThickness,
|
double aGlyphThickness,
|
||||||
double* aTopLimit, double* aBottomLimit ) const
|
double* aTopLimit, double* aBottomLimit ) const
|
||||||
{
|
{
|
||||||
VECTOR2D result = VECTOR2D( 0.0, m_gal->GetGlyphSize().y );
|
VECTOR2D string_bbox;
|
||||||
double ymax = 0.0;
|
double ymax = 0.0;
|
||||||
double ymin = 0.0;
|
double ymin = 0.0;
|
||||||
|
|
||||||
|
@ -434,7 +434,7 @@ VECTOR2D STROKE_FONT::ComputeStringBoundaryLimits( const UTF8& aText, VECTOR2D a
|
||||||
|
|
||||||
const BOX2D& box = m_glyphBoundingBoxes[dd];
|
const BOX2D& box = m_glyphBoundingBoxes[dd];
|
||||||
|
|
||||||
result.x += box.GetEnd().x;
|
string_bbox.x += box.GetEnd().x;
|
||||||
|
|
||||||
// Calculate Y min and Y max
|
// Calculate Y min and Y max
|
||||||
if( aTopLimit )
|
if( aTopLimit )
|
||||||
|
@ -450,12 +450,13 @@ VECTOR2D STROKE_FONT::ComputeStringBoundaryLimits( const UTF8& aText, VECTOR2D a
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result.x *= aGlyphSize.x;
|
string_bbox.x *= aGlyphSize.x;
|
||||||
result.x += aGlyphThickness;
|
string_bbox.x += aGlyphThickness;
|
||||||
|
string_bbox.y = aGlyphSize.y + aGlyphThickness;
|
||||||
|
|
||||||
// For italic correction, take in account italic tilt
|
// For italic correction, take in account italic tilt
|
||||||
if( m_gal->IsFontItalic() )
|
if( m_gal->IsFontItalic() )
|
||||||
result.x += result.y * STROKE_FONT::ITALIC_TILT;
|
string_bbox.x += string_bbox.y * STROKE_FONT::ITALIC_TILT;
|
||||||
|
|
||||||
if( aTopLimit )
|
if( aTopLimit )
|
||||||
*aTopLimit = ymax * aGlyphSize.y;
|
*aTopLimit = ymax * aGlyphSize.y;
|
||||||
|
@ -463,5 +464,5 @@ VECTOR2D STROKE_FONT::ComputeStringBoundaryLimits( const UTF8& aText, VECTOR2D a
|
||||||
if( aBottomLimit )
|
if( aBottomLimit )
|
||||||
*aBottomLimit = ymin * aGlyphSize.y;
|
*aBottomLimit = ymin * aGlyphSize.y;
|
||||||
|
|
||||||
return result;
|
return string_bbox;
|
||||||
}
|
}
|
||||||
|
|
|
@ -537,14 +537,15 @@ void WORKSHEET_DATAITEM_TEXT::SetConstrainedTextSize()
|
||||||
|
|
||||||
if( m_BoundingBoxSize.x || m_BoundingBoxSize.y )
|
if( m_BoundingBoxSize.x || m_BoundingBoxSize.y )
|
||||||
{
|
{
|
||||||
int linewidth = 0;
|
|
||||||
// to know the X and Y size of the line, we should use
|
// to know the X and Y size of the line, we should use
|
||||||
// EDA_TEXT::GetTextBox()
|
// EDA_TEXT::GetTextBox()
|
||||||
// but this function uses integers
|
// but this function uses integers
|
||||||
// So, to avoid truncations with our unit in mm, use microns.
|
// So, to avoid truncations with our unit in mm, use microns.
|
||||||
wxSize size_micron;
|
wxSize size_micron;
|
||||||
size_micron.x = KiROUND( m_ConstrainedTextSize.x * 1000.0 );
|
#define FSCALE 1000.0
|
||||||
size_micron.y = KiROUND( m_ConstrainedTextSize.y * 1000.0 );
|
int linewidth = 0;
|
||||||
|
size_micron.x = KiROUND( m_ConstrainedTextSize.x * FSCALE );
|
||||||
|
size_micron.y = KiROUND( m_ConstrainedTextSize.y * FSCALE );
|
||||||
WS_DRAW_ITEM_TEXT dummy( WS_DRAW_ITEM_TEXT( this, this->m_FullText,
|
WS_DRAW_ITEM_TEXT dummy( WS_DRAW_ITEM_TEXT( this, this->m_FullText,
|
||||||
wxPoint(0,0),
|
wxPoint(0,0),
|
||||||
size_micron,
|
size_micron,
|
||||||
|
@ -552,10 +553,11 @@ void WORKSHEET_DATAITEM_TEXT::SetConstrainedTextSize()
|
||||||
IsItalic(), IsBold() ) );
|
IsItalic(), IsBold() ) );
|
||||||
dummy.SetMultilineAllowed( true );
|
dummy.SetMultilineAllowed( true );
|
||||||
TransfertSetupToGraphicText( &dummy );
|
TransfertSetupToGraphicText( &dummy );
|
||||||
|
|
||||||
EDA_RECT rect = dummy.GetTextBox();
|
EDA_RECT rect = dummy.GetTextBox();
|
||||||
DSIZE size;
|
DSIZE size;
|
||||||
size.x = rect.GetWidth() / 1000.0;
|
size.x = rect.GetWidth() / FSCALE;
|
||||||
size.y = rect.GetHeight() / 1000.0;
|
size.y = rect.GetHeight() / FSCALE;
|
||||||
|
|
||||||
if( m_BoundingBoxSize.x && size.x > m_BoundingBoxSize.x )
|
if( m_BoundingBoxSize.x && size.x > m_BoundingBoxSize.x )
|
||||||
m_ConstrainedTextSize.x *= m_BoundingBoxSize.x / size.x;
|
m_ConstrainedTextSize.x *= m_BoundingBoxSize.x / size.x;
|
||||||
|
|
|
@ -163,12 +163,12 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
|
||||||
if( jj && ! wsText->IsInsidePage( jj ) )
|
if( jj && ! wsText->IsInsidePage( jj ) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Append( gtext = new WS_DRAW_ITEM_TEXT( wsText, wsText->m_FullText,
|
gtext = new WS_DRAW_ITEM_TEXT( wsText, wsText->m_FullText,
|
||||||
wsText->GetStartPosUi( jj ),
|
wsText->GetStartPosUi( jj ),
|
||||||
textsize,
|
textsize, pensize, color,
|
||||||
pensize, color,
|
|
||||||
wsText->IsItalic(),
|
wsText->IsItalic(),
|
||||||
wsText->IsBold() ) );
|
wsText->IsBold() );
|
||||||
|
Append( gtext );
|
||||||
gtext->SetMultilineAllowed( multilines );
|
gtext->SetMultilineAllowed( multilines );
|
||||||
wsText->TransfertSetupToGraphicText( gtext );
|
wsText->TransfertSetupToGraphicText( gtext );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue