Fixed vertical alignment for strings that contain a newline character at the end (GAL).
This commit is contained in:
parent
fb0045a898
commit
0304598a71
|
@ -40,7 +40,8 @@ STROKE_FONT::STROKE_FONT( GAL* aGal ) :
|
|||
m_gal( aGal ),
|
||||
m_bold( false ),
|
||||
m_italic( false ),
|
||||
m_mirrored( false )
|
||||
m_mirrored( false ),
|
||||
m_overbar( false )
|
||||
{
|
||||
// Default values
|
||||
m_glyphSize = VECTOR2D( 10.0, 10.0 );
|
||||
|
@ -149,6 +150,9 @@ BOX2D STROKE_FONT::computeBoundingBox( const GLYPH& aGLYPH, const VECTOR2D& aGLY
|
|||
|
||||
void STROKE_FONT::Draw( const UTF8& aText, const VECTOR2D& aPosition, double aRotationAngle )
|
||||
{
|
||||
if( aText.empty() )
|
||||
return;
|
||||
|
||||
// Context needs to be saved before any transformations
|
||||
m_gal->Save();
|
||||
|
||||
|
|
|
@ -189,17 +189,13 @@ private:
|
|||
* @param aText is the text to be checked.
|
||||
* @return unsigned - The number of lines in aText.
|
||||
*/
|
||||
unsigned linesCount( const UTF8& aText ) const
|
||||
inline unsigned linesCount( const UTF8& aText ) const
|
||||
{
|
||||
unsigned lines = 1;
|
||||
|
||||
for( UTF8::const_iterator it = aText.begin(), itEnd = aText.end(); it != itEnd; ++it )
|
||||
{
|
||||
if( *it == '\n' )
|
||||
++lines;
|
||||
}
|
||||
|
||||
return lines;
|
||||
if( aText.empty() )
|
||||
return 0; // std::count does not work well with empty strings
|
||||
else
|
||||
// aText.end() - 1 is to skip a newline character that is potentially at the end
|
||||
return std::count( aText.begin(), aText.end() - 1, '\n' ) + 1;
|
||||
}
|
||||
|
||||
///> Factor that determines relative height of overbar.
|
||||
|
@ -208,7 +204,7 @@ private:
|
|||
///> Factor that determines relative line width for bold text.
|
||||
static const double BOLD_FACTOR;
|
||||
|
||||
///> Scale factor for the glyph
|
||||
///> Scale factor for a glyph
|
||||
static const double HERSHEY_SCALE;
|
||||
};
|
||||
} // namespace KIGFX
|
||||
|
|
Loading…
Reference in New Issue