kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #24815
[PATCH] GAL: Fix offset problem in multiline text rendering
Commit BZR 6703 introduced a minor horizontal adjustment for stroke
text rendering in GAL, but the Translate() call was done before
calling Save(). So, when this function was called multiple times a
residual offset carried over to each subsequent line.
---
common/gal/stroke_font.cpp | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/common/gal/stroke_font.cpp b/common/gal/stroke_font.cpp
index dc3c24a..c51b977 100644
--- a/common/gal/stroke_font.cpp
+++ b/common/gal/stroke_font.cpp
@@ -255,6 +255,9 @@ void STROKE_FONT::drawSingleLineText( const UTF8& aText )
VECTOR2D textSize = computeTextLineSize( aText );
double half_thickness = m_gal->GetLineWidth()/2;
+ // Context needs to be saved before any transformations
+ m_gal->Save();
+
// First adjust: the text X position is corrected by half_thickness
// because when the text with thickness is draw, its full size is textSize,
// but the position of lines is half_thickness to textSize - half_thickness
@@ -262,8 +265,6 @@ void STROKE_FONT::drawSingleLineText( const UTF8& aText )
// to place the text inside the 0 to textSize X area.
m_gal->Translate( VECTOR2D( half_thickness, 0 ) );
- m_gal->Save();
-
// Adjust the text position to the given horizontal justification
switch( m_gal->GetHorizontalJustify() )
{
Follow ups