diff --git a/common/plotters/PDF_plotter.cpp b/common/plotters/PDF_plotter.cpp index 19ea834d25..1e982b6caf 100644 --- a/common/plotters/PDF_plotter.cpp +++ b/common/plotters/PDF_plotter.cpp @@ -1567,10 +1567,11 @@ void PDF_PLOTTER::Text( const VECTOR2I& aPos, double wideningFactor, heightFactor; VECTOR2I t_size( std::abs( aSize.x ), std::abs( aSize.y ) ); + bool textMirrored = aSize.x < 0; - computeTextParameters( aPos, aText, aOrient, t_size, m_plotMirror, aH_justify, - aV_justify, aWidth, aItalic, aBold, &wideningFactor, &ctm_a, - &ctm_b, &ctm_c, &ctm_d, &ctm_e, &ctm_f, &heightFactor ); + computeTextParameters( aPos, aText, aOrient, t_size, textMirrored, aH_justify, aV_justify, + aWidth, aItalic, aBold, &wideningFactor, &ctm_a, &ctm_b, &ctm_c, &ctm_d, + &ctm_e, &ctm_f, &heightFactor ); SetColor( aColor ); SetCurrentLineWidth( aWidth, aData ); @@ -1583,6 +1584,10 @@ void PDF_PLOTTER::Text( const VECTOR2I& aPos, VECTOR2I full_box( aFont->StringBoundaryLimits( aText, t_size, aWidth, aBold, aItalic, aFontMetrics ) ); + + if( textMirrored ) + full_box.x *= -1; + VECTOR2I box_x( full_box.x, 0 ); VECTOR2I box_y( 0, full_box.y ); @@ -1603,14 +1608,18 @@ void PDF_PLOTTER::Text( const VECTOR2I& aPos, { wxString word = str_tok.GetNextToken(); - computeTextParameters( pos, word, aOrient, t_size, m_plotMirror, GR_TEXT_H_ALIGN_LEFT, - GR_TEXT_V_ALIGN_BOTTOM, aWidth, aItalic, aBold, &wideningFactor, &ctm_a, - &ctm_b, &ctm_c, &ctm_d, &ctm_e, &ctm_f, &heightFactor ); + computeTextParameters( pos, word, aOrient, t_size, textMirrored, GR_TEXT_H_ALIGN_LEFT, + GR_TEXT_V_ALIGN_BOTTOM, aWidth, aItalic, aBold, &wideningFactor, + &ctm_a, &ctm_b, &ctm_c, &ctm_d, &ctm_e, &ctm_f, &heightFactor ); // Extract the changed width and rotate by the orientation to get the offset for the // next word VECTOR2I bbox( aFont->StringBoundaryLimits( word, t_size, aWidth, aBold, aItalic, aFontMetrics ).x, 0 ); + + if( textMirrored ) + bbox.x *= -1; + RotatePoint( bbox, aOrient ); pos += bbox; diff --git a/common/plotters/PS_plotter.cpp b/common/plotters/PS_plotter.cpp index 981789fe72..7de0d20bba 100644 --- a/common/plotters/PS_plotter.cpp +++ b/common/plotters/PS_plotter.cpp @@ -374,7 +374,7 @@ void PSLIKE_PLOTTER::computeTextParameters( const VECTOR2I& aPos, // This is an approximation of the text bounds (in IUs) int tw = returnPostscriptTextWidth( aText, aSize.x, aItalic, aWidth ); int th = aSize.y; - int dx, dy; + int dx = 0, dy = 0; switch( aH_justify ) { @@ -401,7 +401,7 @@ void PSLIKE_PLOTTER::computeTextParameters( const VECTOR2I& aPos, *wideningFactor = sz_dev.x / sz_dev.y; // Mirrored texts must be plotted as mirrored! - if( m_plotMirror ) + if( m_plotMirror ^ aMirror ) *wideningFactor = -*wideningFactor; // The CTM transformation matrix