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/filename.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 const 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 const 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 IMPLEMENT_DYNAMIC_CLASS(wxPostScriptDC
, wxDC
)
241 wxPostScriptDC::wxPostScriptDC()
242 : wxDC(new wxPostScriptDCImpl(this))
246 wxPostScriptDC::wxPostScriptDC(const wxPrintData
& printData
)
247 : wxDC(new wxPostScriptDCImpl(this, printData
))
252 static const double RAD2DEG
= 180.0 / M_PI
;
254 // we don't want to use only 72 dpi from PS print
255 static const int DPI
= 600;
256 static const double PS2DEV
= 600.0 / 72.0;
257 static const double DEV2PS
= 72.0 / 600.0;
259 #define XLOG2DEV(x) ((double)(LogicalToDeviceX(x)) * DEV2PS)
260 #define XLOG2DEVREL(x) ((double)(LogicalToDeviceXRel(x)) * DEV2PS)
261 #define YLOG2DEV(x) ((m_pageHeight - (double)LogicalToDeviceY(x)) * DEV2PS)
262 #define YLOG2DEVREL(x) ((double)(LogicalToDeviceYRel(x)) * DEV2PS)
265 IMPLEMENT_ABSTRACT_CLASS(wxPostScriptDCImpl
, wxDCImpl
)
267 //-------------------------------------------------------------------------------
269 wxPostScriptDCImpl::wxPostScriptDCImpl( wxPostScriptDC
*owner
) :
274 m_pageHeight
= 842 * PS2DEV
;
279 wxPostScriptDCImpl::wxPostScriptDCImpl( wxPostScriptDC
*owner
, const wxPrintData
& data
) :
284 // this calculates m_pageHeight required for
285 // taking the inverted Y axis into account
286 SetPrintData( data
);
292 wxPostScriptDCImpl::wxPostScriptDCImpl( wxPrinterDC
*owner
) :
297 m_pageHeight
= 842 * PS2DEV
;
302 wxPostScriptDCImpl::wxPostScriptDCImpl( wxPrinterDC
*owner
, const wxPrintData
& data
) :
307 // this calculates m_pageHeight required for
308 // taking the inverted Y axis into account
309 SetPrintData( data
);
314 void wxPostScriptDCImpl::Init()
326 m_underlinePosition
= 0.0;
327 m_underlineThickness
= 0.0;
331 wxPostScriptDCImpl::~wxPostScriptDCImpl ()
340 bool wxPostScriptDCImpl::IsOk() const
345 wxRect
wxPostScriptDCImpl::GetPaperRect() const
350 return wxRect(0,0,w
,h
);
353 int wxPostScriptDCImpl::GetResolution() const
358 void wxPostScriptDCImpl::DoSetClippingRegion (wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
)
360 wxCHECK_RET( m_ok
, wxT("invalid postscript dc") );
363 DestroyClippingRegion();
373 buffer
.Printf( "gsave\n"
379 "closepath clip newpath\n",
380 XLOG2DEV(x
), YLOG2DEV(y
),
381 XLOG2DEV(x
+w
), YLOG2DEV(y
),
382 XLOG2DEV(x
+w
), YLOG2DEV(y
+h
),
383 XLOG2DEV(x
), YLOG2DEV(y
+h
) );
384 buffer
.Replace( ",", "." );
389 void wxPostScriptDCImpl::DestroyClippingRegion()
391 wxCHECK_RET( m_ok
, wxT("invalid postscript dc") );
396 PsPrint( "grestore\n" );
399 wxDCImpl::DestroyClippingRegion();
402 void wxPostScriptDCImpl::Clear()
404 // This should fail silently to avoid unnecessary
406 // wxFAIL_MSG( wxT("wxPostScriptDCImpl::Clear not implemented.") );
409 bool wxPostScriptDCImpl::DoFloodFill (wxCoord
WXUNUSED(x
), wxCoord
WXUNUSED(y
), const wxColour
&WXUNUSED(col
), wxFloodFillStyle
WXUNUSED(style
))
411 wxFAIL_MSG( wxT("wxPostScriptDCImpl::FloodFill not implemented.") );
415 bool wxPostScriptDCImpl::DoGetPixel (wxCoord
WXUNUSED(x
), wxCoord
WXUNUSED(y
), wxColour
* WXUNUSED(col
)) const
417 wxFAIL_MSG( wxT("wxPostScriptDCImpl::GetPixel not implemented.") );
421 void wxPostScriptDCImpl::DoCrossHair (wxCoord
WXUNUSED(x
), wxCoord
WXUNUSED(y
))
423 wxFAIL_MSG( wxT("wxPostScriptDCImpl::CrossHair not implemented.") );
426 void wxPostScriptDCImpl::DoDrawLine (wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
428 wxCHECK_RET( m_ok
, wxT("invalid postscript dc") );
430 if ( m_pen
.IsTransparent() )
436 buffer
.Printf( "newpath\n"
440 XLOG2DEV(x1
), YLOG2DEV(y1
),
441 XLOG2DEV(x2
), YLOG2DEV(y2
) );
442 buffer
.Replace( ",", "." );
445 CalcBoundingBox( x1
, y1
);
446 CalcBoundingBox( x2
, y2
);
449 void wxPostScriptDCImpl::DoDrawArc (wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
, wxCoord xc
, wxCoord yc
)
451 wxCHECK_RET( m_ok
, wxT("invalid postscript dc") );
453 wxCoord dx
= x1
- xc
;
454 wxCoord dy
= y1
- yc
;
455 double radius
= sqrt( (double)(dx
*dx
+dy
*dy
) );
456 double alpha1
, alpha2
;
458 if (x1
== x2
&& y1
== y2
)
463 else if ( wxIsNullDouble(radius
) )
470 alpha1
= (x1
- xc
== 0) ?
471 (y1
- yc
< 0) ? 90.0 : -90.0 :
472 -atan2(double(y1
-yc
), double(x1
-xc
)) * RAD2DEG
;
473 alpha2
= (x2
- xc
== 0) ?
474 (y2
- yc
< 0) ? 90.0 : -90.0 :
475 -atan2(double(y2
-yc
), double(x2
-xc
)) * RAD2DEG
;
477 while (alpha1
<= 0) alpha1
+= 360;
478 while (alpha2
<= 0) alpha2
+= 360; // adjust angles to be between
479 while (alpha1
> 360) alpha1
-= 360; // 0 and 360 degree
480 while (alpha2
> 360) alpha2
-= 360;
482 int i_radius
= wxRound( radius
);
484 if ( m_brush
.IsNonTransparent() )
489 buffer
.Printf( "newpath\n"
490 "%f %f %f %f %f %f ellipse\n"
494 XLOG2DEV(xc
), YLOG2DEV(yc
),
495 XLOG2DEVREL(i_radius
), YLOG2DEVREL(i_radius
),
497 XLOG2DEV(xc
), YLOG2DEV(yc
) );
498 buffer
.Replace( ",", "." );
501 CalcBoundingBox( xc
-i_radius
, yc
-i_radius
);
502 CalcBoundingBox( xc
+i_radius
, yc
+i_radius
);
505 if ( m_pen
.IsNonTransparent() )
510 buffer
.Printf( "newpath\n"
511 "%f %f %f %f %f %f ellipse\n"
515 XLOG2DEV(xc
), YLOG2DEV(yc
),
516 XLOG2DEVREL(i_radius
), YLOG2DEVREL(i_radius
),
518 XLOG2DEV(xc
), YLOG2DEV(yc
) );
519 buffer
.Replace( ",", "." );
522 CalcBoundingBox( xc
-i_radius
, yc
-i_radius
);
523 CalcBoundingBox( xc
+i_radius
, yc
+i_radius
);
527 void wxPostScriptDCImpl::DoDrawEllipticArc(wxCoord x
,wxCoord y
,wxCoord w
,wxCoord h
,double sa
,double ea
)
529 wxCHECK_RET( m_ok
, wxT("invalid postscript dc") );
531 if ( sa
>= 360 || sa
<= -360 )
532 sa
-= int(sa
/360)*360;
533 if ( ea
>= 360 || ea
<=- 360 )
534 ea
-= int(ea
/360)*360;
540 if ( wxIsSameDouble(sa
, ea
) )
542 DoDrawEllipse(x
,y
,w
,h
);
546 if ( m_brush
.IsNonTransparent() )
551 buffer
.Printf( "newpath\n"
552 "%f %f %f %f %f %f true ellipticarc\n",
553 XLOG2DEV(x
+w
/2), YLOG2DEV(y
+h
/2),
554 XLOG2DEVREL(w
/2), YLOG2DEVREL(h
/2),
556 buffer
.Replace( ",", "." );
559 CalcBoundingBox( x
,y
);
560 CalcBoundingBox( x
+w
, y
+h
);
563 if ( m_pen
.IsNonTransparent() )
568 buffer
.Printf( "newpath\n"
569 "%f %f %f %f %f %f false ellipticarc\n",
570 XLOG2DEV(x
+w
/2), YLOG2DEV(y
+h
/2),
571 XLOG2DEVREL(w
/2), YLOG2DEVREL(h
/2),
573 buffer
.Replace( ",", "." );
576 CalcBoundingBox( x
,y
);
577 CalcBoundingBox( x
+w
, y
+h
);
581 void wxPostScriptDCImpl::DoDrawPoint (wxCoord x
, wxCoord y
)
583 wxCHECK_RET( m_ok
, wxT("invalid postscript dc") );
585 if ( m_pen
.IsTransparent() )
591 buffer
.Printf( "newpath\n"
595 XLOG2DEV(x
), YLOG2DEV(y
),
596 XLOG2DEV(x
+1), YLOG2DEV(y
) );
597 buffer
.Replace( ",", "." );
600 CalcBoundingBox( x
, y
);
603 void wxPostScriptDCImpl::DoDrawPolygon (int n
, wxPoint points
[], wxCoord xoffset
, wxCoord yoffset
, wxPolygonFillMode fillStyle
)
605 wxCHECK_RET( m_ok
, wxT("invalid postscript dc") );
609 if ( m_brush
.IsNonTransparent() )
613 PsPrint( "newpath\n" );
615 double xx
= XLOG2DEV(points
[0].x
+ xoffset
);
616 double yy
= YLOG2DEV(points
[0].y
+ yoffset
);
619 buffer
.Printf( "%f %f moveto\n", xx
, yy
);
620 buffer
.Replace( ",", "." );
623 CalcBoundingBox( points
[0].x
+ xoffset
, points
[0].y
+ yoffset
);
625 for (int i
= 1; i
< n
; i
++)
627 xx
= XLOG2DEV(points
[i
].x
+ xoffset
);
628 yy
= YLOG2DEV(points
[i
].y
+ yoffset
);
630 buffer
.Printf( "%f %f lineto\n", xx
, yy
);
631 buffer
.Replace( ",", "." );
634 CalcBoundingBox( points
[i
].x
+ xoffset
, points
[i
].y
+ yoffset
);
637 PsPrint( (fillStyle
== wxODDEVEN_RULE
? "eofill\n" : "fill\n") );
640 if ( m_pen
.IsNonTransparent() )
644 PsPrint( "newpath\n" );
646 double xx
= XLOG2DEV(points
[0].x
+ xoffset
);
647 double yy
= YLOG2DEV(points
[0].y
+ yoffset
);
650 buffer
.Printf( "%f %f moveto\n", xx
, yy
);
651 buffer
.Replace( ",", "." );
654 CalcBoundingBox( points
[0].x
+ xoffset
, points
[0].y
+ yoffset
);
656 for (int i
= 1; i
< n
; i
++)
658 xx
= XLOG2DEV(points
[i
].x
+ xoffset
);
659 yy
= YLOG2DEV(points
[i
].y
+ yoffset
);
661 buffer
.Printf( "%f %f lineto\n", xx
, yy
);
662 buffer
.Replace( ",", "." );
665 CalcBoundingBox( points
[i
].x
+ xoffset
, points
[i
].y
+ yoffset
);
668 PsPrint( "closepath\n" );
669 PsPrint( "stroke\n" );
673 void wxPostScriptDCImpl::DoDrawPolyPolygon (int n
, int count
[], wxPoint points
[], wxCoord xoffset
, wxCoord yoffset
, wxPolygonFillMode fillStyle
)
675 wxCHECK_RET( m_ok
, wxT("invalid postscript dc") );
679 if ( m_brush
.IsNonTransparent() )
683 PsPrint( "newpath\n" );
686 for (int i
= 0; i
< n
; ofs
+= count
[i
++])
688 double xx
= XLOG2DEV(points
[ofs
].x
+ xoffset
);
689 double yy
= YLOG2DEV(points
[ofs
].y
+ yoffset
);
692 buffer
.Printf( "%f %f moveto\n", xx
, yy
);
693 buffer
.Replace( ",", "." );
696 CalcBoundingBox( points
[ofs
].x
+ xoffset
, points
[ofs
].y
+ yoffset
);
698 for (int j
= 1; j
< count
[i
]; j
++)
700 xx
= XLOG2DEV(points
[ofs
+j
].x
+ xoffset
);
701 yy
= YLOG2DEV(points
[ofs
+j
].y
+ yoffset
);
703 buffer
.Printf( "%f %f lineto\n", xx
, yy
);
704 buffer
.Replace( ",", "." );
707 CalcBoundingBox( points
[ofs
+j
].x
+ xoffset
, points
[ofs
+j
].y
+ yoffset
);
710 PsPrint( (fillStyle
== wxODDEVEN_RULE
? "eofill\n" : "fill\n") );
713 if ( m_pen
.IsNonTransparent() )
717 PsPrint( "newpath\n" );
720 for (int i
= 0; i
< n
; ofs
+= count
[i
++])
722 double xx
= XLOG2DEV(points
[ofs
].x
+ xoffset
);
723 double yy
= YLOG2DEV(points
[ofs
].y
+ yoffset
);
726 buffer
.Printf( "%f %f moveto\n", xx
, yy
);
727 buffer
.Replace( ",", "." );
730 CalcBoundingBox( points
[ofs
].x
+ xoffset
, points
[ofs
].y
+ yoffset
);
732 for (int j
= 1; j
< count
[i
]; j
++)
734 xx
= XLOG2DEV(points
[ofs
+j
].x
+ xoffset
);
735 yy
= YLOG2DEV(points
[ofs
+j
].y
+ yoffset
);
737 buffer
.Printf( "%f %f lineto\n", xx
, yy
);
738 buffer
.Replace( ",", "." );
741 CalcBoundingBox( points
[ofs
+j
].x
+ xoffset
, points
[ofs
+j
].y
+ yoffset
);
744 PsPrint( "closepath\n" );
745 PsPrint( "stroke\n" );
749 void wxPostScriptDCImpl::DoDrawLines (int n
, wxPoint points
[], wxCoord xoffset
, wxCoord yoffset
)
751 wxCHECK_RET( m_ok
, wxT("invalid postscript dc") );
753 if ( m_pen
.IsTransparent() )
761 for ( i
=0; i
<n
; i
++ )
762 CalcBoundingBox( points
[i
].x
+xoffset
, points
[i
].y
+yoffset
);
765 buffer
.Printf( "newpath\n"
767 XLOG2DEV(points
[0].x
+xoffset
),
768 YLOG2DEV(points
[0].y
+yoffset
) );
769 buffer
.Replace( ",", "." );
772 for (i
= 1; i
< n
; i
++)
774 buffer
.Printf( "%f %f lineto\n",
775 XLOG2DEV(points
[i
].x
+xoffset
),
776 YLOG2DEV(points
[i
].y
+yoffset
) );
777 buffer
.Replace( ",", "." );
781 PsPrint( "stroke\n" );
784 void wxPostScriptDCImpl::DoDrawRectangle (wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
786 wxCHECK_RET( m_ok
, wxT("invalid postscript dc") );
791 if ( m_brush
.IsNonTransparent() )
796 buffer
.Printf( "newpath\n"
803 XLOG2DEV(x
), YLOG2DEV(y
),
804 XLOG2DEV(x
+ width
), YLOG2DEV(y
),
805 XLOG2DEV(x
+ width
), YLOG2DEV(y
+ height
),
806 XLOG2DEV(x
), YLOG2DEV(y
+ height
) );
807 buffer
.Replace( ",", "." );
810 CalcBoundingBox( x
, y
);
811 CalcBoundingBox( x
+ width
, y
+ height
);
814 if ( m_pen
.IsNonTransparent() )
819 buffer
.Printf( "newpath\n"
826 XLOG2DEV(x
), YLOG2DEV(y
),
827 XLOG2DEV(x
+ width
), YLOG2DEV(y
),
828 XLOG2DEV(x
+ width
), YLOG2DEV(y
+ height
),
829 XLOG2DEV(x
), YLOG2DEV(y
+ height
) );
830 buffer
.Replace( ",", "." );
833 CalcBoundingBox( x
, y
);
834 CalcBoundingBox( x
+ width
, y
+ height
);
838 void wxPostScriptDCImpl::DoDrawRoundedRectangle (wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
, double radius
)
840 wxCHECK_RET( m_ok
, wxT("invalid postscript dc") );
847 // Now, a negative radius is interpreted to mean
848 // 'the proportion of the smallest X or Y dimension'
849 double smallest
= width
< height
? width
: height
;
850 radius
= (-radius
* smallest
);
853 wxCoord rad
= (wxCoord
) radius
;
855 if ( m_brush
.IsNonTransparent() )
859 /* Draw rectangle anticlockwise */
861 buffer
.Printf( "newpath\n"
862 "%f %f %f 90 180 arc\n"
864 "%f %f %f 180 270 arc\n"
866 "%f %f %f 270 0 arc\n"
868 "%f %f %f 0 90 arc\n"
872 XLOG2DEV(x
+ rad
), YLOG2DEV(y
+ rad
), XLOG2DEVREL(rad
),
873 XLOG2DEV(x
), YLOG2DEV(y
+ height
- rad
),
874 XLOG2DEV(x
+ rad
), YLOG2DEV(y
+ height
- rad
), XLOG2DEVREL(rad
),
875 XLOG2DEV(x
+ width
- rad
), YLOG2DEV(y
+ height
),
876 XLOG2DEV(x
+ width
- rad
), YLOG2DEV(y
+ height
- rad
), XLOG2DEVREL(rad
),
877 XLOG2DEV(x
+ width
), YLOG2DEV(y
+ rad
),
878 XLOG2DEV(x
+ width
- rad
), YLOG2DEV(y
+ rad
), XLOG2DEVREL(rad
),
879 XLOG2DEV(x
+ rad
), YLOG2DEV(y
) );
880 buffer
.Replace( ",", "." );
883 CalcBoundingBox( x
, y
);
884 CalcBoundingBox( x
+ width
, y
+ height
);
887 if ( m_pen
.IsNonTransparent() )
891 /* Draw rectangle anticlockwise */
893 buffer
.Printf( "newpath\n"
894 "%f %f %f 90 180 arc\n"
896 "%f %f %f 180 270 arc\n"
898 "%f %f %f 270 0 arc\n"
900 "%f %f %f 0 90 arc\n"
904 XLOG2DEV(x
+ rad
), YLOG2DEV(y
+ rad
), XLOG2DEVREL(rad
),
905 XLOG2DEV(x
), YLOG2DEV(y
+ height
- rad
),
906 XLOG2DEV(x
+ rad
), YLOG2DEV(y
+ height
- rad
), XLOG2DEVREL(rad
),
907 XLOG2DEV(x
+ width
- rad
), YLOG2DEV(y
+ height
),
908 XLOG2DEV(x
+ width
- rad
), YLOG2DEV(y
+ height
- rad
), XLOG2DEVREL(rad
),
909 XLOG2DEV(x
+ width
), YLOG2DEV(y
+ rad
),
910 XLOG2DEV(x
+ width
- rad
), YLOG2DEV(y
+ rad
), XLOG2DEVREL(rad
),
911 XLOG2DEV(x
+ rad
), YLOG2DEV(y
) );
912 buffer
.Replace( ",", "." );
915 CalcBoundingBox( x
, y
);
916 CalcBoundingBox( x
+ width
, y
+ height
);
920 void wxPostScriptDCImpl::DoDrawEllipse (wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
922 wxCHECK_RET( m_ok
, wxT("invalid postscript dc") );
927 if ( m_brush
.IsNonTransparent() )
932 buffer
.Printf( "newpath\n"
933 "%f %f %f %f 0 360 ellipse\n"
935 XLOG2DEV(x
+ width
/ 2), YLOG2DEV(y
+ height
/ 2),
936 XLOG2DEVREL(width
/ 2), YLOG2DEVREL(height
/ 2) );
937 buffer
.Replace( ",", "." );
940 CalcBoundingBox( x
- width
, y
- height
);
941 CalcBoundingBox( x
+ width
, y
+ height
);
944 if ( m_pen
.IsNonTransparent() )
949 buffer
.Printf( "newpath\n"
950 "%f %f %f %f 0 360 ellipse\n"
952 XLOG2DEV(x
+ width
/ 2), YLOG2DEV(y
+ height
/ 2),
953 XLOG2DEVREL(width
/ 2), YLOG2DEVREL(height
/ 2) );
954 buffer
.Replace( ",", "." );
957 CalcBoundingBox( x
- width
, y
- height
);
958 CalcBoundingBox( x
+ width
, y
+ height
);
962 void wxPostScriptDCImpl::DoDrawIcon( const wxIcon
& icon
, wxCoord x
, wxCoord y
)
964 DoDrawBitmap( icon
, x
, y
, true );
967 /* this has to be char, not wxChar */
968 static const char hexArray
[] = "0123456789ABCDEF";
970 void wxPostScriptDCImpl::DoDrawBitmap( const wxBitmap
& bitmap
, wxCoord x
, wxCoord y
, bool WXUNUSED(useMask
) )
972 wxCHECK_RET( m_ok
, wxT("invalid postscript dc") );
974 if (!bitmap
.Ok()) return;
976 wxImage image
= bitmap
.ConvertToImage();
978 if (!image
.Ok()) return;
980 wxCoord w
= image
.GetWidth();
981 wxCoord h
= image
.GetHeight();
983 double ww
= XLOG2DEVREL(image
.GetWidth());
984 double hh
= YLOG2DEVREL(image
.GetHeight());
986 double xx
= XLOG2DEV(x
);
987 double yy
= YLOG2DEV(y
+ bitmap
.GetHeight());
990 buffer
.Printf( "/origstate save def\n"
992 "/pix %d string def\n"
993 "/grays %d string def\n"
1000 "{currentfile pix readhexstring pop}\n"
1001 "false 3 colorimage\n",
1002 w
, w
, xx
, yy
, ww
, hh
, w
, h
, w
, -h
, h
);
1003 buffer
.Replace( ",", "." );
1006 unsigned char* data
= image
.GetData();
1008 // size of the buffer = width*rgb(3)*hexa(2)+'\n'
1009 wxCharBuffer
charbuffer(w
*6 + 1);
1010 int firstDigit
, secondDigit
;
1013 for (int j
= 0; j
< h
; j
++)
1015 char* bufferindex
= charbuffer
.data();
1018 for (int i
= 0; i
< w
*3; i
++)
1020 firstDigit
= (int)(*data
/16.0);
1021 secondDigit
= (int)(*data
- (firstDigit
*16.0));
1022 *(bufferindex
++) = hexArray
[firstDigit
];
1023 *(bufferindex
++) = hexArray
[secondDigit
];
1027 *(bufferindex
++) = '\n';
1031 fwrite( charbuffer
, 1, strlen( charbuffer
), m_pstream
);
1033 PsPrint( charbuffer
);
1037 PsPrint( "origstate restore\n" );
1040 void wxPostScriptDCImpl::SetFont( const wxFont
& font
)
1042 wxCHECK_RET( m_ok
, wxT("invalid postscript dc") );
1044 if (!font
.Ok()) return;
1048 int Style
= m_font
.GetStyle();
1049 int Weight
= m_font
.GetWeight();
1052 switch (m_font
.GetFamily())
1057 if (Style
== wxITALIC
)
1059 if (Weight
== wxBOLD
)
1060 name
= "/Courier-BoldOblique";
1062 name
= "/Courier-Oblique";
1066 if (Weight
== wxBOLD
)
1067 name
= "/Courier-Bold";
1075 if (Style
== wxITALIC
)
1077 if (Weight
== wxBOLD
)
1078 name
= "/Times-BoldItalic";
1080 name
= "/Times-Italic";
1084 if (Weight
== wxBOLD
)
1085 name
= "/Times-Bold";
1087 name
= "/Times-Roman";
1093 name
= "/ZapfChancery-MediumItalic";
1099 if (Style
== wxITALIC
)
1101 if (Weight
== wxBOLD
)
1102 name
= "/Helvetica-BoldOblique";
1104 name
= "/Helvetica-Oblique";
1108 if (Weight
== wxBOLD
)
1109 name
= "/Helvetica-Bold";
1111 name
= "/Helvetica";
1117 // We may legitimately call SetFont before BeginDoc
1122 PsPrint( " reencodeISO def\n" );
1124 PsPrint( " findfont\n" );
1127 float size
= float(m_font
.GetPointSize());
1128 size
= size
* GetFontPointSizeAdjustment(DPI
);
1130 buffer
.Printf( "%f scalefont setfont\n", size
* m_scaleX
);
1131 buffer
.Replace( ",", "." );
1135 void wxPostScriptDCImpl::SetPen( const wxPen
& pen
)
1137 wxCHECK_RET( m_ok
, wxT("invalid postscript dc") );
1139 if (!pen
.Ok()) return;
1141 int oldStyle
= m_pen
.GetStyle();
1147 if (m_pen
.GetWidth() <= 0)
1150 width
= (double) m_pen
.GetWidth();
1153 buffer
.Printf( "%f setlinewidth\n", width
* DEV2PS
* m_scaleX
);
1154 buffer
.Replace( ",", "." );
1158 Line style - WRONG: 2nd arg is OFFSET
1160 Here, I'm afraid you do not conceive meaning of parameters of 'setdash'
1161 operator correctly. You should look-up this in the Red Book: the 2nd parame-
1162 ter is not number of values in the array of the first one, but an offset
1163 into this description of the pattern. I mean a real *offset* not index
1164 into array. I.e. If the command is [3 4] 1 setdash is used, then there
1165 will be first black line *2* units wxCoord, then space 4 units, then the
1166 pattern of *3* units black, 4 units space will be repeated.
1169 static const char *dotted
= "[2 5] 2";
1170 static const char *short_dashed
= "[4 4] 2";
1171 static const char *wxCoord_dashed
= "[4 8] 2";
1172 static const char *dotted_dashed
= "[6 6 2 6] 4";
1176 switch (m_pen
.GetStyle())
1178 case wxPENSTYLE_DOT
: psdash
= dotted
; break;
1179 case wxPENSTYLE_SHORT_DASH
: psdash
= short_dashed
; break;
1180 case wxPENSTYLE_LONG_DASH
: psdash
= wxCoord_dashed
; break;
1181 case wxPENSTYLE_DOT_DASH
: psdash
= dotted_dashed
; break;
1182 case wxPENSTYLE_USER_DASH
:
1185 int nDashes
= m_pen
.GetDashes (&dashes
);
1187 for (int i
= 0; i
< nDashes
; ++i
)
1189 buffer
.Printf( "%d ", dashes
[i
] );
1192 PsPrint ("] 0 setdash\n");
1196 case wxPENSTYLE_SOLID
:
1197 case wxPENSTYLE_TRANSPARENT
:
1198 default: psdash
= "[] 0"; break;
1201 if ( psdash
&& (oldStyle
!= m_pen
.GetStyle()) )
1204 PsPrint( " setdash\n" );
1208 unsigned char red
= m_pen
.GetColour().Red();
1209 unsigned char blue
= m_pen
.GetColour().Blue();
1210 unsigned char green
= m_pen
.GetColour().Green();
1214 // Anything not white is black
1215 if (! (red
== (unsigned char) 255 &&
1216 blue
== (unsigned char) 255 &&
1217 green
== (unsigned char) 255) )
1219 red
= (unsigned char) 0;
1220 green
= (unsigned char) 0;
1221 blue
= (unsigned char) 0;
1226 if (!(red
== m_currentRed
&& green
== m_currentGreen
&& blue
== m_currentBlue
))
1228 double redPS
= (double)(red
) / 255.0;
1229 double bluePS
= (double)(blue
) / 255.0;
1230 double greenPS
= (double)(green
) / 255.0;
1232 buffer
.Printf( "%f %f %f setrgbcolor\n", redPS
, greenPS
, bluePS
);
1233 buffer
.Replace( ",", "." );
1237 m_currentBlue
= blue
;
1238 m_currentGreen
= green
;
1242 void wxPostScriptDCImpl::SetBrush( const wxBrush
& brush
)
1244 wxCHECK_RET( m_ok
, wxT("invalid postscript dc") );
1246 if (!brush
.Ok()) return;
1251 unsigned char red
= m_brush
.GetColour().Red();
1252 unsigned char blue
= m_brush
.GetColour().Blue();
1253 unsigned char green
= m_brush
.GetColour().Green();
1257 // Anything not white is black
1258 if (! (red
== (unsigned char) 255 &&
1259 blue
== (unsigned char) 255 &&
1260 green
== (unsigned char) 255) )
1262 red
= (unsigned char) 0;
1263 green
= (unsigned char) 0;
1264 blue
= (unsigned char) 0;
1269 if (!(red
== m_currentRed
&& green
== m_currentGreen
&& blue
== m_currentBlue
))
1271 double redPS
= (double)(red
) / 255.0;
1272 double bluePS
= (double)(blue
) / 255.0;
1273 double greenPS
= (double)(green
) / 255.0;
1276 buffer
.Printf( "%f %f %f setrgbcolor\n", redPS
, greenPS
, bluePS
);
1277 buffer
.Replace( ",", "." );
1281 m_currentBlue
= blue
;
1282 m_currentGreen
= green
;
1286 void wxPostScriptDCImpl::DoDrawText( const wxString
& text
, wxCoord x
, wxCoord y
)
1288 wxCHECK_RET( m_ok
, wxT("invalid postscript dc") );
1290 const wxWX2MBbuf textbuf
= text
.mb_str();
1294 if (m_textForegroundColour
.Ok())
1296 unsigned char red
= m_textForegroundColour
.Red();
1297 unsigned char blue
= m_textForegroundColour
.Blue();
1298 unsigned char green
= m_textForegroundColour
.Green();
1302 // Anything not white is black
1303 if (! (red
== (unsigned char) 255 &&
1304 blue
== (unsigned char) 255 &&
1305 green
== (unsigned char) 255))
1307 red
= (unsigned char) 0;
1308 green
= (unsigned char) 0;
1309 blue
= (unsigned char) 0;
1313 // maybe setgray here ?
1314 if (!(red
== m_currentRed
&& green
== m_currentGreen
&& blue
== m_currentBlue
))
1316 double redPS
= (double)(red
) / 255.0;
1317 double bluePS
= (double)(blue
) / 255.0;
1318 double greenPS
= (double)(green
) / 255.0;
1321 buffer
.Printf( "%f %f %f setrgbcolor\n", redPS
, greenPS
, bluePS
);
1322 buffer
.Replace( ",", "." );
1326 m_currentBlue
= blue
;
1327 m_currentGreen
= green
;
1331 wxCoord text_w
, text_h
, text_descent
;
1333 GetOwner()->GetTextExtent(text
, &text_w
, &text_h
, &text_descent
);
1335 int size
= m_font
.GetPointSize();
1337 // wxCoord by = y + (wxCoord)floor( double(size) * 2.0 / 3.0 ); // approximate baseline
1338 // commented by V. Slavik and replaced by accurate version
1339 // - note that there is still rounding error in text_descent!
1340 wxCoord by
= y
+ size
- text_descent
; // baseline
1343 buffer
.Printf( "%f %f moveto\n", XLOG2DEV(x
), YLOG2DEV(by
) );
1344 buffer
.Replace( ",", "." );
1348 for ( const char *p
= textbuf
; *p
!= '\0'; p
++ )
1350 int c
= (unsigned char)*p
;
1351 if (c
== ')' || c
== '(' || c
== '\\')
1353 /* Cope with special characters */
1355 PsPrint( (char) c
);
1357 else if ( c
>= 128 )
1359 /* Cope with character codes > 127 */
1360 buffer
.Printf( "\\%o", c
);
1365 PsPrint( (char) c
);
1369 PsPrint( ") show\n" );
1371 if (m_font
.GetUnderlined())
1373 wxCoord uy
= (wxCoord
)(y
+ size
- m_underlinePosition
);
1375 buffer
.Printf( "gsave\n"
1381 XLOG2DEV(x
), YLOG2DEV(uy
),
1382 m_underlineThickness
,
1383 XLOG2DEV(x
+ text_w
), YLOG2DEV(uy
) );
1384 buffer
.Replace( ",", "." );
1388 CalcBoundingBox( x
, y
);
1389 CalcBoundingBox( x
+ size
* text
.length() * 2/3 , y
);
1392 void wxPostScriptDCImpl::DoDrawRotatedText( const wxString
& text
, wxCoord x
, wxCoord y
, double angle
)
1394 if ( wxIsNullDouble(angle
) )
1396 DoDrawText(text
, x
, y
);
1400 wxCHECK_RET( m_ok
, wxT("invalid postscript dc") );
1404 if (m_textForegroundColour
.Ok())
1406 unsigned char red
= m_textForegroundColour
.Red();
1407 unsigned char blue
= m_textForegroundColour
.Blue();
1408 unsigned char green
= m_textForegroundColour
.Green();
1412 // Anything not white is black
1413 if (! (red
== (unsigned char) 255 &&
1414 blue
== (unsigned char) 255 &&
1415 green
== (unsigned char) 255))
1417 red
= (unsigned char) 0;
1418 green
= (unsigned char) 0;
1419 blue
= (unsigned char) 0;
1423 // maybe setgray here ?
1424 if (!(red
== m_currentRed
&& green
== m_currentGreen
&& blue
== m_currentBlue
))
1426 double redPS
= (double)(red
) / 255.0;
1427 double bluePS
= (double)(blue
) / 255.0;
1428 double greenPS
= (double)(green
) / 255.0;
1431 buffer
.Printf( "%f %f %f setrgbcolor\n", redPS
, greenPS
, bluePS
);
1432 buffer
.Replace( ",", "." );
1436 m_currentBlue
= blue
;
1437 m_currentGreen
= green
;
1441 int size
= m_font
.GetPointSize();
1444 buffer
.Printf( "%f %f moveto\n", XLOG2DEV(x
), YLOG2DEV(y
));
1445 buffer
.Replace( ",", "." );
1448 buffer
.Printf( "%f rotate\n", angle
);
1449 buffer
.Replace( ",", "." );
1453 const wxWX2MBbuf textbuf
= text
.mb_str();
1456 for ( const char *p
= textbuf
; *p
!= '\0'; p
++ )
1458 int c
= (unsigned char)*p
;
1459 if (c
== ')' || c
== '(' || c
== '\\')
1461 /* Cope with special characters */
1463 PsPrint( (char) c
);
1465 else if ( c
>= 128 )
1467 /* Cope with character codes > 127 */
1468 buffer
.Printf( "\\%o", c
);
1473 PsPrint( (char) c
);
1478 PsPrint( ") show\n" );
1480 buffer
.Printf( "%f rotate\n", -angle
);
1481 buffer
.Replace( ",", "." );
1484 if (m_font
.GetUnderlined())
1486 wxCoord uy
= (wxCoord
)(y
+ size
- m_underlinePosition
);
1488 GetOwner()->GetTextExtent(text
, &w
, &h
);
1497 XLOG2DEV(x
), YLOG2DEV(uy
),
1498 m_underlineThickness
,
1499 XLOG2DEV(x
+ w
), YLOG2DEV(uy
) );
1500 buffer
.Replace( ",", "." );
1504 CalcBoundingBox( x
, y
);
1505 CalcBoundingBox( x
+ size
* text
.length() * 2/3 , y
);
1508 void wxPostScriptDCImpl::SetBackground (const wxBrush
& brush
)
1510 m_backgroundBrush
= brush
;
1513 void wxPostScriptDCImpl::SetLogicalFunction(wxRasterOperationMode
WXUNUSED(function
))
1515 wxFAIL_MSG( wxT("wxPostScriptDCImpl::SetLogicalFunction not implemented.") );
1519 void wxPostScriptDCImpl::DoDrawSpline( const wxPointList
*points
)
1521 wxCHECK_RET( m_ok
, wxT("invalid postscript dc") );
1525 // a and b are not used
1527 double c
, d
, x1
, y1
, x2
, y2
, x3
, y3
;
1530 wxPointList::compatibility_iterator node
= points
->GetFirst();
1531 p
= node
->GetData();
1535 node
= node
->GetNext();
1536 p
= node
->GetData();
1543 (double)(x1
+ c
) / 2;
1548 (double)(y1
+ d
) / 2;
1551 buffer
.Printf( "newpath\n"
1554 XLOG2DEV(wxRound(x1
)), YLOG2DEV(wxRound(y1
)),
1555 XLOG2DEV(wxRound(x3
)), YLOG2DEV(wxRound(y3
)) );
1556 buffer
.Replace( ",", "." );
1559 CalcBoundingBox( (wxCoord
)x1
, (wxCoord
)y1
);
1560 CalcBoundingBox( (wxCoord
)x3
, (wxCoord
)y3
);
1562 node
= node
->GetNext();
1565 q
= node
->GetData();
1573 x3
= (double)(x2
+ c
) / 2;
1574 y3
= (double)(y2
+ d
) / 2;
1576 buffer
.Printf( "%f %f %f %f %f %f DrawSplineSection\n",
1577 XLOG2DEV(wxRound(x1
)), YLOG2DEV(wxRound(y1
)),
1578 XLOG2DEV(wxRound(x2
)), YLOG2DEV(wxRound(y2
)),
1579 XLOG2DEV(wxRound(x3
)), YLOG2DEV(wxRound(y3
)) );
1580 buffer
.Replace( ",", "." );
1583 CalcBoundingBox( (wxCoord
)x1
, (wxCoord
)y1
);
1584 CalcBoundingBox( (wxCoord
)x3
, (wxCoord
)y3
);
1586 node
= node
->GetNext();
1590 At this point, (x2,y2) and (c,d) are the position of the
1591 next-to-last and last point respectively, in the point list
1594 buffer
.Printf( "%f %f lineto\nstroke\n", XLOG2DEV(wxRound(c
)), YLOG2DEV(wxRound(d
)) );
1595 buffer
.Replace( ",", "." );
1598 #endif // wxUSE_SPLINES
1600 wxCoord
wxPostScriptDCImpl::GetCharWidth() const
1602 // Chris Breeze: reasonable approximation using wxMODERN/Courier
1603 return (wxCoord
) (GetCharHeight() * 72.0 / 120.0);
1606 void wxPostScriptDCImpl::SetPrintData(const wxPrintData
& data
)
1610 wxPaperSize id
= m_printData
.GetPaperId();
1611 wxPrintPaperType
*paper
= wxThePrintPaperDatabase
->FindPaperType(id
);
1612 if (!paper
) paper
= wxThePrintPaperDatabase
->FindPaperType(wxPAPER_A4
);
1617 w
= paper
->GetSizeDeviceUnits().x
;
1618 h
= paper
->GetSizeDeviceUnits().y
;
1621 if (m_printData
.GetOrientation() == wxLANDSCAPE
)
1622 m_pageHeight
= w
* PS2DEV
;
1624 m_pageHeight
= h
* PS2DEV
;
1627 void wxPostScriptDCImpl::ComputeScaleAndOrigin()
1629 const wxRealPoint
origScale(m_scaleX
, m_scaleY
);
1631 wxDCImpl::ComputeScaleAndOrigin();
1633 // If scale has changed call SetPen to recalulate the line width
1634 // and SetFont to recalculate font size
1635 if ( wxRealPoint(m_scaleX
, m_scaleY
) != origScale
&& m_pen
.IsOk() )
1642 void wxPostScriptDCImpl::DoGetSize(int* width
, int* height
) const
1644 wxPaperSize id
= m_printData
.GetPaperId();
1646 wxPrintPaperType
*paper
= wxThePrintPaperDatabase
->FindPaperType(id
);
1648 if (!paper
) paper
= wxThePrintPaperDatabase
->FindPaperType(wxPAPER_A4
);
1654 w
= paper
->GetSizeDeviceUnits().x
;
1655 h
= paper
->GetSizeDeviceUnits().y
;
1658 if (m_printData
.GetOrientation() == wxLANDSCAPE
)
1666 *width
= wxRound( w
* PS2DEV
);
1669 *height
= wxRound( h
* PS2DEV
);
1672 void wxPostScriptDCImpl::DoGetSizeMM(int *width
, int *height
) const
1674 wxPaperSize id
= m_printData
.GetPaperId();
1676 wxPrintPaperType
*paper
= wxThePrintPaperDatabase
->FindPaperType(id
);
1678 if (!paper
) paper
= wxThePrintPaperDatabase
->FindPaperType(wxPAPER_A4
);
1684 w
= paper
->GetWidth() / 10;
1685 h
= paper
->GetHeight() / 10;
1688 if (m_printData
.GetOrientation() == wxLANDSCAPE
)
1695 if (width
) *width
= w
;
1696 if (height
) *height
= h
;
1699 // Resolution in pixels per logical inch
1700 wxSize
wxPostScriptDCImpl::GetPPI(void) const
1702 return wxSize( DPI
, DPI
);
1706 bool wxPostScriptDCImpl::StartDoc( const wxString
& WXUNUSED(message
) )
1708 wxCHECK_MSG( m_ok
, false, wxT("invalid postscript dc") );
1710 if (m_printData
.GetPrintMode() != wxPRINT_MODE_STREAM
)
1712 if (m_printData
.GetFilename() == wxEmptyString
)
1714 wxString filename
= wxFileName::CreateTempFileName( wxT("ps") );
1715 m_printData
.SetFilename(filename
);
1718 m_pstream
= wxFopen( m_printData
.GetFilename(), wxT("w+") );
1722 wxLogError( _("Cannot open file for PostScript printing!"));
1732 PsPrint( "%!PS-Adobe-2.0\n" );
1734 PsPrint( "%%Creator: wxWidgets PostScript renderer\n" );
1736 buffer
.Printf( "%%%%CreationDate: %s\n", wxNow() );
1739 if (m_printData
.GetOrientation() == wxLANDSCAPE
)
1740 PsPrint( "%%Orientation: Landscape\n" );
1742 PsPrint( "%%Orientation: Portrait\n" );
1744 const wxChar
*paper
;
1745 switch (m_printData
.GetPaperId())
1747 case wxPAPER_LETTER
: paper
= wxT("Letter"); break; // Letter: paper ""; 8 1/2 by 11 inches
1748 case wxPAPER_LEGAL
: paper
= wxT("Legal"); break; // Legal, 8 1/2 by 14 inches
1749 case wxPAPER_A4
: paper
= wxT("A4"); break; // A4 Sheet, 210 by 297 millimeters
1750 case wxPAPER_TABLOID
: paper
= wxT("Tabloid"); break; // Tabloid, 11 by 17 inches
1751 case wxPAPER_LEDGER
: paper
= wxT("Ledger"); break; // Ledger, 17 by 11 inches
1752 case wxPAPER_STATEMENT
: paper
= wxT("Statement"); break; // Statement, 5 1/2 by 8 1/2 inches
1753 case wxPAPER_EXECUTIVE
: paper
= wxT("Executive"); break; // Executive, 7 1/4 by 10 1/2 inches
1754 case wxPAPER_A3
: paper
= wxT("A3"); break; // A3 sheet, 297 by 420 millimeters
1755 case wxPAPER_A5
: paper
= wxT("A5"); break; // A5 sheet, 148 by 210 millimeters
1756 case wxPAPER_B4
: paper
= wxT("B4"); break; // B4 sheet, 250 by 354 millimeters
1757 case wxPAPER_B5
: paper
= wxT("B5"); break; // B5 sheet, 182-by-257-millimeter paper
1758 case wxPAPER_FOLIO
: paper
= wxT("Folio"); break; // Folio, 8-1/2-by-13-inch paper
1759 case wxPAPER_QUARTO
: paper
= wxT("Quaro"); break; // Quarto, 215-by-275-millimeter paper
1760 case wxPAPER_10X14
: paper
= wxT("10x14"); break; // 10-by-14-inch sheet
1761 default: paper
= wxT("A4");
1764 buffer
.Printf( "%%%%DocumentPaperSizes: %s\n", paper
);
1767 PsPrint( "%%EndComments\n\n" );
1769 PsPrint( "%%BeginProlog\n" );
1770 PsPrint( wxPostScriptHeaderConicTo
);
1771 PsPrint( wxPostScriptHeaderEllipse
);
1772 PsPrint( wxPostScriptHeaderEllipticArc
);
1773 PsPrint( wxPostScriptHeaderColourImage
);
1774 PsPrint( wxPostScriptHeaderReencodeISO1
);
1775 PsPrint( wxPostScriptHeaderReencodeISO2
);
1776 if (wxPostScriptHeaderSpline
)
1777 PsPrint( wxPostScriptHeaderSpline
);
1778 PsPrint( "%%EndProlog\n" );
1780 SetBrush( *wxBLACK_BRUSH
);
1781 SetPen( *wxBLACK_PEN
);
1782 SetBackground( *wxWHITE_BRUSH
);
1783 SetTextForeground( *wxBLACK
);
1785 // set origin according to paper size
1786 SetDeviceOrigin( 0,0 );
1792 void wxPostScriptDCImpl::EndDoc ()
1794 wxCHECK_RET( m_ok
, wxT("invalid postscript dc") );
1799 PsPrint( "grestore\n" );
1803 fclose( m_pstream
);
1808 // THE FOLLOWING HAS BEEN CONTRIBUTED BY Andy Fyfe <andy@hyperparallel.com>
1809 wxCoord wx_printer_translate_x
, wx_printer_translate_y
;
1810 double wx_printer_scale_x
, wx_printer_scale_y
;
1812 wx_printer_translate_x
= (wxCoord
)m_printData
.GetPrinterTranslateX();
1813 wx_printer_translate_y
= (wxCoord
)m_printData
.GetPrinterTranslateY();
1815 wx_printer_scale_x
= m_printData
.GetPrinterScaleX();
1816 wx_printer_scale_y
= m_printData
.GetPrinterScaleY();
1818 // Compute the bounding box. Note that it is in the default user
1819 // coordinate system, thus we have to convert the values.
1820 wxCoord minX
= (wxCoord
) XLOG2DEV(m_minX
);
1821 wxCoord minY
= (wxCoord
) YLOG2DEV(m_minY
);
1822 wxCoord maxX
= (wxCoord
) XLOG2DEV(m_maxX
);
1823 wxCoord maxY
= (wxCoord
) YLOG2DEV(m_maxY
);
1825 // LOG2DEV may have changed the minimum to maximum vice versa
1826 if ( minX
> maxX
) { wxCoord tmp
= minX
; minX
= maxX
; maxX
= tmp
; }
1827 if ( minY
> maxY
) { wxCoord tmp
= minY
; minY
= maxY
; maxY
= tmp
; }
1829 // account for used scaling (boundingbox is before scaling in ps-file)
1830 double scale_x
= m_printData
.GetPrinterScaleX() / ms_PSScaleFactor
;
1831 double scale_y
= m_printData
.GetPrinterScaleY() / ms_PSScaleFactor
;
1833 wxCoord llx
, lly
, urx
, ury
;
1834 llx
= (wxCoord
) ((minX
+wx_printer_translate_x
)*scale_x
);
1835 lly
= (wxCoord
) ((minY
+wx_printer_translate_y
)*scale_y
);
1836 urx
= (wxCoord
) ((maxX
+wx_printer_translate_x
)*scale_x
);
1837 ury
= (wxCoord
) ((maxY
+wx_printer_translate_y
)*scale_y
);
1838 // (end of bounding box computation)
1841 // If we're landscape, our sense of "x" and "y" is reversed.
1842 if (m_printData
.GetOrientation() == wxLANDSCAPE
)
1845 tmp
= llx
; llx
= lly
; lly
= tmp
;
1846 tmp
= urx
; urx
= ury
; ury
= tmp
;
1848 // We need either the two lines that follow, or we need to subtract
1849 // min_x from real_translate_y, which is commented out below.
1850 llx
= llx
- (wxCoord
)(m_minX
*wx_printer_scale_y
);
1851 urx
= urx
- (wxCoord
)(m_minX
*wx_printer_scale_y
);
1854 // The Adobe specifications call for integers; we round as to make
1855 // the bounding larger.
1856 PsPrintf( wxT("%%%%BoundingBox: %d %d %d %d\n"),
1857 (wxCoord
)floor((double)llx
), (wxCoord
)floor((double)lly
),
1858 (wxCoord
)ceil((double)urx
), (wxCoord
)ceil((double)ury
) );
1860 // To check the correctness of the bounding box, postscript commands
1861 // to draw a box corresponding to the bounding box are generated below.
1862 // But since we typically don't want to print such a box, the postscript
1863 // commands are generated within comments. These lines appear before any
1864 // adjustment of scale, rotation, or translation, and hence are in the
1865 // default user coordinates.
1866 PsPrint( "% newpath\n" );
1867 PsPrintf( wxT("%% %d %d moveto\n"), llx
, lly
);
1868 PsPrintf( wxT("%% %d %d lineto\n"), urx
, lly
);
1869 PsPrintf( wxT("%% %d %d lineto\n"), urx
, ury
);
1870 PsPrintf( wxT("%% %d %d lineto closepath stroke\n"), llx
, ury
);
1874 wxPostScriptPrintNativeData
*data
=
1875 (wxPostScriptPrintNativeData
*) m_printData
.GetNativeData();
1877 if (m_ok
&& (m_printData
.GetPrintMode() == wxPRINT_MODE_PRINTER
))
1880 command
+= data
->GetPrinterCommand();
1881 command
+= wxT(" ");
1882 command
+= data
->GetPrinterOptions();
1883 command
+= wxT(" ");
1884 command
+= m_printData
.GetFilename();
1886 wxExecute( command
, true );
1887 wxRemoveFile( m_printData
.GetFilename() );
1892 void wxPostScriptDCImpl::StartPage()
1894 wxCHECK_RET( m_ok
, wxT("invalid postscript dc") );
1897 buffer
.Printf( wxT("%%%%Page: %d\n"), m_pageNumber
++ );
1901 wxPostScriptPrintNativeData
*data
=
1902 (wxPostScriptPrintNativeData
*) m_printData
.GetNativeData();
1904 wxCoord translate_x
= (wxCoord
)data
->GetPrinterTranslateX();
1905 wxCoord translate_y
= (wxCoord
)data
->GetPrinterTranslateY();
1907 buffer
.Printf( "%d %d translate\n", translate_x
, translate_y
);
1910 double scale_x
= data
->GetPrinterScaleX();
1911 double scale_y
= data
->GetPrinterScaleY();
1913 buffer
.Printf( "%f %f scale\n", scale_x
, scale_y
);
1914 buffer
.Replace( ",", "." );
1919 // Each page starts with an "initgraphics" which resets the
1920 // transformation and so we need to rotate the page for
1921 // landscape printing)
1923 // I copied this one from a PostScript tutorial, but to no avail. RR.
1924 // PsPrint( "90 rotate llx neg ury nef translate\n" );
1926 if (m_printData
.GetOrientation() == wxLANDSCAPE
)
1927 PsPrint( "90 rotate\n" );
1930 void wxPostScriptDCImpl::EndPage ()
1932 wxCHECK_RET( m_ok
, wxT("invalid postscript dc") );
1934 PsPrint( "showpage\n" );
1937 bool wxPostScriptDCImpl::DoBlit( wxCoord xdest
, wxCoord ydest
,
1938 wxCoord fwidth
, wxCoord fheight
,
1940 wxCoord xsrc
, wxCoord ysrc
,
1941 wxRasterOperationMode rop
,
1942 bool WXUNUSED(useMask
), wxCoord
WXUNUSED(xsrcMask
), wxCoord
WXUNUSED(ysrcMask
) )
1944 wxCHECK_MSG( m_ok
, false, wxT("invalid postscript dc") );
1946 wxCHECK_MSG( source
, false, wxT("invalid source dc") );
1948 // blit into a bitmap
1949 wxBitmap
bitmap( (int)fwidth
, (int)fheight
);
1951 memDC
.SelectObject(bitmap
);
1952 memDC
.Blit(0, 0, fwidth
, fheight
, source
, xsrc
, ysrc
, rop
); /* TODO: Blit transparently? */
1953 memDC
.SelectObject(wxNullBitmap
);
1955 //draw bitmap. scaling and positioning is done there
1956 GetOwner()->DrawBitmap( bitmap
, xdest
, ydest
);
1961 wxCoord
wxPostScriptDCImpl::GetCharHeight() const
1964 return m_font
.GetPointSize();
1969 void wxPostScriptDCImpl::PsPrint( const wxString
& str
)
1971 const wxCharBuffer
psdata(str
.utf8_str());
1973 wxPostScriptPrintNativeData
*data
=
1974 (wxPostScriptPrintNativeData
*) m_printData
.GetNativeData();
1976 switch (m_printData
.GetPrintMode())
1979 // append to output stream
1980 case wxPRINT_MODE_STREAM
:
1982 wxOutputStream
* outputstream
= data
->GetOutputStream();
1983 wxCHECK_RET( outputstream
, wxT("invalid outputstream") );
1984 outputstream
->Write( psdata
, strlen( psdata
) );
1987 #endif // wxUSE_STREAMS
1989 // save data into file
1991 wxCHECK_RET( m_pstream
, wxT("invalid postscript dc") );
1992 fwrite( psdata
, 1, strlen( psdata
), m_pstream
);
1996 void wxPostScriptDCImpl::DoGetTextExtent(const wxString
& string
,
1997 wxCoord
*x
, wxCoord
*y
,
1998 wxCoord
*descent
, wxCoord
*externalLeading
,
1999 const wxFont
*theFont
) const
2001 const wxFont
*fontToUse
= theFont
;
2003 if (!fontToUse
) fontToUse
= &m_font
;
2005 const float fontSize
=
2006 fontToUse
->GetPointSize() * GetFontPointSizeAdjustment(72.0);
2012 if (descent
) (*descent
) = 0;
2013 if (externalLeading
) (*externalLeading
) = 0;
2019 const wxWX2MBbuf strbuf
= string
.mb_str();
2021 // conversion failed (non e.g. ISO characters)
2025 #if !wxUSE_AFM_FOR_POSTSCRIPT
2026 /* Provide a VERY rough estimate (avoid using it).
2027 * Produces accurate results for mono-spaced font
2028 * such as Courier (aka wxMODERN) */
2031 *x
= strlen (strbuf
) * fontSize
* 72.0 / 120.0;
2033 *y
= (wxCoord
) (fontSize
* 1.32); /* allow for descender */
2034 if (descent
) *descent
= 0;
2035 if (externalLeading
) *externalLeading
= 0;
2038 /* method for calculating string widths in postscript:
2039 / read in the AFM (adobe font metrics) file for the
2040 / actual font, parse it and extract the character widths
2041 / and also the descender. this may be improved, but for now
2042 / it works well. the AFM file is only read in if the
2043 / font is changed. this may be chached in the future.
2044 / calls to GetTextExtent with the font unchanged are rather
2047 / for each font and style used there is an AFM file necessary.
2048 / currently i have only files for the roman font family.
2049 / I try to get files for the other ones!
2051 / CAVE: the size of the string is currently always calculated
2052 / in 'points' (1/72 of an inch). this should later on be
2053 / changed to depend on the mapping mode.
2054 / CAVE: the path to the AFM files must be set before calling this
2055 / fun3B3Bction. this is usually done by a call like the following:
2056 / wxSetAFMPath("d:\\wxw161\\afm\\");
2060 / wxPostScriptDC dc(NULL, true);
2062 / wxSetAFMPath("d:\\wxw161\\afm\\");
2063 / dc.StartDoc("Test");
2066 / dc.SetFont(new wxFont(10, wxROMAN, wxNORMAL, wxNORMAL));
2067 / dc.GetTextExtent("Hallo",&w,&h);
2072 / by steve (stefan.hammes@urz.uni-heidelberg.de)
2074 / updated: 14.05.95 */
2076 /* these static vars are for storing the state between calls */
2077 static int lastFamily
= INT_MIN
;
2078 static int lastSize
= INT_MIN
;
2079 static int lastStyle
= INT_MIN
;
2080 static int lastWeight
= INT_MIN
;
2081 static int lastDescender
= INT_MIN
;
2082 static int lastWidths
[256]; /* widths of the characters */
2084 double UnderlinePosition
= 0.0;
2085 double UnderlineThickness
= 0.0;
2087 // Get actual parameters
2088 int Family
= fontToUse
->GetFamily();
2089 int Size
= fontToUse
->GetPointSize();
2090 int Style
= fontToUse
->GetStyle();
2091 int Weight
= fontToUse
->GetWeight();
2093 // If we have another font, read the font-metrics
2094 if (Family
!=lastFamily
|| Size
!=lastSize
|| Style
!=lastStyle
|| Weight
!=lastWeight
)
2096 // Store actual values
2097 lastFamily
= Family
;
2100 lastWeight
= Weight
;
2109 if ((Style
== wxITALIC
) && (Weight
== wxBOLD
)) name
= wxT("CourBoO.afm");
2110 else if ((Style
!= wxITALIC
) && (Weight
== wxBOLD
)) name
= wxT("CourBo.afm");
2111 else if ((Style
== wxITALIC
) && (Weight
!= wxBOLD
)) name
= wxT("CourO.afm");
2112 else name
= wxT("Cour.afm");
2117 if ((Style
== wxITALIC
) && (Weight
== wxBOLD
)) name
= wxT("TimesBoO.afm");
2118 else if ((Style
!= wxITALIC
) && (Weight
== wxBOLD
)) name
= wxT("TimesBo.afm");
2119 else if ((Style
== wxITALIC
) && (Weight
!= wxBOLD
)) name
= wxT("TimesO.afm");
2120 else name
= wxT("TimesRo.afm");
2125 name
= wxT("Zapf.afm");
2131 if ((Style
== wxITALIC
) && (Weight
== wxBOLD
)) name
= wxT("HelvBoO.afm");
2132 else if ((Style
!= wxITALIC
) && (Weight
== wxBOLD
)) name
= wxT("HelvBo.afm");
2133 else if ((Style
== wxITALIC
) && (Weight
!= wxBOLD
)) name
= wxT("HelvO.afm");
2134 else name
= wxT("Helv.afm");
2139 FILE *afmFile
= NULL
;
2141 // Get the directory of the AFM files
2144 // VZ: I don't know if the cast always works under Unix but it clearly
2145 // never does under Windows where the pointer is
2146 // wxWindowsPrintNativeData and so calling GetFontMetricPath() on
2149 wxPostScriptPrintNativeData
*data
=
2150 wxDynamicCast(m_printData
.GetNativeData(), wxPostScriptPrintNativeData
);
2152 if (data
&& !data
->GetFontMetricPath().empty())
2154 afmName
= data
->GetFontMetricPath();
2155 afmName
<< wxFILE_SEP_PATH
<< name
;
2159 if ( !afmName
.empty() )
2160 afmFile
= wxFopen(afmName
, wxT("r"));
2164 #if defined(__UNIX__) && !defined(__VMS__)
2165 afmName
= wxGetDataDir();
2167 afmName
= wxStandardPaths::Get().GetDataDir();
2168 #endif // __UNIX__/!__UNIX__
2170 afmName
<< wxFILE_SEP_PATH
2171 #if defined(__LINUX__) || defined(__FREEBSD__)
2172 << wxT("gs_afm") << wxFILE_SEP_PATH
2174 << wxT("afm") << wxFILE_SEP_PATH
2177 afmFile
= wxFopen(afmName
,wxT("r"));
2180 /* 2. open and process the file
2181 / a short explanation of the AFM format:
2182 / we have for each character a line, which gives its size
2185 / C 63 ; WX 444 ; N question ; B 49 -14 395 676 ;
2187 / that means, we have a character with ascii code 63, and width
2188 / (444/1000 * fontSize) points.
2189 / the other data is ignored for now!
2191 / when the font has changed, we read in the right AFM file and store the
2192 / character widths in an array, which is processed below (see point 3.). */
2195 wxLogDebug( wxT("GetTextExtent: can't open AFM file '%s'"), afmName
.c_str() );
2196 wxLogDebug( wxT(" using approximate values"));
2197 for (int i
=0; i
<256; i
++) lastWidths
[i
] = 500; /* an approximate value */
2198 lastDescender
= -150; /* dito. */
2202 /* init the widths array */
2203 for(int i
=0; i
<256; i
++) lastWidths
[i
] = INT_MIN
;
2204 /* some variables for holding parts of a line */
2205 char cString
[10], semiString
[10], WXString
[10];
2206 char descString
[20];
2207 char upString
[30], utString
[30];
2211 /* read in the file and parse it */
2212 while(fgets(line
,sizeof(line
),afmFile
)!=NULL
)
2214 /* A.) check for descender definition */
2215 if (strncmp(line
,"Descender",9)==0)
2217 if ((sscanf(line
,"%s%d",descString
,&lastDescender
)!=2) ||
2218 (strcmp(descString
,"Descender")!=0))
2220 wxLogDebug( wxT("AFM-file '%s': line '%s' has error (bad descender)"), afmName
.c_str(),line
);
2223 /* JC 1.) check for UnderlinePosition */
2224 else if(strncmp(line
,"UnderlinePosition",17)==0)
2226 if ((sscanf(line
,"%s%lf",upString
,&UnderlinePosition
)!=2) ||
2227 (strcmp(upString
,"UnderlinePosition")!=0))
2229 wxLogDebug( wxT("AFM-file '%s': line '%s' has error (bad UnderlinePosition)"), afmName
.c_str(), line
);
2232 /* JC 2.) check for UnderlineThickness */
2233 else if(strncmp(line
,"UnderlineThickness",18)==0)
2235 if ((sscanf(line
,"%s%lf",utString
,&UnderlineThickness
)!=2) ||
2236 (strcmp(utString
,"UnderlineThickness")!=0))
2238 wxLogDebug( wxT("AFM-file '%s': line '%s' has error (bad UnderlineThickness)"), afmName
.c_str(), line
);
2241 /* JC 3.) check for EncodingScheme */
2242 else if(strncmp(line
,"EncodingScheme",14)==0)
2244 if ((sscanf(line
,"%s%s",utString
,encString
)!=2) ||
2245 (strcmp(utString
,"EncodingScheme")!=0))
2247 wxLogDebug( wxT("AFM-file '%s': line '%s' has error (bad EncodingScheme)"), afmName
.c_str(), line
);
2249 else if (strncmp(encString
, "AdobeStandardEncoding", 21))
2251 wxLogDebug( wxT("AFM-file '%s': line '%s' has error (unsupported EncodingScheme %s)"),
2252 afmName
.c_str(),line
, encString
);
2255 /* B.) check for char-width */
2256 else if(strncmp(line
,"C ",2)==0)
2258 if (sscanf(line
,"%s%d%s%s%d",cString
,&ascii
,semiString
,WXString
,&cWidth
)!=5)
2260 wxLogDebug(wxT("AFM-file '%s': line '%s' has an error (bad character width)"),afmName
.c_str(),line
);
2262 if(strcmp(cString
,"C")!=0 || strcmp(semiString
,";")!=0 || strcmp(WXString
,"WX")!=0)
2264 wxLogDebug(wxT("AFM-file '%s': line '%s' has a format error"),afmName
.c_str(),line
);
2266 /* printf(" char '%c'=%d has width '%d'\n",ascii,ascii,cWidth); */
2267 if (ascii
>=0 && ascii
<256)
2269 lastWidths
[ascii
] = cWidth
; /* store width */
2273 /* MATTHEW: this happens a lot; don't print an error */
2274 /* wxLogDebug("AFM-file '%s': ASCII value %d out of range",afmName.c_str(),ascii); */
2277 /* C.) ignore other entries. */
2281 /* hack to compute correct values for german 'Umlaute'
2282 / the correct way would be to map the character names
2283 / like 'adieresis' to corresp. positions of ISOEnc and read
2284 / these values from AFM files, too. Maybe later ... */
2286 // NB: casts to int are needed to suppress gcc 3.3 warnings
2287 lastWidths
[196] = lastWidths
[(int)'A']; // U+00C4 A Umlaute
2288 lastWidths
[228] = lastWidths
[(int)'a']; // U+00E4 a Umlaute
2289 lastWidths
[214] = lastWidths
[(int)'O']; // U+00D6 O Umlaute
2290 lastWidths
[246] = lastWidths
[(int)'o']; // U+00F6 o Umlaute
2291 lastWidths
[220] = lastWidths
[(int)'U']; // U+00DC U Umlaute
2292 lastWidths
[252] = lastWidths
[(int)'u']; // U+00FC u Umlaute
2293 lastWidths
[223] = lastWidths
[(int)251]; // U+00DF eszett (scharfes s)
2295 /* JC: calculate UnderlineThickness/UnderlinePosition */
2297 // VS: dirty, but is there any better solution?
2299 pt
= (double*) &m_underlinePosition
;
2300 *pt
= YLOG2DEVREL((wxCoord
)(UnderlinePosition
* fontSize
)) / 1000.0f
;
2301 pt
= (double*) &m_underlineThickness
;
2302 *pt
= YLOG2DEVREL((wxCoord
)(UnderlineThickness
* fontSize
)) / 1000.0f
;
2307 /* 3. now the font metrics are read in, calc size this
2308 / is done by adding the widths of the characters in the
2309 / string. they are given in 1/1000 of the size! */
2312 float height
=fontSize
; /* by default */
2314 for(p
=(unsigned char *)wxMBSTRINGCAST strbuf
; *p
; p
++)
2316 if(lastWidths
[*p
]== INT_MIN
)
2318 wxLogDebug(wxT("GetTextExtent: undefined width for character '%c' (%d)"), *p
,*p
);
2319 sum
+= lastWidths
[(unsigned char)' ']; /* assume space */
2323 sum
+= lastWidths
[*p
];
2327 double widthSum
= sum
;
2328 widthSum
*= fontSize
;
2329 widthSum
/= 1000.0F
;
2331 /* add descender to height (it is usually a negative value) */
2332 //if (lastDescender != INT_MIN)
2334 // height += (wxCoord)(((-lastDescender)/1000.0F) * Size); /* MATTHEW: forgot scale */
2336 // - commented by V. Slavik - height already contains descender in it
2337 // (judging from few experiments)
2339 /* return size values */
2341 *x
= (wxCoord
)widthSum
;
2343 *y
= (wxCoord
)height
;
2345 /* return other parameters */
2348 if(lastDescender
!=INT_MIN
)
2350 *descent
= (wxCoord
)(((-lastDescender
)/1000.0F
) * fontSize
); /* MATTHEW: forgot scale */
2358 /* currently no idea how to calculate this! */
2359 if (externalLeading
) *externalLeading
= 0;
2365 #endif // wxUSE_PRINTING_ARCHITECTURE && wxUSE_POSTSCRIPT