+void wxPostScriptDC::DoDrawText( const wxString& text, wxCoord x, wxCoord y )
+{
+ wxCHECK_RET( m_ok && m_pstream, wxT("invalid postscript dc") );
+
+ wxCoord text_w, text_h, text_descent;
+
+ GetTextExtent(text, &text_w, &text_h, &text_descent);
+
+ SetFont( m_font );
+
+ if (m_textForegroundColour.Ok())
+ {
+ unsigned char red = m_textForegroundColour.Red();
+ unsigned char blue = m_textForegroundColour.Blue();
+ unsigned char green = m_textForegroundColour.Green();
+
+ if (!m_colour)
+ {
+ // Anything not white is black
+ if (! (red == (unsigned char) 255 &&
+ blue == (unsigned char) 255 &&
+ green == (unsigned char) 255))
+ {
+ red = (unsigned char) 0;
+ green = (unsigned char) 0;
+ blue = (unsigned char) 0;
+ }
+ }
+
+ // maybe setgray here ?
+ if (!(red == m_currentRed && green == m_currentGreen && blue == m_currentBlue))
+ {
+ double redPS = (double)(red) / 255.0;
+ double bluePS = (double)(blue) / 255.0;
+ double greenPS = (double)(green) / 255.0;
+
+ fprintf( m_pstream,
+ "%.8f %.8f %.8f setrgbcolor\n",
+ redPS, greenPS, bluePS );
+
+ m_currentRed = red;
+ m_currentBlue = blue;
+ m_currentGreen = green;
+ }
+ }
+
+ int size = m_font.GetPointSize();
+
+// wxCoord by = y + (wxCoord)floor( double(size) * 2.0 / 3.0 ); // approximate baseline
+// commented by V. Slavik and replaced by accurate version
+// - note that there is still rounding error in text_descent!
+ wxCoord by = y + size - text_descent; // baseline
+ fprintf( m_pstream, "%d %d moveto\n", XLOG2DEV(x), YLOG2DEV(by) );
+
+ /* I don't know how to write char to a stream, so I use a mini string */
+ char tmpbuf[2];
+ tmpbuf[1] = 0;
+
+ fprintf( m_pstream, "(" );
+ const wxWX2MBbuf textbuf = text.mb_str();
+ int len = strlen(textbuf);
+ int i;
+ for (i = 0; i < len; i++)
+ {
+ int c = (unsigned char) textbuf[i];
+ if (c == ')' || c == '(' || c == '\\')
+ {
+ /* Cope with special characters */
+ fprintf( m_pstream, "\\" );
+ tmpbuf[0] = (char) c;
+ fprintf( m_pstream, tmpbuf );
+ }
+ else if ( c >= 128 )
+ {
+ /* Cope with character codes > 127 */
+ fprintf(m_pstream, "\\%o", c);
+ }
+ else
+ {
+ tmpbuf[0] = (char) c;
+ fprintf( m_pstream, tmpbuf );
+ }
+ }
+
+ fprintf( m_pstream, ") show\n" );
+
+ if (m_font.GetUnderlined())
+ {
+ wxCoord uy = (wxCoord)(y + size - m_underlinePosition);
+
+ fprintf( m_pstream,
+ "gsave\n"
+ "%d %d moveto\n"
+ "%d setlinewidth\n"
+ "%d %d lineto\n"
+ "stroke\n"
+ "grestore\n",
+ XLOG2DEV(x), YLOG2DEV(uy),
+ (wxCoord)m_underlineThickness,
+ XLOG2DEV(x + text_w), YLOG2DEV(uy) );
+ }
+
+ CalcBoundingBox( x, y );
+ CalcBoundingBox( x + size * text.Length() * 2/3 , y );
+}
+
+void wxPostScriptDC::DoDrawRotatedText( const wxString& text, wxCoord x, wxCoord y, double angle )