Fixed multiline vertical strings drawing bug.
This commit is contained in:
parent
6c3534bd35
commit
58280f749a
|
@ -140,21 +140,6 @@ BOX2D STROKE_FONT::computeBoundingBox( const Glyph& aGlyph, const VECTOR2D& aGly
|
||||||
|
|
||||||
void STROKE_FONT::Draw( std::string aText, const VECTOR2D& aPosition, double aRotationAngle )
|
void STROKE_FONT::Draw( std::string aText, const VECTOR2D& aPosition, double aRotationAngle )
|
||||||
{
|
{
|
||||||
// Split multiline strings into separate ones and draw line by line
|
|
||||||
size_t newlinePos = aText.find( '\n' );
|
|
||||||
|
|
||||||
if( newlinePos != std::string::npos )
|
|
||||||
{
|
|
||||||
VECTOR2D nextlinePosition( aPosition );
|
|
||||||
nextlinePosition += VECTOR2D( 0.0, m_glyphSize.y * 1.6 ); // FIXME remove magic number
|
|
||||||
|
|
||||||
Draw( aText.substr( newlinePos + 1 ), nextlinePosition, aRotationAngle );
|
|
||||||
aText = aText.substr( 0, newlinePos );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Compute the text size
|
|
||||||
VECTOR2D textsize = computeTextSize( aText );
|
|
||||||
|
|
||||||
// By default overbar is turned off
|
// By default overbar is turned off
|
||||||
m_overbar = false;
|
m_overbar = false;
|
||||||
|
|
||||||
|
@ -164,6 +149,20 @@ void STROKE_FONT::Draw( std::string aText, const VECTOR2D& aPosition, double aRo
|
||||||
m_gal->Translate( aPosition );
|
m_gal->Translate( aPosition );
|
||||||
m_gal->Rotate( -aRotationAngle );
|
m_gal->Rotate( -aRotationAngle );
|
||||||
|
|
||||||
|
// Split multiline strings into separate ones and draw them line by line
|
||||||
|
size_t newlinePos = aText.find( '\n' );
|
||||||
|
|
||||||
|
if( newlinePos != std::string::npos )
|
||||||
|
{
|
||||||
|
VECTOR2D nextlinePosition = VECTOR2D( 0.0, m_glyphSize.y * LINE_HEIGHT_RATIO );
|
||||||
|
|
||||||
|
Draw( aText.substr( newlinePos + 1 ), nextlinePosition, 0.0 );
|
||||||
|
aText = aText.substr( 0, newlinePos );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compute the text size
|
||||||
|
VECTOR2D textsize = computeTextSize( aText );
|
||||||
|
|
||||||
// Adjust the text position to the given alignment
|
// Adjust the text position to the given alignment
|
||||||
switch( m_horizontalJustify )
|
switch( m_horizontalJustify )
|
||||||
{
|
{
|
||||||
|
|
|
@ -181,6 +181,8 @@ private:
|
||||||
* @return is the text size.
|
* @return is the text size.
|
||||||
*/
|
*/
|
||||||
VECTOR2D computeTextSize( const std::string& aText ) const;
|
VECTOR2D computeTextSize( const std::string& aText ) const;
|
||||||
|
|
||||||
|
static const double LINE_HEIGHT_RATIO = 1.6;
|
||||||
};
|
};
|
||||||
} // namespace KiGfx
|
} // namespace KiGfx
|
||||||
|
|
||||||
|
|
|
@ -599,6 +599,9 @@ void PCB_PAINTER::draw( const DRAWSEGMENT* aSegment )
|
||||||
|
|
||||||
void PCB_PAINTER::draw( const TEXTE_PCB* aText )
|
void PCB_PAINTER::draw( const TEXTE_PCB* aText )
|
||||||
{
|
{
|
||||||
|
if( aText->GetText().Length() == 0 )
|
||||||
|
return;
|
||||||
|
|
||||||
COLOR4D strokeColor = getLayerColor( aText->GetLayer(), 0 );
|
COLOR4D strokeColor = getLayerColor( aText->GetLayer(), 0 );
|
||||||
VECTOR2D position( aText->GetTextPosition().x, aText->GetTextPosition().y );
|
VECTOR2D position( aText->GetTextPosition().x, aText->GetTextPosition().y );
|
||||||
double orientation = aText->GetOrientation() * M_PI / 1800.0;
|
double orientation = aText->GetOrientation() * M_PI / 1800.0;
|
||||||
|
@ -612,6 +615,9 @@ void PCB_PAINTER::draw( const TEXTE_PCB* aText )
|
||||||
|
|
||||||
void PCB_PAINTER::draw( const TEXTE_MODULE* aText, int aLayer )
|
void PCB_PAINTER::draw( const TEXTE_MODULE* aText, int aLayer )
|
||||||
{
|
{
|
||||||
|
if( aText->GetLength() == 0 )
|
||||||
|
return;
|
||||||
|
|
||||||
COLOR4D strokeColor = getLayerColor( aLayer, 0 );
|
COLOR4D strokeColor = getLayerColor( aLayer, 0 );
|
||||||
VECTOR2D position( aText->GetTextPosition().x, aText->GetTextPosition().y);
|
VECTOR2D position( aText->GetTextPosition().x, aText->GetTextPosition().y);
|
||||||
double orientation = aText->GetDrawRotation() * M_PI / 1800.0;
|
double orientation = aText->GetDrawRotation() * M_PI / 1800.0;
|
||||||
|
|
Loading…
Reference in New Issue