+ fprintf( m_pstream, "(" );
+ const wxWX2MBbuf textbuf = text.mb_str();
+ size_t len = strlen(textbuf);
+ for (i = 0; i < len; i++)
+ {
+ int c = (unsigned char) textbuf[i];
+ if (c == ')' || c == '(' || c == '\\')
+ {
+ /* Cope with special characters */
+ fprintf( m_pstream, "\\" );
+ fputc(c, m_pstream);
+ }
+ else if ( c >= 128 )
+ {
+ /* Cope with character codes > 127 */
+ fprintf(m_pstream, "\\%o", c);
+ }
+ else
+ {
+ fputc(c, m_pstream);
+ }
+ }
+
+ fprintf( m_pstream, ") show\n" );
+
+ sprintf( buffer, "%.8f rotate\n", -angle );
+ for (i = 0; i < 100; i++)
+ if (buffer[i] == ',') buffer[i] = '.';
+ fprintf( m_pstream, buffer );
+
+ if (m_font.GetUnderlined())
+ {
+ wxCoord uy = (wxCoord)(y + size - m_underlinePosition);
+ wxCoord w, h;
+ char buffer[100];
+ GetTextExtent(text, &w, &h);
+
+ sprintf( buffer,
+ "gsave\n"
+ "%d %d moveto\n"
+ "%f setlinewidth\n"
+ "%d %d lineto\n"
+ "stroke\n"
+ "grestore\n",
+ LogicalToDeviceX(x), LogicalToDeviceY(uy),
+ m_underlineThickness,
+ LogicalToDeviceX(x + w), LogicalToDeviceY(uy) );
+ for (i = 0; i < 100; i++)
+ if (buffer[i] == ',') buffer[i] = '.';
+ fprintf( m_pstream, buffer );
+ }
+
+ CalcBoundingBox( x, y );
+ CalcBoundingBox( x + size * text.Length() * 2/3 , y );
+}
+
+void wxPostScriptDC::SetBackground (const wxBrush& brush)
+{
+ m_backgroundBrush = brush;
+}
+
+void wxPostScriptDC::SetLogicalFunction (int WXUNUSED(function))
+{
+ wxFAIL_MSG( wxT("wxPostScriptDC::SetLogicalFunction not implemented.") );
+}
+
+void wxPostScriptDC::DoDrawSpline( wxList *points )
+{
+ wxCHECK_RET( m_ok && m_pstream, wxT("invalid postscript dc") );
+
+ SetPen( m_pen );
+
+ double a, b, c, d, x1, y1, x2, y2, x3, y3;
+ wxPoint *p, *q;
+
+ wxNode *node = points->First();
+ p = (wxPoint *)node->Data();
+ x1 = p->x;
+ y1 = p->y;
+
+ node = node->Next();
+ p = (wxPoint *)node->Data();
+ c = p->x;
+ d = p->y;
+ x3 = a = (double)(x1 + c) / 2;
+ y3 = b = (double)(y1 + d) / 2;
+
+ fprintf( m_pstream,
+ "newpath\n"
+ "%d %d moveto\n"
+ "%d %d lineto\n",
+ LogicalToDeviceX((wxCoord)x1), LogicalToDeviceY((wxCoord)y1),
+ LogicalToDeviceX((wxCoord)x3), LogicalToDeviceY((wxCoord)y3) );
+
+ CalcBoundingBox( (wxCoord)x1, (wxCoord)y1 );
+ CalcBoundingBox( (wxCoord)x3, (wxCoord)y3 );
+
+ while ((node = node->Next()) != NULL)
+ {
+ q = (wxPoint *)node->Data();
+
+ x1 = x3;
+ y1 = y3;
+ x2 = c;
+ y2 = d;
+ c = q->x;
+ d = q->y;
+ x3 = (double)(x2 + c) / 2;
+ y3 = (double)(y2 + d) / 2;
+
+ fprintf( m_pstream,
+ "%d %d %d %d %d %d DrawSplineSection\n",
+ LogicalToDeviceX((wxCoord)x1), LogicalToDeviceY((wxCoord)y1),
+ LogicalToDeviceX((wxCoord)x2), LogicalToDeviceY((wxCoord)y2),
+ LogicalToDeviceX((wxCoord)x3), LogicalToDeviceY((wxCoord)y3) );
+
+ CalcBoundingBox( (wxCoord)x1, (wxCoord)y1 );
+ CalcBoundingBox( (wxCoord)x3, (wxCoord)y3 );
+ }
+
+ /*
+ At this point, (x2,y2) and (c,d) are the position of the
+ next-to-last and last point respectively, in the point list
+ */
+
+ fprintf( m_pstream,
+ "%d %d lineto\n"
+ "stroke\n",
+ LogicalToDeviceX((wxCoord)c), LogicalToDeviceY((wxCoord)d) );
+}
+
+wxCoord wxPostScriptDC::GetCharWidth() const
+{
+ // Chris Breeze: reasonable approximation using wxMODERN/Courier
+ return (wxCoord) (GetCharHeight() * 72.0 / 120.0);