Modified STROKE_FONT::ComputeStringBoundaryLimits() to process multiline strings

Removed a declaration of a not existing method (STROKE_FONT::ComputeTextLineSize()).

Fixes: lp:1747967
* https://bugs.launchpad.net/kicad/+bug/1747967
This commit is contained in:
Maciej Suminski 2018-03-08 10:54:45 +01:00
parent b3601bd540
commit 9ce768c29a
2 changed files with 19 additions and 45 deletions

View File

@ -397,18 +397,22 @@ VECTOR2D STROKE_FONT::computeTextLineSize( const UTF8& aText ) const
}
VECTOR2D STROKE_FONT::ComputeStringBoundaryLimits( const UTF8& aText, VECTOR2D aGlyphSize,
double aGlyphThickness,
double* aTopLimit, double* aBottomLimit ) const
VECTOR2D STROKE_FONT::ComputeStringBoundaryLimits( const UTF8& aText, const VECTOR2D& aGlyphSize,
double aGlyphThickness ) const
{
VECTOR2D string_bbox;
double ymax = 0.0;
double ymin = 0.0;
int line_count = 1;
double maxX = 0.0, curX = 0.0;
for( UTF8::uni_iter it = aText.ubegin(), end = aText.uend(); it < end; ++it )
{
wxASSERT_MSG( *it != '\n',
wxT( "This function is intended to work with single line strings" ) );
if( *it == '\n' )
{
curX = 0.0;
maxX = std::max( maxX, curX );
++line_count;
continue;
}
// If it is double tilda, then it is displayed as a single tilda
// If it is single tilda, then it is toggling overbar, so we need to skip it
@ -425,36 +429,17 @@ VECTOR2D STROKE_FONT::ComputeStringBoundaryLimits( const UTF8& aText, VECTOR2D a
dd = '?' - ' ';
const BOX2D& box = m_glyphBoundingBoxes[dd];
string_bbox.x += box.GetEnd().x;
// Calculate Y min and Y max
if( aTopLimit )
{
ymax = std::max( ymax, box.GetY() );
ymax = std::max( ymax, box.GetEnd().y );
}
if( aBottomLimit )
{
ymin = std::min( ymin, box.GetY() );
ymin = std::min( ymin, box.GetEnd().y );
}
curX += box.GetEnd().x;
}
string_bbox.x = std::max( maxX, curX );
string_bbox.x *= aGlyphSize.x;
string_bbox.x += aGlyphThickness;
string_bbox.y = aGlyphSize.y + aGlyphThickness;
string_bbox.y = line_count * GetInterline( aGlyphSize.y, aGlyphThickness );
// For italic correction, take in account italic tilt
if( m_gal->IsFontItalic() )
string_bbox.x += string_bbox.y * STROKE_FONT::ITALIC_TILT;
if( aTopLimit )
*aTopLimit = ymax * aGlyphSize.y;
if( aBottomLimit )
*aBottomLimit = ymin * aGlyphSize.y;
return string_bbox;
}

View File

@ -87,24 +87,13 @@ public:
}
/**
* Compute the boundary limits of aText (the bbox of all shapes).
* The overbar is not taken in account, by ~ are skipped.
* @return a VECTOR2D giving the h size of line, and the V glyph size
* and ( if aTopLimit or aBottomLimit not NULL ) the top and bottom
* limits of the text.
*/
VECTOR2D ComputeStringBoundaryLimits( const UTF8& aText, VECTOR2D aGlyphSize,
double aGlyphThickness,
double* aTopLimit = NULL, double* aBottomLimit = NULL ) const;
/**
* @brief Compute the X and Y size of a given text. The text is expected to be
* a only one line text.
* Compute the boundary limits of aText (the bounding box of all shapes).
* The overbar and alignment are not taken in account, '~' characters are skipped.
*
* @param aText is the text string (one line).
* @return the text size.
* @return a VECTOR2D giving the width and height of text.
*/
VECTOR2D ComputeTextLineSize( const UTF8& aText ) const;
VECTOR2D ComputeStringBoundaryLimits( const UTF8& aText, const VECTOR2D& aGlyphSize,
double aGlyphThickness ) const;
/**
* Compute the vertical position of an overbar, sometimes used in texts.