From e3c3a0f18819e6af6807ce2fff2761cf20e24426 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sun, 22 Jan 2017 13:05:03 +0100 Subject: [PATCH] Fix calculating position of rotated text (wxPostScriptDC) Given top-left position of the drawn text should be converted to the bottom-left position, taking into account rotation angle. Closes #10940 --- src/generic/dcpsg.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/generic/dcpsg.cpp b/src/generic/dcpsg.cpp index 1754ac83a9..1bb1ce14f4 100644 --- a/src/generic/dcpsg.cpp +++ b/src/generic/dcpsg.cpp @@ -1464,10 +1464,16 @@ void wxPostScriptDCImpl::DoDrawRotatedText( const wxString& text, wxCoord x, wxC } } + // Calculate bottom-left coordinates of the rotated text + wxCoord text_descent; + GetOwner()->GetTextExtent(text, NULL, NULL, &text_descent); int size = m_font.GetPointSize(); + double rad = wxDegToRad(angle); + wxCoord bx = wxRound(x + (size - text_descent) * sin(rad)); + wxCoord by = wxRound(y + (size - text_descent) * cos(rad)); wxString buffer; - buffer.Printf( "%f %f moveto\n", XLOG2DEV(x), YLOG2DEV(y)); + buffer.Printf( "%f %f moveto\n", XLOG2DEV(bx), YLOG2DEV(by)); buffer.Replace( ",", "." ); PsPrint( buffer );