1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/generic/dcpsg.cpp
3 // Purpose: Generic wxPostScriptDC implementation
4 // Author: Julian Smart, Robert Roebling, Markus Holzhem
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
18 #if wxUSE_PRINTING_ARCHITECTURE && wxUSE_POSTSCRIPT
20 #include "wx/generic/dcpsg.h"
26 #include "wx/dcmemory.h"
32 #include "wx/prntbase.h"
33 #include "wx/generic/prntdlgg.h"
35 #include "wx/filefn.h"
36 #include "wx/stdpaths.h"
58 //-----------------------------------------------------------------------------
59 // start and end of document/page
60 //-----------------------------------------------------------------------------
62 static const char *wxPostScriptHeaderConicTo
= "\
66 /conic_cntrl_y exch def\n\
67 /conic_cntrl_x exch def\n\
71 /p1_x p0_x conic_cntrl_x p0_x sub 2 3 div mul add def\n\
72 /p1_y p0_y conic_cntrl_y p0_y sub 2 3 div mul add def\n\
73 /p2_x p1_x to_x p0_x sub 1 3 div mul add def\n\
74 /p2_y p1_y to_y p0_y sub 1 3 div mul add def\n\
75 p1_x p1_y p2_x p2_y to_x to_y curveto\n\
79 static const char *wxPostScriptHeaderEllipse
= "\
80 /ellipsedict 8 dict def\n\
81 ellipsedict /mtrx matrix put\n\
85 /startangle exch def\n\
90 /savematrix mtrx currentmatrix def\n\
93 0 0 1 startangle endangle arc\n\
94 savematrix setmatrix\n\
99 static const char *wxPostScriptHeaderEllipticArc
= "\
100 /ellipticarcdict 8 dict def\n\
101 ellipticarcdict /mtrx matrix put\n\
103 { ellipticarcdict begin\n\
105 /endangle exch def\n\
106 /startangle exch def\n\
111 /savematrix mtrx currentmatrix def\n\
114 do_fill { 0 0 moveto } if\n\
115 0 0 1 startangle endangle arc\n\
116 savematrix setmatrix\n\
117 do_fill { fill }{ stroke } ifelse\n\
121 static const char *wxPostScriptHeaderSpline
= "\
122 /DrawSplineSection {\n\
129 /xa x1 x2 x1 sub 0.666667 mul add def\n\
130 /ya y1 y2 y1 sub 0.666667 mul add def\n\
131 /xb x3 x2 x3 sub 0.666667 mul add def\n\
132 /yb y3 y2 y3 sub 0.666667 mul add def\n\
134 xa ya xb yb x3 y3 curveto\n\
138 static const char *wxPostScriptHeaderColourImage
= "\
139 % define 'colorimage' if it isn't defined\n\
140 % ('colortogray' and 'mergeprocs' come from xwd2ps\n\
142 /colorimage where % do we know about 'colorimage'?\n\
143 { pop } % yes: pop off the 'dict' returned\n\
144 { % no: define one\n\
145 /colortogray { % define an RGB->I function\n\
146 /rgbdata exch store % call input 'rgbdata'\n\
147 rgbdata length 3 idiv\n\
148 /npixls exch store\n\
150 0 1 npixls 1 sub {\n\
152 rgbdata rgbindx get 20 mul % Red\n\
153 rgbdata rgbindx 1 add get 32 mul % Green\n\
154 rgbdata rgbindx 2 add get 12 mul % Blue\n\
155 add add 64 idiv % I = .5G + .31R + .18B\n\
157 /rgbindx rgbindx 3 add store\n\
159 grays 0 npixls getinterval\n\
162 % Utility procedure for colorimage operator.\n\
163 % This procedure takes two procedures off the\n\
164 % stack and merges them into a single procedure.\n\
166 /mergeprocs { % def\n\
185 /colorimage { % def\n\
186 pop pop % remove 'false 3' operands\n\
187 {colortogray} mergeprocs\n\
190 } ifelse % end of 'false' case\n\
193 static char wxPostScriptHeaderReencodeISO1
[] =
195 "dup dup findfont dup length dict begin\n"
196 "{ 1 index /FID ne { def }{ pop pop } ifelse } forall\n"
197 "/Encoding ISOLatin1Encoding def\n"
198 "currentdict end definefont\n"
200 "/ISOLatin1Encoding [\n"
201 "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n"
202 "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n"
203 "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n"
204 "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n"
205 "/space/exclam/quotedbl/numbersign/dollar/percent/ampersand/quoteright\n"
206 "/parenleft/parenright/asterisk/plus/comma/minus/period/slash\n"
207 "/zero/one/two/three/four/five/six/seven/eight/nine/colon/semicolon\n"
208 "/less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N\n"
209 "/O/P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright\n"
210 "/asciicircum/underscore/quoteleft/a/b/c/d/e/f/g/h/i/j/k/l/m\n"
211 "/n/o/p/q/r/s/t/u/v/w/x/y/z/braceleft/bar/braceright/asciitilde\n"
212 "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n"
213 "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n"
214 "/.notdef/dotlessi/grave/acute/circumflex/tilde/macron/breve\n"
215 "/dotaccent/dieresis/.notdef/ring/cedilla/.notdef/hungarumlaut\n";
217 static char wxPostScriptHeaderReencodeISO2
[] =
218 "/ogonek/caron/space/exclamdown/cent/sterling/currency/yen/brokenbar\n"
219 "/section/dieresis/copyright/ordfeminine/guillemotleft/logicalnot\n"
220 "/hyphen/registered/macron/degree/plusminus/twosuperior/threesuperior\n"
221 "/acute/mu/paragraph/periodcentered/cedilla/onesuperior/ordmasculine\n"
222 "/guillemotright/onequarter/onehalf/threequarters/questiondown\n"
223 "/Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE/Ccedilla\n"
224 "/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute/Icircumflex\n"
225 "/Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis\n"
226 "/multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute\n"
227 "/Thorn/germandbls/agrave/aacute/acircumflex/atilde/adieresis\n"
228 "/aring/ae/ccedilla/egrave/eacute/ecircumflex/edieresis/igrave\n"
229 "/iacute/icircumflex/idieresis/eth/ntilde/ograve/oacute/ocircumflex\n"
230 "/otilde/odieresis/divide/oslash/ugrave/uacute/ucircumflex/udieresis\n"
231 "/yacute/thorn/ydieresis\n"
234 //-------------------------------------------------------------------------------
236 //-------------------------------------------------------------------------------
239 static const double RAD2DEG
= 180.0 / M_PI
;
241 // we don't want to use only 72 dpi from PS print
242 static const int DPI
= 600;
243 static const double PS2DEV
= 600.0 / 72.0;
244 static const double DEV2PS
= 72.0 / 600.0;
246 #define XLOG2DEV(x) ((double)(LogicalToDeviceX(x)) * DEV2PS)
247 #define XLOG2DEVREL(x) ((double)(LogicalToDeviceXRel(x)) * DEV2PS)
248 #define YLOG2DEV(x) ((m_pageHeight - (double)LogicalToDeviceY(x)) * DEV2PS)
249 #define YLOG2DEVREL(x) ((double)(LogicalToDeviceYRel(x)) * DEV2PS)
251 IMPLEMENT_DYNAMIC_CLASS(wxPostScriptDC
, wxDC
)
253 //-------------------------------------------------------------------------------
255 void wxPostScriptDC
::SetResolution(int ppi
)
259 int wxPostScriptDC
::GetResolution()
264 wxPostScriptDC
::wxPostScriptDC ()
266 m_pstream
= (FILE*) NULL
;
276 m_underlinePosition
= 0.0;
277 m_underlineThickness
= 0.0;
279 m_pageHeight
= 842 * PS2DEV
;
282 wxPostScriptDC
::wxPostScriptDC (const wxPrintData
& printData
)
284 m_pstream
= (FILE*) NULL
;
294 m_underlinePosition
= 0.0;
295 m_underlineThickness
= 0.0;
297 // this calculates m_pageHeight required for
298 // taking the inverted Y axis into account
299 SetPrintData( printData
);
304 wxPostScriptDC
::~wxPostScriptDC ()
309 m_pstream
= (FILE*) NULL
;
313 bool wxPostScriptDC
::IsOk() const
318 void wxPostScriptDC
::DoSetClippingRegion (wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
)
320 wxCHECK_RET( m_ok
, wxT("invalid postscript dc") );
322 if (m_clipping
) DestroyClippingRegion();
324 wxDC
::DoSetClippingRegion(x
, y
, w
, h
);
329 buffer
.Printf( "gsave\n"
335 "closepath clip newpath\n",
336 XLOG2DEV(x
), YLOG2DEV(y
),
337 XLOG2DEV(x
+w
), YLOG2DEV(y
),
338 XLOG2DEV(x
+w
), YLOG2DEV(y
+h
),
339 XLOG2DEV(x
), YLOG2DEV(y
+h
) );
340 buffer
.Replace( ",", "." );
345 void wxPostScriptDC
::DestroyClippingRegion()
347 wxCHECK_RET( m_ok
, wxT("invalid postscript dc") );
352 PsPrint( "grestore\n" );
355 wxDC
::DestroyClippingRegion();
358 void wxPostScriptDC
::Clear()
360 // This should fail silently to avoid unnecessary
362 // wxFAIL_MSG( wxT("wxPostScriptDC::Clear not implemented.") );
365 bool wxPostScriptDC
::DoFloodFill (wxCoord
WXUNUSED(x
), wxCoord
WXUNUSED(y
), const wxColour
&WXUNUSED(col
), int WXUNUSED(style
))
367 wxFAIL_MSG( wxT("wxPostScriptDC::FloodFill not implemented.") );
371 bool wxPostScriptDC
::DoGetPixel (wxCoord
WXUNUSED(x
), wxCoord
WXUNUSED(y
), wxColour
* WXUNUSED(col
)) const
373 wxFAIL_MSG( wxT("wxPostScriptDC::GetPixel not implemented.") );
377 void wxPostScriptDC
::DoCrossHair (wxCoord
WXUNUSED(x
), wxCoord
WXUNUSED(y
))
379 wxFAIL_MSG( wxT("wxPostScriptDC::CrossHair not implemented.") );
382 void wxPostScriptDC
::DoDrawLine (wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
384 wxCHECK_RET( m_ok
, wxT("invalid postscript dc") );
386 if (m_pen
.GetStyle() == wxTRANSPARENT
) return;
391 buffer
.Printf( "newpath\n"
395 XLOG2DEV(x1
), YLOG2DEV(y1
),
396 XLOG2DEV(x2
), YLOG2DEV(y2
) );
397 buffer
.Replace( ",", "." );
400 CalcBoundingBox( x1
, y1
);
401 CalcBoundingBox( x2
, y2
);
404 void wxPostScriptDC
::DoDrawArc (wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
, wxCoord xc
, wxCoord yc
)
406 wxCHECK_RET( m_ok
, wxT("invalid postscript dc") );
408 wxCoord dx
= x1
- xc
;
409 wxCoord dy
= y1
- yc
;
410 double radius
= sqrt( (double)(dx
*dx
+dy
*dy
) );
411 double alpha1
, alpha2
;
413 if (x1
== x2
&& y1
== y2
)
418 else if ( wxIsNullDouble(radius
) )
425 alpha1
= (x1
- xc
== 0) ?
426 (y1
- yc
< 0) ?
90.0 : -90.0 :
427 -atan2(double(y1
-yc
), double(x1
-xc
)) * RAD2DEG
;
428 alpha2
= (x2
- xc
== 0) ?
429 (y2
- yc
< 0) ?
90.0 : -90.0 :
430 -atan2(double(y2
-yc
), double(x2
-xc
)) * RAD2DEG
;
432 while (alpha1
<= 0) alpha1
+= 360;
433 while (alpha2
<= 0) alpha2
+= 360; // adjust angles to be between
434 while (alpha1
> 360) alpha1
-= 360; // 0 and 360 degree
435 while (alpha2
> 360) alpha2
-= 360;
437 int i_radius
= wxRound( radius
);
439 if (m_brush
.GetStyle() != wxTRANSPARENT
)
444 buffer
.Printf( "newpath\n"
445 "%f %f %f %f %f %f ellipse\n"
449 XLOG2DEV(xc
), YLOG2DEV(yc
),
450 XLOG2DEVREL(i_radius
), YLOG2DEVREL(i_radius
),
452 XLOG2DEV(xc
), YLOG2DEV(yc
) );
453 buffer
.Replace( ",", "." );
456 CalcBoundingBox( xc
-i_radius
, yc
-i_radius
);
457 CalcBoundingBox( xc
+i_radius
, yc
+i_radius
);
460 if (m_pen
.GetStyle() != wxTRANSPARENT
)
465 buffer
.Printf( "newpath\n"
466 "%f %f %f %f %f %f ellipse\n"
470 XLOG2DEV(xc
), YLOG2DEV(yc
),
471 XLOG2DEVREL(i_radius
), YLOG2DEVREL(i_radius
),
473 XLOG2DEV(xc
), YLOG2DEV(yc
) );
474 buffer
.Replace( ",", "." );
477 CalcBoundingBox( xc
-i_radius
, yc
-i_radius
);
478 CalcBoundingBox( xc
+i_radius
, yc
+i_radius
);
482 void wxPostScriptDC
::DoDrawEllipticArc(wxCoord x
,wxCoord y
,wxCoord w
,wxCoord h
,double sa
,double ea
)
484 wxCHECK_RET( m_ok
, wxT("invalid postscript dc") );
486 if ( sa
>= 360 || sa
<= -360 )
487 sa
-= int(sa
/360)*360;
488 if ( ea
>= 360 || ea
<=- 360 )
489 ea
-= int(ea
/360)*360;
495 if ( wxIsSameDouble(sa
, ea
) )
497 DrawEllipse(x
,y
,w
,h
);
501 if (m_brush
.GetStyle () != wxTRANSPARENT
)
506 buffer
.Printf( "newpath\n"
507 "%f %f %f %f %f %f true ellipticarc\n",
508 XLOG2DEV(x
+w
/2), YLOG2DEV(y
+h
/2),
509 XLOG2DEVREL(w
/2), YLOG2DEVREL(h
/2),
511 buffer
.Replace( ",", "." );
514 CalcBoundingBox( x
,y
);
515 CalcBoundingBox( x
+w
, y
+h
);
518 if (m_pen
.GetStyle () != wxTRANSPARENT
)
523 buffer
.Printf( "newpath\n"
524 "%f %f %f %f %f %f false ellipticarc\n",
525 XLOG2DEV(x
+w
/2), YLOG2DEV(y
+h
/2),
526 XLOG2DEVREL(w
/2), YLOG2DEVREL(h
/2),
527 wxRound(sa
), wxRound(ea
) );
528 buffer
.Replace( ",", "." );
531 CalcBoundingBox( x
,y
);
532 CalcBoundingBox( x
+w
, y
+h
);
536 void wxPostScriptDC
::DoDrawPoint (wxCoord x
, wxCoord y
)
538 wxCHECK_RET( m_ok
, wxT("invalid postscript dc") );
540 if (m_pen
.GetStyle() == wxTRANSPARENT
) return;
545 buffer
.Printf( "newpath\n"
549 XLOG2DEV(x
), YLOG2DEV(y
),
550 XLOG2DEV(x
+1), YLOG2DEV(y
) );
551 buffer
.Replace( ",", "." );
554 CalcBoundingBox( x
, y
);
557 void wxPostScriptDC
::DoDrawPolygon (int n
, wxPoint points
[], wxCoord xoffset
, wxCoord yoffset
, int fillStyle
)
559 wxCHECK_RET( m_ok
, wxT("invalid postscript dc") );
563 if (m_brush
.GetStyle () != wxTRANSPARENT
)
567 PsPrint( "newpath\n" );
569 double xx
= XLOG2DEV(points
[0].x
+ xoffset
);
570 double yy
= YLOG2DEV(points
[0].y
+ yoffset
);
573 buffer
.Printf( "%f %f moveto\n", xx
, yy
);
574 buffer
.Replace( ",", "." );
577 CalcBoundingBox( points
[0].x
+ xoffset
, points
[0].y
+ yoffset
);
579 for (int i
= 1; i
< n
; i
++)
581 xx
= XLOG2DEV(points
[i
].x
+ xoffset
);
582 yy
= YLOG2DEV(points
[i
].y
+ yoffset
);
584 buffer
.Printf( "%f %f lineto\n", xx
, yy
);
585 buffer
.Replace( ",", "." );
588 CalcBoundingBox( points
[i
].x
+ xoffset
, points
[i
].y
+ yoffset
);
591 PsPrint( (fillStyle
== wxODDEVEN_RULE ?
"eofill\n" : "fill\n") );
594 if (m_pen
.GetStyle () != wxTRANSPARENT
)
598 PsPrint( "newpath\n" );
600 double xx
= XLOG2DEV(points
[0].x
+ xoffset
);
601 double yy
= YLOG2DEV(points
[0].y
+ yoffset
);
604 buffer
.Printf( "%f %f moveto\n", xx
, yy
);
605 buffer
.Replace( ",", "." );
608 CalcBoundingBox( points
[0].x
+ xoffset
, points
[0].y
+ yoffset
);
610 for (int i
= 1; i
< n
; i
++)
612 xx
= XLOG2DEV(points
[i
].x
+ xoffset
);
613 yy
= YLOG2DEV(points
[i
].y
+ yoffset
);
615 buffer
.Printf( "%f %f lineto\n", xx
, yy
);
616 buffer
.Replace( ",", "." );
619 CalcBoundingBox( points
[i
].x
+ xoffset
, points
[i
].y
+ yoffset
);
622 PsPrint( "closepath\n" );
623 PsPrint( "stroke\n" );
627 void wxPostScriptDC
::DoDrawPolyPolygon (int n
, int count
[], wxPoint points
[], wxCoord xoffset
, wxCoord yoffset
, int fillStyle
)
629 wxCHECK_RET( m_ok
, wxT("invalid postscript dc") );
633 if (m_brush
.GetStyle () != wxTRANSPARENT
)
637 PsPrint( "newpath\n" );
640 for (int i
= 0; i
< n
; ofs
+= count
[i
++])
642 double xx
= XLOG2DEV(points
[ofs
].x
+ xoffset
);
643 double yy
= YLOG2DEV(points
[ofs
].y
+ yoffset
);
646 buffer
.Printf( "%f %f moveto\n", xx
, yy
);
647 buffer
.Replace( ",", "." );
650 CalcBoundingBox( points
[ofs
].x
+ xoffset
, points
[ofs
].y
+ yoffset
);
652 for (int j
= 1; j
< count
[i
]; j
++)
654 xx
= XLOG2DEV(points
[ofs
+j
].x
+ xoffset
);
655 yy
= YLOG2DEV(points
[ofs
+j
].y
+ yoffset
);
657 buffer
.Printf( "%f %f lineto\n", xx
, yy
);
658 buffer
.Replace( ",", "." );
661 CalcBoundingBox( points
[ofs
+j
].x
+ xoffset
, points
[ofs
+j
].y
+ yoffset
);
664 PsPrint( (fillStyle
== wxODDEVEN_RULE ?
"eofill\n" : "fill\n") );
667 if (m_pen
.GetStyle () != wxTRANSPARENT
)
671 PsPrint( "newpath\n" );
674 for (int i
= 0; i
< n
; ofs
+= count
[i
++])
676 double xx
= XLOG2DEV(points
[ofs
].x
+ xoffset
);
677 double yy
= YLOG2DEV(points
[ofs
].y
+ yoffset
);
680 buffer
.Printf( "%f %f moveto\n", xx
, yy
);
681 buffer
.Replace( ",", "." );
684 CalcBoundingBox( points
[ofs
].x
+ xoffset
, points
[ofs
].y
+ yoffset
);
686 for (int j
= 1; j
< count
[i
]; j
++)
688 xx
= XLOG2DEV(points
[ofs
+j
].x
+ xoffset
);
689 yy
= YLOG2DEV(points
[ofs
+j
].y
+ yoffset
);
691 buffer
.Printf( "%f %f lineto\n", xx
, yy
);
692 buffer
.Replace( ",", "." );
695 CalcBoundingBox( points
[ofs
+j
].x
+ xoffset
, points
[ofs
+j
].y
+ yoffset
);
698 PsPrint( "closepath\n" );
699 PsPrint( "stroke\n" );
703 void wxPostScriptDC
::DoDrawLines (int n
, wxPoint points
[], wxCoord xoffset
, wxCoord yoffset
)
705 wxCHECK_RET( m_ok
, wxT("invalid postscript dc") );
707 if (m_pen
.GetStyle() == wxTRANSPARENT
) return;
714 for ( i
=0; i
<n
; i
++ )
715 CalcBoundingBox( points
[i
].x
+xoffset
, points
[i
].y
+yoffset
);
718 buffer
.Printf( "newpath\n"
720 XLOG2DEV(points
[0].x
+xoffset
),
721 YLOG2DEV(points
[0].y
+yoffset
) );
722 buffer
.Replace( ",", "." );
725 for (i
= 1; i
< n
; i
++)
727 buffer
.Printf( "%f %f lineto\n",
728 XLOG2DEV(points
[i
].x
+xoffset
),
729 YLOG2DEV(points
[i
].y
+yoffset
) );
730 buffer
.Replace( ",", "." );
734 PsPrint( "stroke\n" );
737 void wxPostScriptDC
::DoDrawRectangle (wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
739 wxCHECK_RET( m_ok
, wxT("invalid postscript dc") );
741 if (m_brush
.GetStyle () != wxTRANSPARENT
)
746 buffer
.Printf( "newpath\n"
753 XLOG2DEV(x
), YLOG2DEV(y
),
754 XLOG2DEV(x
+ width
), YLOG2DEV(y
),
755 XLOG2DEV(x
+ width
), YLOG2DEV(y
+ height
),
756 XLOG2DEV(x
), YLOG2DEV(y
+ height
) );
757 buffer
.Replace( ",", "." );
760 CalcBoundingBox( x
, y
);
761 CalcBoundingBox( x
+ width
, y
+ height
);
764 if (m_pen
.GetStyle () != wxTRANSPARENT
)
769 buffer
.Printf( "newpath\n"
776 XLOG2DEV(x
), YLOG2DEV(y
),
777 XLOG2DEV(x
+ width
), YLOG2DEV(y
),
778 XLOG2DEV(x
+ width
), YLOG2DEV(y
+ height
),
779 XLOG2DEV(x
), YLOG2DEV(y
+ height
) );
780 buffer
.Replace( ",", "." );
783 CalcBoundingBox( x
, y
);
784 CalcBoundingBox( x
+ width
, y
+ height
);
788 void wxPostScriptDC
::DoDrawRoundedRectangle (wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
, double radius
)
790 wxCHECK_RET( m_ok
, wxT("invalid postscript dc") );
794 // Now, a negative radius is interpreted to mean
795 // 'the proportion of the smallest X or Y dimension'
796 double smallest
= width
< height ? width
: height
;
797 radius
= (-radius
* smallest
);
800 wxCoord rad
= (wxCoord
) radius
;
802 if (m_brush
.GetStyle () != wxTRANSPARENT
)
806 /* Draw rectangle anticlockwise */
808 buffer
.Printf( "newpath\n"
809 "%f %f %f 90 180 arc\n"
811 "%f %f %f 180 270 arc\n"
813 "%f %f %f 270 0 arc\n"
815 "%f %f %f 0 90 arc\n"
819 XLOG2DEV(x
+ rad
), YLOG2DEV(y
+ rad
), XLOG2DEVREL(rad
),
820 XLOG2DEV(x
), YLOG2DEV(y
+ height
- rad
),
821 XLOG2DEV(x
+ rad
), YLOG2DEV(y
+ height
- rad
), XLOG2DEVREL(rad
),
822 XLOG2DEV(x
+ width
- rad
), YLOG2DEV(y
+ height
),
823 XLOG2DEV(x
+ width
- rad
), YLOG2DEV(y
+ height
- rad
), XLOG2DEVREL(rad
),
824 XLOG2DEV(x
+ width
), YLOG2DEV(y
+ rad
),
825 XLOG2DEV(x
+ width
- rad
), YLOG2DEV(y
+ rad
), XLOG2DEVREL(rad
),
826 XLOG2DEV(x
+ rad
), YLOG2DEV(y
) );
827 buffer
.Replace( ",", "." );
830 CalcBoundingBox( x
, y
);
831 CalcBoundingBox( x
+ width
, y
+ height
);
834 if (m_pen
.GetStyle () != wxTRANSPARENT
)
838 /* Draw rectangle anticlockwise */
840 buffer
.Printf( "newpath\n"
841 "%f %f %f 90 180 arc\n"
843 "%f %f %f 180 270 arc\n"
845 "%f %f %f 270 0 arc\n"
847 "%f %f %f 0 90 arc\n"
851 XLOG2DEV(x
+ rad
), YLOG2DEV(y
+ rad
), XLOG2DEVREL(rad
),
852 XLOG2DEV(x
), YLOG2DEV(y
+ height
- rad
),
853 XLOG2DEV(x
+ rad
), YLOG2DEV(y
+ height
- rad
), XLOG2DEVREL(rad
),
854 XLOG2DEV(x
+ width
- rad
), YLOG2DEV(y
+ height
),
855 XLOG2DEV(x
+ width
- rad
), YLOG2DEV(y
+ height
- rad
), XLOG2DEVREL(rad
),
856 XLOG2DEV(x
+ width
), YLOG2DEV(y
+ rad
),
857 XLOG2DEV(x
+ width
- rad
), YLOG2DEV(y
+ rad
), XLOG2DEVREL(rad
),
858 XLOG2DEV(x
+ rad
), YLOG2DEV(y
) );
859 buffer
.Replace( ",", "." );
862 CalcBoundingBox( x
, y
);
863 CalcBoundingBox( x
+ width
, y
+ height
);
867 void wxPostScriptDC
::DoDrawEllipse (wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
869 wxCHECK_RET( m_ok
, wxT("invalid postscript dc") );
871 if (m_brush
.GetStyle () != wxTRANSPARENT
)
876 buffer
.Printf( "newpath\n"
877 "%f %f %f %f 0 360 ellipse\n"
879 XLOG2DEV(x
+ width
/ 2), YLOG2DEV(y
+ height
/ 2),
880 XLOG2DEVREL(width
/ 2), YLOG2DEVREL(height
/ 2) );
881 buffer
.Replace( ",", "." );
884 CalcBoundingBox( x
- width
, y
- height
);
885 CalcBoundingBox( x
+ width
, y
+ height
);
888 if (m_pen
.GetStyle () != wxTRANSPARENT
)
893 buffer
.Printf( "newpath\n"
894 "%f %f %f %f 0 360 ellipse\n"
896 XLOG2DEV(x
+ width
/ 2), YLOG2DEV(y
+ height
/ 2),
897 XLOG2DEVREL(width
/ 2), YLOG2DEVREL(height
/ 2) );
898 buffer
.Replace( ",", "." );
901 CalcBoundingBox( x
- width
, y
- height
);
902 CalcBoundingBox( x
+ width
, y
+ height
);
906 void wxPostScriptDC
::DoDrawIcon( const wxIcon
& icon
, wxCoord x
, wxCoord y
)
908 DrawBitmap( icon
, x
, y
, true );
911 /* this has to be char, not wxChar */
912 static char hexArray
[] = "0123456789ABCDEF";
914 void wxPostScriptDC
::DoDrawBitmap( const wxBitmap
& bitmap
, wxCoord x
, wxCoord y
, bool WXUNUSED(useMask
) )
916 wxCHECK_RET( m_ok
, wxT("invalid postscript dc") );
918 if (!bitmap
.Ok()) return;
920 wxImage image
= bitmap
.ConvertToImage();
922 if (!image
.Ok()) return;
924 wxCoord w
= image
.GetWidth();
925 wxCoord h
= image
.GetHeight();
927 double ww
= XLOG2DEVREL(image
.GetWidth());
928 double hh
= YLOG2DEVREL(image
.GetHeight());
930 double xx
= XLOG2DEV(x
);
931 double yy
= YLOG2DEV(y
+ bitmap
.GetHeight());
934 buffer
.Printf( "/origstate save def\n"
936 "/pix %f string def\n"
937 "/grays %f string def\n"
944 "{currentfile pix readhexstring pop}\n"
945 "false 3 colorimage\n",
946 w
, w
, xx
, yy
, ww
, hh
, w
, h
, w
, -h
, h
);
947 buffer
.Replace( ",", "." );
950 unsigned char* data
= image
.GetData();
952 // size of the buffer = width*rgb(3)*hexa(2)+'\n'
953 wxCharBuffer
charbuffer(w
*6 + 1);
954 int firstDigit
, secondDigit
;
957 for (int j
= 0; j
< h
; j
++)
959 char* bufferindex
= charbuffer
.data();
962 for (int i
= 0; i
< w
*3; i
++)
964 firstDigit
= (int)(*data
/16.0);
965 secondDigit
= (int)(*data
- (firstDigit
*16.0));
966 *(bufferindex
++) = hexArray
[firstDigit
];
967 *(bufferindex
++) = hexArray
[secondDigit
];
971 *(bufferindex
++) = '\n';
973 PsPrint( charbuffer
);
977 PsPrint( "origstate restore\n" );
980 void wxPostScriptDC
::SetFont( const wxFont
& font
)
982 wxCHECK_RET( m_ok
, wxT("invalid postscript dc") );
984 if (!font
.Ok()) return;
988 int Style
= m_font
.GetStyle();
989 int Weight
= m_font
.GetWeight();
992 switch (m_font
.GetFamily())
997 if (Style
== wxITALIC
)
999 if (Weight
== wxBOLD
)
1000 name
= "/Courier-BoldOblique";
1002 name
= "/Courier-Oblique";
1006 if (Weight
== wxBOLD
)
1007 name
= "/Courier-Bold";
1015 if (Style
== wxITALIC
)
1017 if (Weight
== wxBOLD
)
1018 name
= "/Times-BoldItalic";
1020 name
= "/Times-Italic";
1024 if (Weight
== wxBOLD
)
1025 name
= "/Times-Bold";
1027 name
= "/Times-Roman";
1033 name
= "/ZapfChancery-MediumItalic";
1039 if (Style
== wxITALIC
)
1041 if (Weight
== wxBOLD
)
1042 name
= "/Helvetica-BoldOblique";
1044 name
= "/Helvetica-Oblique";
1048 if (Weight
== wxBOLD
)
1049 name
= "/Helvetica-Bold";
1051 name
= "/Helvetica";
1057 // We may legitimately call SetFont before BeginDoc
1062 PsPrint( " reencodeISO def\n" );
1064 PsPrint( " findfont\n" );
1067 double size
= (double) m_font
.GetPointSize();
1069 buffer
.Printf( "%f scalefont setfont\n", size
* DEV2PS
* m_scaleX
);
1070 buffer
.Replace( ",", "." );
1074 void wxPostScriptDC
::SetPen( const wxPen
& pen
)
1076 wxCHECK_RET( m_ok
, wxT("invalid postscript dc") );
1078 if (!pen
.Ok()) return;
1080 int oldStyle
= m_pen
.GetStyle();
1086 if (m_pen
.GetWidth() <= 0)
1089 width
= (double) m_pen
.GetWidth();
1092 buffer
.Printf( "%f setlinewidth\n", width
* DEV2PS
* m_scaleX
);
1093 buffer
.Replace( ",", "." );
1097 Line style - WRONG: 2nd arg is OFFSET
1099 Here, I'm afraid you do not conceive meaning of parameters of 'setdash'
1100 operator correctly. You should look-up this in the Red Book: the 2nd parame-
1101 ter is not number of values in the array of the first one, but an offset
1102 into this description of the pattern. I mean a real *offset* not index
1103 into array. I.e. If the command is [3 4] 1 setdash is used, then there
1104 will be first black line *2* units wxCoord, then space 4 units, then the
1105 pattern of *3* units black, 4 units space will be repeated.
1108 static const char *dotted
= "[2 5] 2";
1109 static const char *short_dashed
= "[4 4] 2";
1110 static const char *wxCoord_dashed
= "[4 8] 2";
1111 static const char *dotted_dashed
= "[6 6 2 6] 4";
1115 switch (m_pen
.GetStyle())
1117 case wxDOT
: psdash
= dotted
; break;
1118 case wxSHORT_DASH
: psdash
= short_dashed
; break;
1119 case wxLONG_DASH
: psdash
= wxCoord_dashed
; break;
1120 case wxDOT_DASH
: psdash
= dotted_dashed
; break;
1124 int nDashes
= m_pen
.GetDashes (&dashes
);
1126 for (int i
= 0; i
< nDashes
; ++i
)
1128 buffer
.Printf( "%d ", dashes
[i
] );
1131 PsPrint ("] 0 setdash\n");
1137 default: psdash
= "[] 0"; break;
1140 if ( psdash
&& (oldStyle
!= m_pen
.GetStyle()) )
1143 PsPrint( " setdash\n" );
1147 unsigned char red
= m_pen
.GetColour().Red();
1148 unsigned char blue
= m_pen
.GetColour().Blue();
1149 unsigned char green
= m_pen
.GetColour().Green();
1153 // Anything not white is black
1154 if (! (red
== (unsigned char) 255 &&
1155 blue
== (unsigned char) 255 &&
1156 green
== (unsigned char) 255) )
1158 red
= (unsigned char) 0;
1159 green
= (unsigned char) 0;
1160 blue
= (unsigned char) 0;
1165 if (!(red
== m_currentRed
&& green
== m_currentGreen
&& blue
== m_currentBlue
))
1167 double redPS
= (double)(red
) / 255.0;
1168 double bluePS
= (double)(blue
) / 255.0;
1169 double greenPS
= (double)(green
) / 255.0;
1172 buffer
.Printf( "%f %f %f setrgbcolor\n", redPS
, greenPS
, bluePS
);
1173 buffer
.Replace( ",", "." );
1177 m_currentBlue
= blue
;
1178 m_currentGreen
= green
;
1182 void wxPostScriptDC
::SetBrush( const wxBrush
& brush
)
1184 wxCHECK_RET( m_ok
, wxT("invalid postscript dc") );
1186 if (!brush
.Ok()) return;
1191 unsigned char red
= m_brush
.GetColour().Red();
1192 unsigned char blue
= m_brush
.GetColour().Blue();
1193 unsigned char green
= m_brush
.GetColour().Green();
1197 // Anything not white is black
1198 if (! (red
== (unsigned char) 255 &&
1199 blue
== (unsigned char) 255 &&
1200 green
== (unsigned char) 255) )
1202 red
= (unsigned char) 0;
1203 green
= (unsigned char) 0;
1204 blue
= (unsigned char) 0;
1209 if (!(red
== m_currentRed
&& green
== m_currentGreen
&& blue
== m_currentBlue
))
1211 double redPS
= (double)(red
) / 255.0;
1212 double bluePS
= (double)(blue
) / 255.0;
1213 double greenPS
= (double)(green
) / 255.0;
1216 buffer
.Printf( "%f %f %f setrgbcolor\n", redPS
, greenPS
, bluePS
);
1217 buffer
.Replace( ",", "." );
1221 m_currentBlue
= blue
;
1222 m_currentGreen
= green
;
1226 void wxPostScriptDC
::DoDrawText( const wxString
& text
, wxCoord x
, wxCoord y
)
1228 wxCHECK_RET( m_ok
, wxT("invalid postscript dc") );
1230 const wxWX2MBbuf textbuf
= text
.mb_str();
1231 if (textbuf
.data() == NULL
)
1234 if (m_textForegroundColour
.Ok())
1236 unsigned char red
= m_textForegroundColour
.Red();
1237 unsigned char blue
= m_textForegroundColour
.Blue();
1238 unsigned char green
= m_textForegroundColour
.Green();
1242 // Anything not white is black
1243 if (! (red
== (unsigned char) 255 &&
1244 blue
== (unsigned char) 255 &&
1245 green
== (unsigned char) 255))
1247 red
= (unsigned char) 0;
1248 green
= (unsigned char) 0;
1249 blue
= (unsigned char) 0;
1253 // maybe setgray here ?
1254 if (!(red
== m_currentRed
&& green
== m_currentGreen
&& blue
== m_currentBlue
))
1256 double redPS
= (double)(red
) / 255.0;
1257 double bluePS
= (double)(blue
) / 255.0;
1258 double greenPS
= (double)(green
) / 255.0;
1261 buffer
.Printf( "%f %f %f setrgbcolor\n", redPS
, greenPS
, bluePS
);
1262 buffer
.Replace( ",", "." );
1266 m_currentBlue
= blue
;
1267 m_currentGreen
= green
;
1271 wxCoord text_w
, text_h
, text_descent
;
1273 GetTextExtent(text
, &text_w
, &text_h
, &text_descent
);
1275 // VZ: this seems to be unnecessary, so taking it out for now, if it
1276 // doesn't create any problems, remove this comment entirely
1277 //SetFont( m_font );
1280 int size
= m_font
.GetPointSize();
1282 // wxCoord by = y + (wxCoord)floor( double(size) * 2.0 / 3.0 ); // approximate baseline
1283 // commented by V. Slavik and replaced by accurate version
1284 // - note that there is still rounding error in text_descent!
1285 wxCoord by
= y
+ size
- text_descent
; // baseline
1288 buffer
.Printf( "%f %f moveto\n", XLOG2DEV(x
), YLOG2DEV(by
) );
1289 buffer
.Replace( ",", "." );
1293 size_t len
= strlen(textbuf
);
1295 for (i
= 0; i
< len
; i
++)
1297 int c
= (unsigned char) textbuf
[i
];
1298 if (c
== ')' || c
== '(' || c
== '\\')
1300 /* Cope with special characters */
1302 PsPrint( (char) c
);
1304 else if ( c
>= 128 )
1306 /* Cope with character codes > 127 */
1307 buffer
.Printf( "\\%o", c
);
1312 PsPrint( (char) c
);
1316 PsPrint( ") show\n" );
1318 if (m_font
.GetUnderlined())
1320 wxCoord uy
= (wxCoord
)(y
+ size
- m_underlinePosition
);
1322 buffer
.Printf( "gsave\n"
1328 XLOG2DEV(x
), YLOG2DEV(uy
),
1329 m_underlineThickness
,
1330 XLOG2DEV(x
+ text_w
), YLOG2DEV(uy
) );
1331 buffer
.Replace( ",", "." );
1335 CalcBoundingBox( x
, y
);
1336 CalcBoundingBox( x
+ size
* text
.length() * 2/3 , y
);
1339 void wxPostScriptDC
::DoDrawRotatedText( const wxString
& text
, wxCoord x
, wxCoord y
, double angle
)
1341 if ( wxIsNullDouble(angle
) )
1343 DoDrawText(text
, x
, y
);
1347 wxCHECK_RET( m_ok
, wxT("invalid postscript dc") );
1351 if (m_textForegroundColour
.Ok())
1353 unsigned char red
= m_textForegroundColour
.Red();
1354 unsigned char blue
= m_textForegroundColour
.Blue();
1355 unsigned char green
= m_textForegroundColour
.Green();
1359 // Anything not white is black
1360 if (! (red
== (unsigned char) 255 &&
1361 blue
== (unsigned char) 255 &&
1362 green
== (unsigned char) 255))
1364 red
= (unsigned char) 0;
1365 green
= (unsigned char) 0;
1366 blue
= (unsigned char) 0;
1370 // maybe setgray here ?
1371 if (!(red
== m_currentRed
&& green
== m_currentGreen
&& blue
== m_currentBlue
))
1373 double redPS
= (double)(red
) / 255.0;
1374 double bluePS
= (double)(blue
) / 255.0;
1375 double greenPS
= (double)(green
) / 255.0;
1378 buffer
.Printf( "%f %f %f setrgbcolor\n", redPS
, greenPS
, bluePS
);
1379 buffer
.Replace( ",", "." );
1383 m_currentBlue
= blue
;
1384 m_currentGreen
= green
;
1388 int size
= m_font
.GetPointSize();
1391 buffer
.Printf( "%f %f moveto\n", XLOG2DEV(x
), YLOG2DEV(y
));
1392 buffer
.Replace( ",", "." );
1395 buffer
.Printf( "%f rotate\n", angle
);
1396 buffer
.Replace( ",", "." );
1400 const wxWX2MBbuf textbuf
= text
.mb_str();
1401 size_t len
= strlen(textbuf
);
1403 for (i
= 0; i
< len
; i
++)
1405 int c
= (unsigned char) textbuf
[i
];
1406 if (c
== ')' || c
== '(' || c
== '\\')
1408 /* Cope with special characters */
1410 PsPrint( (char) c
);
1412 else if ( c
>= 128 )
1414 /* Cope with character codes > 127 */
1415 buffer
.Printf( "\\%o", c
);
1420 PsPrint( (char) c
);
1424 PsPrint( ") show\n" );
1426 buffer
.Printf( "%f rotate\n", -angle
);
1427 buffer
.Replace( ",", "." );
1430 if (m_font
.GetUnderlined())
1432 wxCoord uy
= (wxCoord
)(y
+ size
- m_underlinePosition
);
1434 GetTextExtent(text
, &w
, &h
);
1443 XLOG2DEV(x
), YLOG2DEV(uy
),
1444 m_underlineThickness
,
1445 XLOG2DEV(x
+ w
), YLOG2DEV(uy
) );
1446 buffer
.Replace( ",", "." );
1450 CalcBoundingBox( x
, y
);
1451 CalcBoundingBox( x
+ size
* text
.length() * 2/3 , y
);
1454 void wxPostScriptDC
::SetBackground (const wxBrush
& brush
)
1456 m_backgroundBrush
= brush
;
1459 void wxPostScriptDC
::SetLogicalFunction (int WXUNUSED(function
))
1461 wxFAIL_MSG( wxT("wxPostScriptDC::SetLogicalFunction not implemented.") );
1465 void wxPostScriptDC
::DoDrawSpline( wxList
*points
)
1467 wxCHECK_RET( m_ok
, wxT("invalid postscript dc") );
1471 // a and b are not used
1473 double c
, d
, x1
, y1
, x2
, y2
, x3
, y3
;
1476 wxList
::compatibility_iterator node
= points
->GetFirst();
1477 p
= (wxPoint
*)node
->GetData();
1481 node
= node
->GetNext();
1482 p
= (wxPoint
*)node
->GetData();
1489 (double)(x1
+ c
) / 2;
1494 (double)(y1
+ d
) / 2;
1497 buffer
.Printf( "newpath\n"
1500 XLOG2DEV(wxRound(x1
)), YLOG2DEV(wxRound(y1
)),
1501 XLOG2DEV(wxRound(x3
)), YLOG2DEV(wxRound(y3
)) );
1502 buffer
.Replace( ",", "." );
1505 CalcBoundingBox( (wxCoord
)x1
, (wxCoord
)y1
);
1506 CalcBoundingBox( (wxCoord
)x3
, (wxCoord
)y3
);
1508 node
= node
->GetNext();
1511 q
= (wxPoint
*)node
->GetData();
1519 x3
= (double)(x2
+ c
) / 2;
1520 y3
= (double)(y2
+ d
) / 2;
1522 buffer
.Printf( "%f %f %f %f %f %f DrawSplineSection\n",
1523 XLOG2DEV(wxRound(x1
)), YLOG2DEV(wxRound(y1
)),
1524 XLOG2DEV(wxRound(x2
)), YLOG2DEV(wxRound(y2
)),
1525 XLOG2DEV(wxRound(x3
)), YLOG2DEV(wxRound(y3
)) );
1526 buffer
.Replace( ",", "." );
1529 CalcBoundingBox( (wxCoord
)x1
, (wxCoord
)y1
);
1530 CalcBoundingBox( (wxCoord
)x3
, (wxCoord
)y3
);
1532 node
= node
->GetNext();
1536 At this point, (x2,y2) and (c,d) are the position of the
1537 next-to-last and last point respectively, in the point list
1540 buffer
.Printf( "%f %f lineto\nstroke\n", XLOG2DEV(wxRound(c
)), YLOG2DEV(wxRound(d
)) );
1541 buffer
.Replace( ",", "." );
1544 #endif // wxUSE_SPLINES
1546 wxCoord wxPostScriptDC
::GetCharWidth() const
1548 // Chris Breeze: reasonable approximation using wxMODERN/Courier
1549 return (wxCoord
) (GetCharHeight() * 72.0 / 120.0);
1552 void wxPostScriptDC
::SetPrintData(const wxPrintData
& data
)
1556 wxPaperSize id
= m_printData
.GetPaperId();
1557 wxPrintPaperType
*paper
= wxThePrintPaperDatabase
->FindPaperType(id
);
1558 if (!paper
) paper
= wxThePrintPaperDatabase
->FindPaperType(wxPAPER_A4
);
1563 w
= paper
->GetSizeDeviceUnits().x
;
1564 h
= paper
->GetSizeDeviceUnits().y
;
1567 if (m_printData
.GetOrientation() == wxLANDSCAPE
)
1568 m_pageHeight
= w
* PS2DEV
;
1570 m_pageHeight
= h
* PS2DEV
;
1575 void wxPostScriptDC
::SetAxisOrientation( bool xLeftRight
, bool yBottomUp
)
1577 wxDCBase
::SetAxisOrientation(xLeftRight
,yBottomUp
);
1580 void wxPostScriptDC
::SetMapMode(int mode
)
1582 wxDCBase
::SetMapMode(mode
);
1585 void wxPostScriptDC
::SetUserScale(double x
, double y
)
1587 wxDCBase
::SetUserScale(x
,y
);
1590 void wxPostScriptDC
::SetLogicalScale(double x
, double y
)
1592 wxDCBase
::SetLogicalScale(x
,y
);
1595 void wxPostScriptDC
::SetLogicalOrigin(wxCoord x
, wxCoord y
)
1597 wxDCBase
::SetLogicalOrigin(x
,y
);
1600 void wxPostScriptDC
::SetDeviceOrigin(wxCoord x
, wxCoord y
)
1602 wxDCBase
::SetDeviceOrigin(x
,y
);
1606 void wxPostScriptDC
::DoGetSize(int* width
, int* height
) const
1608 wxPaperSize id
= m_printData
.GetPaperId();
1610 wxPrintPaperType
*paper
= wxThePrintPaperDatabase
->FindPaperType(id
);
1612 if (!paper
) paper
= wxThePrintPaperDatabase
->FindPaperType(wxPAPER_A4
);
1618 w
= paper
->GetSizeDeviceUnits().x
;
1619 h
= paper
->GetSizeDeviceUnits().y
;
1622 if (m_printData
.GetOrientation() == wxLANDSCAPE
)
1630 *width
= wxRound( w
* PS2DEV
);
1633 *height
= wxRound( h
* PS2DEV
);
1636 void wxPostScriptDC
::DoGetSizeMM(int *width
, int *height
) const
1638 wxPaperSize id
= m_printData
.GetPaperId();
1640 wxPrintPaperType
*paper
= wxThePrintPaperDatabase
->FindPaperType(id
);
1642 if (!paper
) paper
= wxThePrintPaperDatabase
->FindPaperType(wxPAPER_A4
);
1648 w
= paper
->GetWidth() / 10;
1649 h
= paper
->GetHeight() / 10;
1652 if (m_printData
.GetOrientation() == wxLANDSCAPE
)
1659 if (width
) *width
= w
;
1660 if (height
) *height
= h
;
1663 // Resolution in pixels per logical inch
1664 wxSize wxPostScriptDC
::GetPPI(void) const
1666 return wxSize( DPI
, DPI
);
1670 bool wxPostScriptDC
::StartDoc( const wxString
& message
)
1672 wxCHECK_MSG( m_ok
, false, wxT("invalid postscript dc") );
1674 if (m_printData
.GetPrintMode() != wxPRINT_MODE_STREAM
)
1676 if (m_printData
.GetFilename() == wxEmptyString
)
1678 wxString filename
= wxGetTempFileName( wxT("ps") );
1679 m_printData
.SetFilename(filename
);
1682 m_pstream
= wxFopen( m_printData
.GetFilename(), wxT("w+") );
1686 wxLogError( _("Cannot open file for PostScript printing!"));
1697 PsPrint( "%!PS-Adobe-2.0\n" );
1699 buffer
.Printf( "%%%%Title: %s\n", m_title
);
1701 PsPrint( "%%Creator: wxWidgets PostScript renderer\n" );
1703 buffer
.Printf( "%%%%CreationDate: %s\n", wxNow() );
1706 if (m_printData
.GetOrientation() == wxLANDSCAPE
)
1707 PsPrint( "%%Orientation: Landscape\n" );
1709 PsPrint( "%%Orientation: Portrait\n" );
1711 const wxChar
*paper
;
1712 switch (m_printData
.GetPaperId())
1714 case wxPAPER_LETTER
: paper
= wxT("Letter"); break; // Letter: paper ""; 8 1/2 by 11 inches
1715 case wxPAPER_LEGAL
: paper
= wxT("Legal"); break; // Legal, 8 1/2 by 14 inches
1716 case wxPAPER_A4
: paper
= wxT("A4"); break; // A4 Sheet, 210 by 297 millimeters
1717 case wxPAPER_TABLOID
: paper
= wxT("Tabloid"); break; // Tabloid, 11 by 17 inches
1718 case wxPAPER_LEDGER
: paper
= wxT("Ledger"); break; // Ledger, 17 by 11 inches
1719 case wxPAPER_STATEMENT
: paper
= wxT("Statement"); break; // Statement, 5 1/2 by 8 1/2 inches
1720 case wxPAPER_EXECUTIVE
: paper
= wxT("Executive"); break; // Executive, 7 1/4 by 10 1/2 inches
1721 case wxPAPER_A3
: paper
= wxT("A3"); break; // A3 sheet, 297 by 420 millimeters
1722 case wxPAPER_A5
: paper
= wxT("A5"); break; // A5 sheet, 148 by 210 millimeters
1723 case wxPAPER_B4
: paper
= wxT("B4"); break; // B4 sheet, 250 by 354 millimeters
1724 case wxPAPER_B5
: paper
= wxT("B5"); break; // B5 sheet, 182-by-257-millimeter paper
1725 case wxPAPER_FOLIO
: paper
= wxT("Folio"); break; // Folio, 8-1/2-by-13-inch paper
1726 case wxPAPER_QUARTO
: paper
= wxT("Quaro"); break; // Quarto, 215-by-275-millimeter paper
1727 case wxPAPER_10X14
: paper
= wxT("10x14"); break; // 10-by-14-inch sheet
1728 default: paper
= wxT("A4");
1731 buffer
.Printf( "%%%%DocumentPaperSizes: %s\n", paper
);
1734 PsPrint( "%%EndComments\n\n" );
1736 PsPrint( "%%BeginProlog\n" );
1737 PsPrint( wxPostScriptHeaderConicTo
);
1738 PsPrint( wxPostScriptHeaderEllipse
);
1739 PsPrint( wxPostScriptHeaderEllipticArc
);
1740 PsPrint( wxPostScriptHeaderColourImage
);
1741 PsPrint( wxPostScriptHeaderReencodeISO1
);
1742 PsPrint( wxPostScriptHeaderReencodeISO2
);
1743 if (wxPostScriptHeaderSpline
)
1744 PsPrint( wxPostScriptHeaderSpline
);
1745 PsPrint( "%%EndProlog\n" );
1747 SetBrush( *wxBLACK_BRUSH
);
1748 SetPen( *wxBLACK_PEN
);
1749 SetBackground( *wxWHITE_BRUSH
);
1750 SetTextForeground( *wxBLACK
);
1752 // set origin according to paper size
1753 SetDeviceOrigin( 0,0 );
1759 void wxPostScriptDC
::EndDoc ()
1761 wxCHECK_RET( m_ok
, wxT("invalid postscript dc") );
1766 PsPrint( "grestore\n" );
1770 fclose( m_pstream
);
1771 m_pstream
= (FILE *) NULL
;
1775 // THE FOLLOWING HAS BEEN CONTRIBUTED BY Andy Fyfe <andy@hyperparallel.com>
1776 wxCoord wx_printer_translate_x
, wx_printer_translate_y
;
1777 double wx_printer_scale_x
, wx_printer_scale_y
;
1779 wx_printer_translate_x
= (wxCoord
)m_printData
.GetPrinterTranslateX();
1780 wx_printer_translate_y
= (wxCoord
)m_printData
.GetPrinterTranslateY();
1782 wx_printer_scale_x
= m_printData
.GetPrinterScaleX();
1783 wx_printer_scale_y
= m_printData
.GetPrinterScaleY();
1785 // Compute the bounding box. Note that it is in the default user
1786 // coordinate system, thus we have to convert the values.
1787 wxCoord minX
= (wxCoord
) XLOG2DEV(m_minX
);
1788 wxCoord minY
= (wxCoord
) YLOG2DEV(m_minY
);
1789 wxCoord maxX
= (wxCoord
) XLOG2DEV(m_maxX
);
1790 wxCoord maxY
= (wxCoord
) YLOG2DEV(m_maxY
);
1792 // LOG2DEV may have changed the minimum to maximum vice versa
1793 if ( minX
> maxX
) { wxCoord tmp
= minX
; minX
= maxX
; maxX
= tmp
; }
1794 if ( minY
> maxY
) { wxCoord tmp
= minY
; minY
= maxY
; maxY
= tmp
; }
1796 // account for used scaling (boundingbox is before scaling in ps-file)
1797 double scale_x
= m_printData
.GetPrinterScaleX() / ms_PSScaleFactor
;
1798 double scale_y
= m_printData
.GetPrinterScaleY() / ms_PSScaleFactor
;
1800 wxCoord llx
, lly
, urx
, ury
;
1801 llx
= (wxCoord
) ((minX
+wx_printer_translate_x
)*scale_x
);
1802 lly
= (wxCoord
) ((minY
+wx_printer_translate_y
)*scale_y
);
1803 urx
= (wxCoord
) ((maxX
+wx_printer_translate_x
)*scale_x
);
1804 ury
= (wxCoord
) ((maxY
+wx_printer_translate_y
)*scale_y
);
1805 // (end of bounding box computation)
1808 // If we're landscape, our sense of "x" and "y" is reversed.
1809 if (m_printData
.GetOrientation() == wxLANDSCAPE
)
1812 tmp
= llx
; llx
= lly
; lly
= tmp
;
1813 tmp
= urx
; urx
= ury
; ury
= tmp
;
1815 // We need either the two lines that follow, or we need to subtract
1816 // min_x from real_translate_y, which is commented out below.
1817 llx
= llx
- (wxCoord
)(m_minX
*wx_printer_scale_y
);
1818 urx
= urx
- (wxCoord
)(m_minX
*wx_printer_scale_y
);
1821 // The Adobe specifications call for integers; we round as to make
1822 // the bounding larger.
1823 PsPrintf( wxT("%%%%BoundingBox: %d %d %d %d\n"),
1824 (wxCoord
)floor((double)llx
), (wxCoord
)floor((double)lly
),
1825 (wxCoord
)ceil((double)urx
), (wxCoord
)ceil((double)ury
) );
1827 // To check the correctness of the bounding box, postscript commands
1828 // to draw a box corresponding to the bounding box are generated below.
1829 // But since we typically don't want to print such a box, the postscript
1830 // commands are generated within comments. These lines appear before any
1831 // adjustment of scale, rotation, or translation, and hence are in the
1832 // default user coordinates.
1833 PsPrint( "% newpath\n" );
1834 PsPrintf( wxT("%% %d %d moveto\n"), llx
, lly
);
1835 PsPrintf( wxT("%% %d %d lineto\n"), urx
, lly
);
1836 PsPrintf( wxT("%% %d %d lineto\n"), urx
, ury
);
1837 PsPrintf( wxT("%% %d %d lineto closepath stroke\n"), llx
, ury
);
1841 wxPostScriptPrintNativeData
*data
=
1842 (wxPostScriptPrintNativeData
*) m_printData
.GetNativeData();
1844 if (m_ok
&& (m_printData
.GetPrintMode() == wxPRINT_MODE_PRINTER
))
1847 command
+= data
->GetPrinterCommand();
1848 command
+= wxT(" ");
1849 command
+= data
->GetPrinterOptions();
1850 command
+= wxT(" ");
1851 command
+= m_printData
.GetFilename();
1853 wxExecute( command
, true );
1854 wxRemoveFile( m_printData
.GetFilename() );
1859 void wxPostScriptDC
::StartPage()
1861 wxCHECK_RET( m_ok
, wxT("invalid postscript dc") );
1864 buffer
.Printf( wxT("%%%%Page: %d\n"), m_pageNumber
++ );
1868 wxPostScriptPrintNativeData
*data
=
1869 (wxPostScriptPrintNativeData
*) m_printData
.GetNativeData();
1871 wxCoord translate_x
= (wxCoord
)data
->GetPrinterTranslateX();
1872 wxCoord translate_y
= (wxCoord
)data
->GetPrinterTranslateY();
1874 buffer
.Printf( "%d %d translate\n", translate_x
, translate_y
);
1877 double scale_x
= data
->GetPrinterScaleX();
1878 double scale_y
= data
->GetPrinterScaleY();
1880 buffer
.Printf( "%f %f scale\n", scale_x
, scale_y
);
1881 buffer
.Replace( ",", "." );
1886 // Each page starts with an "initgraphics" which resets the
1887 // transformation and so we need to rotate the page for
1888 // landscape printing)
1890 // I copied this one from a PostScript tutorial, but to no avail. RR.
1891 // PsPrint( "90 rotate llx neg ury nef translate\n" );
1893 if (m_printData
.GetOrientation() == wxLANDSCAPE
)
1894 PsPrint( "90 rotate\n" );
1897 void wxPostScriptDC
::EndPage ()
1899 wxCHECK_RET( m_ok
, wxT("invalid postscript dc") );
1901 PsPrint( "showpage\n" );
1904 bool wxPostScriptDC
::DoBlit( wxCoord xdest
, wxCoord ydest
,
1905 wxCoord fwidth
, wxCoord fheight
,
1907 wxCoord xsrc
, wxCoord ysrc
,
1908 int rop
, bool WXUNUSED(useMask
), wxCoord
WXUNUSED(xsrcMask
), wxCoord
WXUNUSED(ysrcMask
) )
1910 wxCHECK_MSG( m_ok
, false, wxT("invalid postscript dc") );
1912 wxCHECK_MSG( source
, false, wxT("invalid source dc") );
1914 /* blit into a bitmap */
1915 wxBitmap
bitmap( (int)fwidth
, (int)fheight
);
1917 memDC
.SelectObject(bitmap
);
1918 memDC
.Blit(0, 0, fwidth
, fheight
, source
, xsrc
, ysrc
, rop
); /* TODO: Blit transparently? */
1919 memDC
.SelectObject(wxNullBitmap
);
1921 /* draw bitmap. scaling and positioning is done there */
1922 DrawBitmap( bitmap
, xdest
, ydest
);
1927 wxCoord wxPostScriptDC
::GetCharHeight() const
1930 return m_font
.GetPointSize();
1935 void wxPostScriptDC
::PsPrint( const wxString
& str
)
1937 const wxCharBuffer
psdata(str
.utf8_str());
1939 wxPostScriptPrintNativeData
*data
=
1940 (wxPostScriptPrintNativeData
*) m_printData
.GetNativeData();
1942 switch (m_printData
.GetPrintMode())
1945 // append to output stream
1946 case wxPRINT_MODE_STREAM
:
1948 wxOutputStream
* outputstream
= data
->GetOutputStream();
1949 wxCHECK_RET( outputstream
, wxT("invalid outputstream") );
1950 outputstream
->Write( psdata
, strlen( psdata
) );
1953 #endif // wxUSE_STREAMS
1955 // save data into file
1957 wxCHECK_RET( m_pstream
, wxT("invalid postscript dc") );
1958 fwrite( psdata
, 1, strlen( psdata
), m_pstream
);
1962 void wxPostScriptDC
::DoGetTextExtent(const wxString
& string
,
1963 wxCoord
*x
, wxCoord
*y
,
1964 wxCoord
*descent
, wxCoord
*externalLeading
,
1965 const wxFont
*theFont
) const
1967 const wxFont
*fontToUse
= theFont
;
1969 if (!fontToUse
) fontToUse
= &m_font
;
1971 wxCHECK_RET( fontToUse
, wxT("GetTextExtent: no font defined") );
1977 if (descent
) (*descent
) = 0;
1978 if (externalLeading
) (*externalLeading
) = 0;
1984 const wxWX2MBbuf strbuf
= string
.mb_str();
1986 // conversion failed (non e.g. ISO characters)
1987 if (strbuf
.data() == NULL
)
1990 #if !wxUSE_AFM_FOR_POSTSCRIPT
1991 /* Provide a VERY rough estimate (avoid using it).
1992 * Produces accurate results for mono-spaced font
1993 * such as Courier (aka wxMODERN) */
1998 height
= fontToUse
->GetPointSize();
2001 *x
= strlen (strbuf
) * height
* 72 / 120;
2003 *y
= (wxCoord
) (height
* 1.32); /* allow for descender */
2004 if (descent
) *descent
= 0;
2005 if (externalLeading
) *externalLeading
= 0;
2008 /* method for calculating string widths in postscript:
2009 / read in the AFM (adobe font metrics) file for the
2010 / actual font, parse it and extract the character widths
2011 / and also the descender. this may be improved, but for now
2012 / it works well. the AFM file is only read in if the
2013 / font is changed. this may be chached in the future.
2014 / calls to GetTextExtent with the font unchanged are rather
2017 / for each font and style used there is an AFM file necessary.
2018 / currently i have only files for the roman font family.
2019 / I try to get files for the other ones!
2021 / CAVE: the size of the string is currently always calculated
2022 / in 'points' (1/72 of an inch). this should later on be
2023 / changed to depend on the mapping mode.
2024 / CAVE: the path to the AFM files must be set before calling this
2025 / fun3B3Bction. this is usually done by a call like the following:
2026 / wxSetAFMPath("d:\\wxw161\\afm\\");
2030 / wxPostScriptDC dc(NULL, true);
2032 / wxSetAFMPath("d:\\wxw161\\afm\\");
2033 / dc.StartDoc("Test");
2036 / dc.SetFont(new wxFont(10, wxROMAN, wxNORMAL, wxNORMAL));
2037 / dc.GetTextExtent("Hallo",&w,&h);
2042 / by steve (stefan.hammes@urz.uni-heidelberg.de)
2044 / updated: 14.05.95 */
2046 /* these static vars are for storing the state between calls */
2047 static int lastFamily
= INT_MIN
;
2048 static int lastSize
= INT_MIN
;
2049 static int lastStyle
= INT_MIN
;
2050 static int lastWeight
= INT_MIN
;
2051 static int lastDescender
= INT_MIN
;
2052 static int lastWidths
[256]; /* widths of the characters */
2054 double UnderlinePosition
= 0.0;
2055 double UnderlineThickness
= 0.0;
2057 // Get actual parameters
2058 int Family
= fontToUse
->GetFamily();
2059 int Size
= fontToUse
->GetPointSize();
2060 int Style
= fontToUse
->GetStyle();
2061 int Weight
= fontToUse
->GetWeight();
2063 // If we have another font, read the font-metrics
2064 if (Family
!=lastFamily
|| Size
!=lastSize
|| Style
!=lastStyle
|| Weight
!=lastWeight
)
2066 // Store actual values
2067 lastFamily
= Family
;
2070 lastWeight
= Weight
;
2079 if ((Style
== wxITALIC
) && (Weight
== wxBOLD
)) name
= wxT("CourBoO.afm");
2080 else if ((Style
!= wxITALIC
) && (Weight
== wxBOLD
)) name
= wxT("CourBo.afm");
2081 else if ((Style
== wxITALIC
) && (Weight
!= wxBOLD
)) name
= wxT("CourO.afm");
2082 else name
= wxT("Cour.afm");
2087 if ((Style
== wxITALIC
) && (Weight
== wxBOLD
)) name
= wxT("TimesBoO.afm");
2088 else if ((Style
!= wxITALIC
) && (Weight
== wxBOLD
)) name
= wxT("TimesBo.afm");
2089 else if ((Style
== wxITALIC
) && (Weight
!= wxBOLD
)) name
= wxT("TimesO.afm");
2090 else name
= wxT("TimesRo.afm");
2095 name
= wxT("Zapf.afm");
2101 if ((Style
== wxITALIC
) && (Weight
== wxBOLD
)) name
= wxT("HelvBoO.afm");
2102 else if ((Style
!= wxITALIC
) && (Weight
== wxBOLD
)) name
= wxT("HelvBo.afm");
2103 else if ((Style
== wxITALIC
) && (Weight
!= wxBOLD
)) name
= wxT("HelvO.afm");
2104 else name
= wxT("Helv.afm");
2109 FILE *afmFile
= NULL
;
2111 // Get the directory of the AFM files
2114 // VZ: I don't know if the cast always works under Unix but it clearly
2115 // never does under Windows where the pointer is
2116 // wxWindowsPrintNativeData and so calling GetFontMetricPath() on
2119 wxPostScriptPrintNativeData
*data
=
2120 wxDynamicCast(m_printData
.GetNativeData(), wxPostScriptPrintNativeData
);
2122 if (data
&& !data
->GetFontMetricPath().empty())
2124 afmName
= data
->GetFontMetricPath();
2125 afmName
<< wxFILE_SEP_PATH
<< name
;
2129 if ( !afmName
.empty() )
2130 afmFile
= wxFopen(afmName
, wxT("r"));
2134 #if defined(__UNIX__) && !defined(__VMS__)
2135 afmName
= wxGetDataDir();
2137 afmName
= wxStandardPaths
::Get().GetDataDir();
2138 #endif // __UNIX__/!__UNIX__
2140 afmName
<< wxFILE_SEP_PATH
2141 #if defined(__LINUX__) || defined(__FREEBSD__)
2142 << wxT("gs_afm") << wxFILE_SEP_PATH
2144 << wxT("afm") << wxFILE_SEP_PATH
2147 afmFile
= wxFopen(afmName
,wxT("r"));
2150 /* 2. open and process the file
2151 / a short explanation of the AFM format:
2152 / we have for each character a line, which gives its size
2155 / C 63 ; WX 444 ; N question ; B 49 -14 395 676 ;
2157 / that means, we have a character with ascii code 63, and width
2158 / (444/1000 * fontSize) points.
2159 / the other data is ignored for now!
2161 / when the font has changed, we read in the right AFM file and store the
2162 / character widths in an array, which is processed below (see point 3.). */
2165 wxLogDebug( wxT("GetTextExtent: can't open AFM file '%s'"), afmName
.c_str() );
2166 wxLogDebug( wxT(" using approximate values"));
2167 for (int i
=0; i
<256; i
++) lastWidths
[i
] = 500; /* an approximate value */
2168 lastDescender
= -150; /* dito. */
2172 /* init the widths array */
2173 for(int i
=0; i
<256; i
++) lastWidths
[i
] = INT_MIN
;
2174 /* some variables for holding parts of a line */
2175 char cString
[10], semiString
[10], WXString
[10];
2176 char descString
[20];
2177 char upString
[30], utString
[30];
2181 /* read in the file and parse it */
2182 while(fgets(line
,sizeof(line
),afmFile
)!=NULL
)
2184 /* A.) check for descender definition */
2185 if (strncmp(line
,"Descender",9)==0)
2187 if ((sscanf(line
,"%s%d",descString
,&lastDescender
)!=2) ||
2188 (strcmp(descString
,"Descender")!=0))
2190 wxLogDebug( wxT("AFM-file '%s': line '%s' has error (bad descender)"), afmName
.c_str(),line
);
2193 /* JC 1.) check for UnderlinePosition */
2194 else if(strncmp(line
,"UnderlinePosition",17)==0)
2196 if ((sscanf(line
,"%s%lf",upString
,&UnderlinePosition
)!=2) ||
2197 (strcmp(upString
,"UnderlinePosition")!=0))
2199 wxLogDebug( wxT("AFM-file '%s': line '%s' has error (bad UnderlinePosition)"), afmName
.c_str(), line
);
2202 /* JC 2.) check for UnderlineThickness */
2203 else if(strncmp(line
,"UnderlineThickness",18)==0)
2205 if ((sscanf(line
,"%s%lf",utString
,&UnderlineThickness
)!=2) ||
2206 (strcmp(utString
,"UnderlineThickness")!=0))
2208 wxLogDebug( wxT("AFM-file '%s': line '%s' has error (bad UnderlineThickness)"), afmName
.c_str(), line
);
2211 /* JC 3.) check for EncodingScheme */
2212 else if(strncmp(line
,"EncodingScheme",14)==0)
2214 if ((sscanf(line
,"%s%s",utString
,encString
)!=2) ||
2215 (strcmp(utString
,"EncodingScheme")!=0))
2217 wxLogDebug( wxT("AFM-file '%s': line '%s' has error (bad EncodingScheme)"), afmName
.c_str(), line
);
2219 else if (strncmp(encString
, "AdobeStandardEncoding", 21))
2221 wxLogDebug( wxT("AFM-file '%s': line '%s' has error (unsupported EncodingScheme %s)"),
2222 afmName
.c_str(),line
, encString
);
2225 /* B.) check for char-width */
2226 else if(strncmp(line
,"C ",2)==0)
2228 if (sscanf(line
,"%s%d%s%s%d",cString
,&ascii
,semiString
,WXString
,&cWidth
)!=5)
2230 wxLogDebug(wxT("AFM-file '%s': line '%s' has an error (bad character width)"),afmName
.c_str(),line
);
2232 if(strcmp(cString
,"C")!=0 || strcmp(semiString
,";")!=0 || strcmp(WXString
,"WX")!=0)
2234 wxLogDebug(wxT("AFM-file '%s': line '%s' has a format error"),afmName
.c_str(),line
);
2236 /* printf(" char '%c'=%d has width '%d'\n",ascii,ascii,cWidth); */
2237 if (ascii
>=0 && ascii
<256)
2239 lastWidths
[ascii
] = cWidth
; /* store width */
2243 /* MATTHEW: this happens a lot; don't print an error */
2244 /* wxLogDebug("AFM-file '%s': ASCII value %d out of range",afmName.c_str(),ascii); */
2247 /* C.) ignore other entries. */
2251 /* hack to compute correct values for german 'Umlaute'
2252 / the correct way would be to map the character names
2253 / like 'adieresis' to corresp. positions of ISOEnc and read
2254 / these values from AFM files, too. Maybe later ... */
2256 // NB: casts to int are needed to suppress gcc 3.3 warnings
2257 lastWidths
[196] = lastWidths
[(int)'A']; // Ä
2258 lastWidths
[228] = lastWidths
[(int)'a']; // ä
2259 lastWidths
[214] = lastWidths
[(int)'O']; // Ö
2260 lastWidths
[246] = lastWidths
[(int)'o']; // ö
2261 lastWidths
[220] = lastWidths
[(int)'U']; // Ü
2262 lastWidths
[252] = lastWidths
[(int)'u']; // ü
2263 lastWidths
[223] = lastWidths
[(int)251]; // ß
2265 /* JC: calculate UnderlineThickness/UnderlinePosition */
2267 // VS: dirty, but is there any better solution?
2269 pt
= (double*) &m_underlinePosition
;
2270 *pt
= YLOG2DEVREL((wxCoord
)(UnderlinePosition
* fontToUse
->GetPointSize())) / 1000.0f
;
2271 pt
= (double*) &m_underlineThickness
;
2272 *pt
= YLOG2DEVREL((wxCoord
)(UnderlineThickness
* fontToUse
->GetPointSize())) / 1000.0f
;
2277 /* 3. now the font metrics are read in, calc size this
2278 / is done by adding the widths of the characters in the
2279 / string. they are given in 1/1000 of the size! */
2282 wxCoord height
=Size
; /* by default */
2284 for(p
=(unsigned char *)wxMBSTRINGCAST strbuf
; *p
; p
++)
2286 if(lastWidths
[*p
]== INT_MIN
)
2288 wxLogDebug(wxT("GetTextExtent: undefined width for character '%c' (%d)"), *p
,*p
);
2289 sum
+= lastWidths
[(unsigned char)' ']; /* assume space */
2293 sum
+= lastWidths
[*p
];
2297 double widthSum
= sum
;
2299 widthSum
/= 1000.0F
;
2301 /* add descender to height (it is usually a negative value) */
2302 //if (lastDescender != INT_MIN)
2304 // height += (wxCoord)(((-lastDescender)/1000.0F) * Size); /* MATTHEW: forgot scale */
2306 // - commented by V. Slavik - height already contains descender in it
2307 // (judging from few experiments)
2309 /* return size values */
2311 *x
= (wxCoord
)widthSum
;
2315 /* return other parameters */
2318 if(lastDescender
!=INT_MIN
)
2320 *descent
= (wxCoord
)(((-lastDescender
)/1000.0F
) * Size
); /* MATTHEW: forgot scale */
2328 /* currently no idea how to calculate this! */
2329 if (externalLeading
) *externalLeading
= 0;
2335 #endif // wxUSE_PRINTING_ARCHITECTURE && wxUSE_POSTSCRIPT