29#include <FL/Fl_Cairo.H>
39#include <X11/Xft/Xft.h>
43const char *Fl_PostScript_Graphics_Driver::class_id =
"Fl_PostScript_Graphics_Driver";
44const char *Fl_PostScript_File_Device::class_id =
"Fl_PostScript_File_Device";
58 scale_x = scale_y = 1.;
59 bg_r = bg_g = bg_b = 255;
64 if(ps_filename_) free(ps_filename_);
103 fnfc.
filter(
"PostScript\t*.ps\n");
105 if ( fnfc.
show() )
return 1;
107 ps->output = fopen(fnfc.
filename(),
"w");
108 if(ps->output == NULL)
return 2;
109 ps->ps_filename_ = strdup(fnfc.
filename());
110 ps->start_postscript(pagecount, format, layout);
115static int dont_close(FILE *f)
134 ps->output = ps_output;
135 ps->ps_filename_ = NULL;
136 ps->start_postscript(pagecount, format, layout);
137 ps->close_command(dont_close);
152#if ! (defined(__APPLE__) || defined(WIN32) )
153 #include "print_panel.cxx"
158static const char * prolog =
164"newpath x1 y1 moveto x2 y2 lineto\n"
195"/FR { /dy exch def\n"
199"currentlinewidth 0 setlinewidth newpath\n"
204"closepath fill setlinewidth\n"
207"/GS { gsave } bind def\n"
208"/GR { grestore } bind def\n"
210"/SP { showpage } bind def\n"
211"/LW { setlinewidth } bind def\n"
213"/SF { /CF exch def } bind def\n"
215"/FS { /fsize exch def fsize CF findfont exch scalefont setfont }def \n"
218"/GL { setgray } bind def\n"
219"/SRGB { setrgbcolor } bind def\n"
223"/CI { GS /py exch def /px exch def /sy exch def /sx exch def\n"
225"sx sy scale px py 8 \n"
226"[ px 0 0 py neg 0 py ]\n"
227"currentfile /ASCIIHexDecode filter\n false 3"
233"/GI { GS /py exch def /px exch def /sy exch def /sx exch def \n"
235"sx sy scale px py 8 \n"
238"[ px 0 0 py neg 0 py ]\n"
239"currentfile /ASCIIHexDecode filter\n"
245"/MI { GS /py exch def /px exch def /sy exch def /sx exch def \n"
247"sx sy scale px py true \n"
248"[ px 0 0 py neg 0 py ]\n"
249"currentfile /ASCIIHexDecode filter\n"
256"/BFP { newpath moveto } def\n"
257"/BP { newpath } bind def \n"
258"/PL { lineto } bind def \n"
259"/PM { moveto } bind def \n"
260"/MT { moveto } bind def \n"
261"/LT { lineto } bind def \n"
262"/EFP { closepath fill } bind def\n"
263"/ELP { stroke } bind def\n"
264"/ECP { closepath stroke } bind def\n"
265"/LW { setlinewidth } bind def\n"
268"/TR { translate } bind def\n"
269"/CT { concat } bind def\n"
270"/RCT { matrix invertmatrix concat} bind def\n"
271"/SC { scale } bind def\n"
277"/show_pos_width {GS moveto dup dup stringwidth pop exch length 2 div dup 2 le {pop 9999} if "
278"1 sub exch 3 index exch sub exch "
279"div 0 2 index 1 -1 scale ashow pop pop GR} bind def\n"
286static const char * prolog_2 =
289"/CII {GS /inter exch def /py exch def /px exch def /sy exch def /sx exch def \n"
292"/DeviceRGB setcolorspace\n"
298"/BitsPerComponent 8 def\n"
299"/Interpolate inter def\n"
300"/DataSource currentfile /ASCIIHexDecode filter def\n"
301"/MultipleDataSources false def\n"
302"/ImageMatrix [ px 0 0 py neg 0 py ] def\n"
303"/Decode [ 0 1 0 1 0 1 ] def\n"
305"IDD image GR} bind def\n"
308"/GII {GS /inter exch def /py exch def /px exch def /sy exch def /sx exch def \n"
311"/DeviceGray setcolorspace\n"
317"/BitsPerComponent 8 def\n"
319"/Interpolate inter def\n"
320"/DataSource currentfile /ASCIIHexDecode filter def\n"
321"/MultipleDataSources false def\n"
322"/ImageMatrix [ px 0 0 py neg 0 py ] def\n"
323"/Decode [ 0 1 ] def\n"
325"IDD image GR} bind def\n"
334"/ToISO { dup findfont dup length dict copy begin /Encoding ISOLatin1Encoding def currentdict end definefont pop } def\n"
335"/Helvetica ToISO /Helvetica-Bold ToISO /Helvetica-Oblique ToISO /Helvetica-BoldOblique ToISO \n"
336"/Courier ToISO /Courier-Bold ToISO /Courier-Oblique ToISO /Courier-BoldOblique ToISO \n"
337"/Times-Roman ToISO /Times-Bold ToISO /Times-Italic ToISO /Times-BoldItalic ToISO \n"
343" /Amacron /amacron /Abreve /abreve /Aogonek /aogonek\n"
344" /Cacute /cacute /Ccircumflex /ccircumflex /Cdotaccent /cdotaccent /Ccaron /ccaron \n"
345" /Dcaron /dcaron /Dcroat /dcroat\n"
346" /Emacron /emacron /Ebreve /ebreve /Edotaccent /edotaccent /Eogonek /eogonek /Ecaron /ecaron\n"
347" /Gcircumflex /gcircumflex /Gbreve /gbreve /Gdotaccent /gdotaccent /Gcommaaccent /gcommaaccent \n"
348" /Hcircumflex /hcircumflex /Hbar /hbar \n"
349" /Itilde /itilde /Imacron /imacron /Ibreve /ibreve /Iogonek /iogonek /Idotaccent /dotlessi \n"
350" /IJ /ij /Jcircumflex /jcircumflex\n"
351" /Kcommaaccent /kcommaaccent /kgreenlandic \n"
352" /Lacute /lacute /Lcommaaccent /lcommaaccent /Lcaron /lcaron /Ldotaccent /ldotaccent /Lslash /lslash \n"
353" /Nacute /nacute /Ncommaaccent /ncommaaccent /Ncaron /ncaron /napostrophe /Eng /eng \n"
354" /Omacron /omacron /Obreve /obreve /Ohungarumlaut /ohungarumlaut /OE /oe \n"
355" /Racute /racute /Rcommaaccent /rcommaaccent /Rcaron /rcaron \n"
356" /Sacute /sacute /Scircumflex /scircumflex /Scedilla /scedilla /Scaron /scaron \n"
357" /Tcommaaccent /tcommaaccent /Tcaron /tcaron /Tbar /tbar \n"
358" /Utilde /utilde /Umacron /umacron /Ubreve /ubreve /Uring /uring /Uhungarumlaut /uhungarumlaut /Uogonek /uogonek \n"
359" /Wcircumflex /wcircumflex /Ycircumflex /ycircumflex /Ydieresis \n"
360" /Zacute /zacute /Zdotaccent /zdotaccent /Zcaron /zcaron \n"
362" /florin /circumflex /caron /breve /dotaccent /ring \n"
363" /ogonek /tilde /hungarumlaut /endash /emdash \n"
364" /quoteleft /quoteright /quotesinglbase /quotedblleft /quotedblright \n"
365" /quotedblbase /dagger /daggerdbl /bullet /ellipsis \n"
366" /perthousand /guilsinglleft /guilsinglright /fraction /Euro \n"
367" /trademark /partialdiff /Delta /summation /radical \n"
368" /infinity /notequal /lessequal /greaterequal /lozenge \n"
372" /mycharstrings /Helvetica findfont /CharStrings get def\n"
373" /PSname2 { dup mycharstrings exch known {LatinExtA 3 -1 roll 3 -1 roll put}{pop pop} ifelse } def \n"
374" 16#20 /Gdot PSname2 16#21 /gdot PSname2 16#30 /Idot PSname2 16#3F /Ldot PSname2 16#40 /ldot PSname2 16#7F /slong PSname2 \n"
377"/ToLatinExtA { findfont dup length dict copy begin /Encoding LatinExtA def currentdict end definefont pop } def\n"
379"/HelveticaExt /Helvetica ToLatinExtA \n"
380"/Helvetica-BoldExt /Helvetica-Bold ToLatinExtA /Helvetica-ObliqueExt /Helvetica-Oblique ToLatinExtA \n"
381"/Helvetica-BoldObliqueExt /Helvetica-BoldOblique ToLatinExtA \n"
382"/CourierExt /Courier ToLatinExtA /Courier-BoldExt /Courier-Bold ToLatinExtA \n"
383"/Courier-ObliqueExt /Courier-Oblique ToLatinExtA /Courier-BoldObliqueExt /Courier-BoldOblique ToLatinExtA \n"
384"/Times-RomanExt /Times-Roman ToLatinExtA /Times-BoldExt /Times-Bold ToLatinExtA \n"
385"/Times-ItalicExt /Times-Italic ToLatinExtA /Times-BoldItalicExt /Times-BoldItalic ToLatinExtA \n"
389"/To2byte { 6 dict begin /FontType 0 def \n"
390"/FDepVector 3 1 roll findfont exch findfont 2 array astore def \n"
391"/FontMatrix [1 0 0 1 0 0] def /FMapType 6 def /Encoding [ 0 1 0 ] def\n"
393"/SubsVector < 01 0100 00A7 > def\n"
394"currentdict end definefont pop } def\n"
396"/Helvetica2B /HelveticaExt /Helvetica To2byte \n"
397"/Helvetica-Bold2B /Helvetica-BoldExt /Helvetica-Bold To2byte \n"
398"/Helvetica-Oblique2B /Helvetica-ObliqueExt /Helvetica-Oblique To2byte \n"
399"/Helvetica-BoldOblique2B /Helvetica-BoldObliqueExt /Helvetica-BoldOblique To2byte \n"
400"/Courier2B /CourierExt /Courier To2byte \n"
401"/Courier-Bold2B /Courier-BoldExt /Courier-Bold To2byte \n"
402"/Courier-Oblique2B /Courier-ObliqueExt /Courier-Oblique To2byte \n"
403"/Courier-BoldOblique2B /Courier-BoldObliqueExt /Courier-BoldOblique To2byte \n"
404"/Times-Roman2B /Times-RomanExt /Times-Roman To2byte \n"
405"/Times-Bold2B /Times-BoldExt /Times-Bold To2byte \n"
406"/Times-Italic2B /Times-ItalicExt /Times-Italic To2byte \n"
407"/Times-BoldItalic2B /Times-BoldItalicExt /Times-BoldItalic To2byte \n"
410static const char * prolog_2_pixmap =
411"/pixmap_mat {[ pixmap_sx 0 0 pixmap_sy neg 0 pixmap_sy ]} bind def\n"
417"/BBox [0 0 pixmap_sx pixmap_sy] "
422"pixmap_w pixmap_h scale "
423"pixmap_sx pixmap_sy 8 "
425"currentfile /ASCIIHexDecode filter "
435"/pixmap_sy exch def /pixmap_sx exch def\n"
436"/pixmap_h exch def /pixmap_w exch def\n"
438"pixmap_dict matrix makepattern setpattern\n"
439"pixmap_w pixmap_h scale\n"
440"pixmap_sx pixmap_sy\n"
443"currentfile /ASCIIHexDecode filter\n"
449static const char * prolog_3 =
452"/CIM {GS /inter exch def /my exch def /mx exch def /py exch def /px exch def /sy exch def /sx exch def \n"
455"/DeviceRGB setcolorspace\n"
463"/BitsPerComponent 8 def\n"
464"/Interpolate inter def\n"
465"/DataSource currentfile /ASCIIHexDecode filter def\n"
466"/MultipleDataSources false def\n"
467"/ImageMatrix [ px 0 0 py neg 0 py ] def\n"
469"/Decode [ 0 1 0 1 0 1 ] def\n"
477"/BitsPerComponent 1 def\n"
479"/ImageMatrix [ mx 0 0 my neg 0 my ] def\n"
480"/Decode [ 1 0 ] def\n"
493"/GIM {GS /inter exch def /my exch def /mx exch def /py exch def /px exch def /sy exch def /sx exch def \n"
496"/DeviceGray setcolorspace\n"
504"/BitsPerComponent 8 def\n"
505"/Interpolate inter def\n"
506"/DataSource currentfile /ASCIIHexDecode filter def\n"
507"/MultipleDataSources false def\n"
508"/ImageMatrix [ px 0 0 py neg 0 py ] def\n"
510"/Decode [ 0 1 ] def\n"
519"/BitsPerComponent 1 def\n"
520"/ImageMatrix [ mx 0 0 my neg 0 my ] def\n"
521"/Decode [ 1 0 ] def\n"
538int Fl_PostScript_Graphics_Driver::start_postscript (
int pagecount,
553 fputs(
"%!PS-Adobe-3.0\n", output);
554 fputs(
"%%Creator: FLTK\n", output);
556 fprintf(output,
"%%%%LanguageLevel: %i\n" , lang_level_);
557 if ((pages_ = pagecount))
558 fprintf(output,
"%%%%Pages: %i\n", pagecount);
560 fputs(
"%%Pages: (atend)\n", output);
565 fprintf(output,
"<</PageSize[%d %d]>>setpagedevice\n", w, h );
566 fputs(
"%%EndFeature\n", output);
567 fputs(
"%%EndComments\n", output);
568 fputs(prolog, output);
569 if (lang_level_ > 1) {
570 fputs(prolog_2, output);
572 if (lang_level_ == 2) {
573 fputs(prolog_2_pixmap, output);
576 fputs(prolog_3, output);
577 if (lang_level_ >= 3) {
578 fputs(
"/CS { clipsave } bind def\n", output);
579 fputs(
"/CR { cliprestore } bind def\n", output);
581 fputs(
"/CS { GS } bind def\n", output);
582 fputs(
"/CR { GR } bind def\n", output);
587 fputs(
"%%EndProlog\n",output);
588 if (lang_level_ >= 2)
589 fprintf(output,
"<< /Policies << /Pagesize 1 >> >> setpagedevice\n");
596void Fl_PostScript_Graphics_Driver::recover(){
602void Fl_PostScript_Graphics_Driver::reset(){
609 strcpy(linedash_,
"");
620void Fl_PostScript_Graphics_Driver::page_policy(
int p){
623 fprintf(output,
"<< /Policies << /Pagesize %i >> >> setpagedevice\n", p);
630void Fl_PostScript_Graphics_Driver::page(
double pw,
double ph,
int media) {
633 fprintf(output,
"CR\nGR\nGR\nGR\nSP\nrestore\n");
636 fprintf(output,
"%%%%Page: %i %i\n" , nPages , nPages);
638 fprintf(output,
"%%%%PageOrientation: Landscape\n");
640 fprintf(output,
"%%%%PageOrientation: Portrait\n");
643 fprintf(output,
"%%%%BeginPageSetup\n");
644 if((media & Fl_Paged_Device::MEDIA) &&(lang_level_>1)){
647 fprintf(output,
"<< /PageSize [%i %i] /Orientation %i>> setpagedevice\n", (
int)(pw+.5), (
int)(ph+.5), r);
649 fprintf(output,
"%%%%EndPageSetup\n");
655 fprintf(output,
"save\n");
656 fprintf(output,
"GS\n");
657 fprintf(output,
"%g %g TR\n", (
double)0 , ph_ );
658 fprintf(output,
"1 -1 SC\n");
660 fprintf(output,
"GS\n");
662 if (!((media & Fl_Paged_Device::MEDIA) &&(lang_level_>1))){
665 fprintf(output,
"-90 rotate %i 0 translate\n",
int(-pw));
668 fprintf(output,
"90 rotate -%i -%i translate\n", (lang_level_ == 2 ?
int(pw - ph) : 0),
int(ph));
673 fprintf(output,
"180 rotate %i %i translate\n",
int(-pw),
int(-ph));
676 fprintf(output,
"GS\nCS\n");
679void Fl_PostScript_Graphics_Driver::page(
int format){
689 page(pw_,ph_,format & 0xFF00);
697 fprintf(output,
"GS\n");
698 fprintf(output,
"BP\n");
699 fprintf(output,
"%i %i MT\n", x , y);
700 fprintf(output,
"%i %i LT\n", x+w-1 , y);
701 fprintf(output,
"%i %i LT\n", x+w-1 , y+h-1);
702 fprintf(output,
"%i %i LT\n", x , y+h-1);
703 fprintf(output,
"ECP\n");
704 fprintf(output,
"GR\n");
708 fprintf(output,
"%g %g %i %i FR\n", x-0.5, y-0.5, w, h);
712 fprintf(output,
"GS\n");
713 fprintf(output,
"%i %i %i %i L\n", x1 , y1, x2 ,y2);
714 fprintf(output,
"GR\n");
718 fprintf(output,
"GS\n");
719 fprintf(output,
"BP\n");
720 fprintf(output,
"%i %i MT\n", x0 , y0);
721 fprintf(output,
"%i %i LT\n", x1 , y1);
722 fprintf(output,
"%i %i LT\n", x2 , y2);
723 fprintf(output,
"ELP\n");
724 fprintf(output,
"GR\n");
728 fprintf(output,
"GS\n");
729 fprintf(output,
"BP\n");
730 fprintf(output,
"%i %i MT\n", x , y );
731 fprintf(output,
"%i %i LT\n", x1 , y );
732 fprintf(output,
"%i %i LT\n", x1 , y2);
733 fprintf(output,
"%i %i LT\n", x3 , y2);
734 fprintf(output,
"ELP\n");
735 fprintf(output,
"GR\n");
741 fprintf(output,
"GS\n");
742 fprintf(output,
"BP\n");
743 fprintf(output,
"%i %i MT\n", x , y);
744 fprintf(output,
"%i %i LT\n", x1 , y);
745 fprintf(output,
"%i %i LT\n", x1 , y2 );
746 fprintf(output,
"ELP\n");
747 fprintf(output,
"GR\n");
751 fprintf(output,
"GS\n");
752 fprintf(output,
"BP\n");
753 fprintf(output,
"%i %i MT\n", x , y);
754 fprintf(output,
"%i %i LT\n", x1 , y );
755 fprintf(output,
"ELP\n");
757 fprintf(output,
"GR\n");
761 fprintf(output,
"GS\n");
763 fprintf(output,
"BP\n");
764 fprintf(output,
"%i %i MT\n", x , y);
765 fprintf(output,
"%i %i LT\n", x , y1 );
766 fprintf(output,
"%i %i LT\n", x2 , y1 );
767 fprintf(output ,
"%i %i LT\n", x2 , y3);
768 fprintf(output,
"ELP\n");
769 fprintf(output,
"GR\n");
773 fprintf(output,
"GS\n");
774 fprintf(output,
"BP\n");
775 fprintf(output,
"%i %i MT\n", x , y);
776 fprintf(output,
"%i %i LT\n", x , y1);
777 fprintf(output,
"%i %i LT\n", x2 , y1);
778 fprintf(output,
"ELP\n");
779 fprintf(output,
"GR\n");
783 fprintf(output,
"GS\n");
784 fprintf(output,
"BP\n");
785 fprintf(output,
"%i %i MT\n", x , y);
786 fprintf(output,
"%i %i LT\n", x , y1);
787 fprintf(output,
"ELP\n");
788 fprintf(output,
"GR\n");
792 fprintf(output,
"GS\n");
793 fprintf(output,
"BP\n");
794 fprintf(output,
"%i %i MT\n", x0 , y0);
795 fprintf(output,
"%i %i LT\n", x1 , y1);
796 fprintf(output,
"%i %i LT\n", x2 , y2);
797 fprintf(output,
"ECP\n");
798 fprintf(output,
"GR\n");
802 fprintf(output,
"GS\n");
803 fprintf(output,
"BP\n");
804 fprintf(output,
"%i %i MT\n", x0 , y0);
805 fprintf(output,
"%i %i LT\n", x1 , y1);
806 fprintf(output,
"%i %i LT\n", x2 , y2);
807 fprintf(output,
"%i %i LT\n", x3 , y3);
808 fprintf(output,
"ECP\n");
809 fprintf(output,
"GR\n");
813 fprintf(output,
"GS\n");
814 fprintf(output,
"BP\n");
815 fprintf(output,
"%i %i MT\n", x0 , y0);
816 fprintf(output,
"%i %i LT\n", x1 , y1);
817 fprintf(output,
"%i %i LT\n", x2 , y2);
818 fprintf(output,
"EFP\n");
819 fprintf(output,
"GR\n");
823 fprintf(output,
"GS\n");
824 fprintf(output,
"BP\n");
825 fprintf(output,
"%i %i MT\n", x0 , y0 );
826 fprintf(output,
"%i %i LT\n", x1 , y1 );
827 fprintf(output,
"%i %i LT\n", x2 , y2 );
828 fprintf(output,
"%i %i LT\n", x3 , y3 );
830 fprintf(output,
"EFP\n");
831 fprintf(output,
"GR\n");
838static int dashes_flat[5][7]={
848static double dashes_cap[5][7]={
851{0.01,1.99,-1,0,0,0,0},
852{2,2,0.01,1.99,-1,0,0},
853{2,2,0.01,1.99,0.01,1.99,-1}
864 if(dashes != linedash_)
865 strcpy(linedash_,dashes);
875 fprintf(output,
"%i setlinewidth\n",
width);
877 if(!style && (!dashes || !(*dashes)) && width0)
880 int cap = (style &0xf00) >> 8;
882 fprintf(output,
"%i setlinecap\n", cap);
884 int join = (style & 0xf000) >> 12;
887 fprintf(output,
"%i setlinejoin\n", join);
890 fprintf(output,
"[");
891 if(dashes && *dashes){
893 fprintf(output,
"%i ", *dashes);
899 double *dt = dashes_cap[style & 0xff];
901 fprintf(output,
"%g ",
width * (*dt));
906 ds = dashes_flat[style & 0xff];
908 fprintf(output,
"%i ",
width * (*ds));
913 fprintf(output,
"] 0 setdash\n");
916static const char *_fontNames[] = {
919"Helvetica-Oblique2B",
920"Helvetica-BoldOblique2B",
924"Courier-BoldOblique2B",
943 fprintf(output,
"/%s SF\n" , _fontNames[f]);
948 int max = desc->font->height;
950 if (ps_size > max) ps_size = max;
954 char *name = desc->font->font_name_list[0];
955 char *p = strstr(name,
"--");
957 sscanf(p + 2,
"%f", &ps_size);
961 fprintf(output,
"%.1f FS\n", ps_size);
984 color(cr_, cg_, cb_);
989 cr_ = r; cg_ = g; cb_ = b;
990 if (r == g && g == b) {
991 double gray = r/255.0;
992 fprintf(output,
"%g GL\n", gray);
998 fprintf(output,
"%g %g %g SRGB\n", fr , fg , fb);
1004 fprintf(output,
"GS %d %d translate %d rotate\n", x, y, - angle);
1005 this->transformed_draw(str, n, 0, 0);
1006 fprintf(output,
"GR\n");
1013 uchar red, green, blue, r, g, b;
1014 uchar bit, byte, *q;
1022 for (
int j = 0; j < w; j++) {
1027 if (r != red || g != green || b != blue)
byte |= bit;
1035 if (bit != 0x80) *q++ = byte;
1041static void transformed_draw_extra(
const char* str,
int n,
double x,
double y,
int w,
1044#if defined(USE_X11) && !USE_XFT
1051 int w_scaled = (int)(w * (scale + 0.5));
1052 int h = (int)(driver->
height() * scale);
1060 fl_rectf(0, 0, w_scaled, (
int)(h+3*scale) );
1062#if defined(USE_X11) && !USE_XFT
1070 if (rtl)
fl_rtl_draw(str, n, w2, (
int)(h * 0.8) );
1071 else fl_draw(str, n, 1, (
int)(h * 0.8) );
1075 driver->
font(fontnum, old_size);
1078 uchar *mask = calc_mask(img, w2, h, bg_color);
1081 scale = w2 / float(w);
1082 fprintf(output,
"%g %g %g %g %d %d MI\n", x, y - h*0.77/scale, w2/scale, h/scale, w2, h);
1084 int wmask = (w2+7)/8;
1085 for (
int j = h - 1; j >= 0; j--){
1086 di = mask + j * wmask;
1087 for (
int i = 0; i < wmask; i++){
1089 fprintf(output,
"%2.2x", *di );
1092 fprintf(output,
"\n");
1094 fprintf(output,
">\n");
1098static int is_in_table(
unsigned utf) {
1100 static unsigned extra_table_roman[] = {
1101 0x192, 0x2C6, 0x2C7,
1102 0x2D8, 0x2D9, 0x2DA, 0x2DB, 0x2DC, 0x2DD,
1103 0x2013, 0x2014, 0x2018, 0x2019,
1104 0x201A, 0x201C, 0x201D, 0x201E,
1105 0x2020, 0x2021, 0x2022,
1106 0x2026, 0x2030, 0x2039, 0x203A,
1107 0x2044, 0x20AC, 0x2122,
1108 0x2202, 0x2206, 0x2211, 0x221A,
1109 0x221E, 0x2260, 0x2264,
1111 0x25CA, 0xFB01, 0xFB02,
1114 for ( i = 0; i <
sizeof(extra_table_roman)/
sizeof(int); i++) {
1115 if (extra_table_roman[i] == utf)
return i + 0x180;
1121void Fl_PostScript_Graphics_Driver::transformed_draw(
const char* str,
int n,
double x,
double y) {
1123 if (!n || !str || !*str)
return;
1125 int w = (int)
width(str, n);
1128 transformed_draw_extra(str, n, x, y, w, output,
this,
false);
1131 fprintf(output,
"%d <", w);
1139 const char *last = str + n;
1140 const char *str2 = str;
1141 while (str2 < last) {
1148 else if ( (code = is_in_table(utf)) != 0) {
1152 fprintf(output,
"> pop pop\n");
1153 transformed_draw_extra(str, n, x, y, w, output,
this,
false);
1156 fprintf(output,
"%4.4X", utf);
1158 fprintf(output,
"> %g %g show_pos_width\n", x, y);
1162 int w = (int)
width(str, n);
1163 transformed_draw_extra(str, n, x - w, y, w, output,
this,
true);
1166void Fl_PostScript_Graphics_Driver::concat(){
1170void Fl_PostScript_Graphics_Driver::reconcat(){
1178 fprintf(output,
"GS\n");
1181 fprintf(output,
"BP\n");
1187 fprintf(output,
"GS\n");
1189 fprintf(output,
"BP\n");
1195 fprintf(output,
"GS\n");
1197 fprintf(output,
"BP\n");
1203 fprintf(output,
"GS\n");
1205 fprintf(output,
"BP\n");
1212 fprintf(output,
"%g %g MT\n", x , y);
1217 fprintf(output,
"%g %g MT\n", x , y);
1220 fprintf(output,
"%g %g LT\n", x , y);
1224 if(shape_==NONE)
return;
1226 fprintf(output,
"%g %g MT\n", x , y);
1228 fprintf(output,
"%g %g LT\n", x , y);
1231 fprintf(output,
"%g %g %g %g %g %g curveto \n", x1 , y1 , x2 , y2 , x3 , y3);
1237 fprintf(output,
"GS\n");
1240 fprintf(output,
"%g %g %g 0 360 arc\n", x , y , r);
1243 fprintf(output,
"GR\n");
1246 fprintf(output,
"%g %g %g 0 360 arc\n", x , y , r);
1251 if(shape_==NONE)
return;
1254 fprintf(output,
"%g %g %g %g %g arc\n", x , y , r , -start, -a);
1256 fprintf(output,
"%g %g %g %g %g arcn\n", x , y , r , -start, -a);
1261 fprintf(output,
"GS\n");
1264 fprintf(output,
"%g %g TR\n", x + w/2.0 -0.5 , y + h/2.0 - 0.5);
1265 fprintf(output,
"%g %g SC\n", (w-1)/2.0 , (h-1)/2.0 );
1268 fprintf(output,
"%g %g SC\n", 2.0/(w-1) , 2.0/(h-1) );
1269 fprintf(output,
"%g %g TR\n", -x - w/2.0 +0.5 , -y - h/2.0 +0.5);
1276 fprintf(output,
"GR\n");
1281 fprintf(output,
"GS\n");
1282 fprintf(output,
"%g %g TR\n", x + w/2.0 -0.5 , y + h/2.0 - 0.5);
1283 fprintf(output,
"%g %g SC\n", (w-1)/2.0 , (h-1)/2.0 );
1286 arc(0.0,0.0, 1, a2, a1);
1288 fprintf(output,
"GR\n");
1294 fprintf(output,
"ELP\n");
1295 fprintf(output,
"GR\n");
1302 fprintf(output,
"ELP\n");
1303 fprintf(output,
"GR\n");
1309 fprintf(output,
"ECP\n");
1310 fprintf(output,
"GR\n");
1318 fprintf(output,
"EFP\n");
1319 fprintf(output,
"GR\n");
1326 fprintf(output,
"%g %g MT\n", x , y);
1329 fprintf(output,
"%g %g LT\n", x , y);
1336 Clip * c=
new Clip();
1337 clip_box(x,y,w,h,c->x,c->y,c->w,c->h);
1340 fprintf(output,
"CR\nCS\n");
1343 fprintf(output,
"%g %g %i %i CL\n", clip_->x-0.5 , clip_->y-0.5 , clip_->w , clip_->h);
1348 Clip * c =
new Clip();
1351 clip_->x = clip_->y = clip_->w = clip_->h = -1;
1352 fprintf(output,
"CR\nCS\n");
1362 fprintf(output,
"CR\nCS\n");
1363 if(clip_ && clip_->w >0)
1364 fprintf(output,
"%g %g %i %i CL\n", clip_->x - 0.5, clip_->y - 0.5, clip_->w , clip_->h);
1380 if (x > (X=clip_->x)) {X=x; ret=1;}
1381 if (y > (Y=clip_->y)) {Y=y; ret=1;}
1382 if ((x+w) < (clip_->x+clip_->w)) {
1388 W = clip_->x + clip_->w - X;
1393 if ((y+h) < (clip_->y+clip_->h)) {
1397 H = clip_->y + clip_->h - Y;
1407 if(!clip_)
return 1;
1408 if(clip_->w < 0)
return 1;
1418 Fl_PostScript_Graphics_Driver *ps =
driver();
1419 if(left) *left = (int)(ps->left_margin / ps->scale_x + .5);
1420 if(right) *right = (int)(ps->left_margin / ps->scale_x + .5);
1421 if(top) *top = (int)(ps->top_margin / ps->scale_y + .5);
1422 if(bottom) *bottom = (int)(ps->top_margin / ps->scale_y + .5);
1428 Fl_PostScript_Graphics_Driver *ps =
driver();
1429 if(w) *w = (int)((ps->pw_ - 2 * ps->left_margin) / ps->scale_x + .5);
1430 if(h) *h = (int)((ps->ph_ - 2 * ps->top_margin) / ps->scale_y + .5);
1443 Fl_PostScript_Graphics_Driver *ps =
driver();
1444 fprintf(ps->output,
"GR GR GS %d %d TR %f %f SC %d %d TR %f rotate GS\n",
1445 ps->left_margin, ps->top_margin, ps->scale_x, ps->scale_y, x, y, ps->angle);
1450 if (s_y == 0.) s_y = s_x;
1451 Fl_PostScript_Graphics_Driver *ps =
driver();
1454 fprintf(ps->output,
"GR GR GS %d %d TR %f %f SC %f rotate GS\n",
1455 ps->left_margin, ps->top_margin, ps->scale_x, ps->scale_y, ps->angle);
1460 Fl_PostScript_Graphics_Driver *ps =
driver();
1461 ps->angle = - rot_angle;
1462 fprintf(ps->output,
"GR GR GS %d %d TR %f %f SC %d %d TR %f rotate GS\n",
1463 ps->left_margin, ps->top_margin, ps->scale_x, ps->scale_y,
x_offset,
y_offset, ps->angle);
1468 fprintf(
driver()->output,
"GS %d %d translate GS\n", x, y);
1473 fprintf(
driver()->output,
"GR GR\n");
1478 Fl_PostScript_Graphics_Driver *ps =
driver();
1479 ps->page(ps->page_format_);
1482 ps->scale_x = ps->scale_y = 1.;
1484 fprintf(ps->output,
"GR GR GS %d %d translate GS\n", ps->left_margin, ps->top_margin);
1496 Fl_PostScript_Graphics_Driver *ps =
driver();
1498 fprintf(ps->output,
"CR\nGR\nGR\nGR\nSP\n restore\n");
1500 fprintf(ps->output,
"%%%%Trailer\n");
1501 fprintf(ps->output,
"%%%%Pages: %i\n" , ps->nPages);
1504 fprintf(ps->output,
"GR\n restore\n");
1505 fputs(
"%%EOF",ps->output);
1508 if(ferror(ps->output)) {
1509 fl_alert (
"Error during PostScript data output.");
1511 if (ps->close_cmd_) {
1512 (*ps->close_cmd_)(ps->output);
1517 Fl_PostScript_Graphics_Driver::Clip * c= ps->clip_;
1518 ps->clip_= ps->clip_->prev;
1524#if ! (defined(__APPLE__) || defined(WIN32) )
1530 if (!print_panel) make_print_panel();
1532 print_selection->deactivate();
1533 print_all->setonly();
1534 print_all->do_callback();
1535 print_from->value(
"1");
1536 {
char tmp[10]; snprintf(tmp,
sizeof(tmp),
"%d", pages); print_to->value(tmp); }
1537 print_panel->show();
1538 while (print_panel->shown())
Fl::wait();
1547 int from = 1, to = pages;
1548 if (print_pages->value()) {
1549 sscanf(print_from->value(),
"%d", &from);
1550 sscanf(print_to->value(),
"%d", &to);
1552 if (from < 1) from = 1;
1553 if (to > pages) to = pages;
1554 if (to < from) to = from;
1555 if (firstpage) *firstpage = from;
1556 if (lastpage) *lastpage = to;
1557 pages = to - from + 1;
1565 int print_pipe = print_choice->value();
1567 const char *media = print_page_size->text(print_page_size->value());
1568 const char *printer = (
const char *)print_choice->menu()[print_choice->value()].user_data();
1569 if (!print_pipe) printer =
"<File>";
1577 snprintf(command,
sizeof(command),
"lp -s -d %s -n %d -t '%s' -o media=%s",
1578 printer, print_collate_button->value() ? 1 : (
int)(print_copies->value() + 0.5),
1581 Fl_PostScript_Graphics_Driver *ps =
driver();
1582 ps->output = popen(command,
"w");
1584 fl_alert(
"could not run command: %s\n",command);
1587 ps->close_command(pclose);
1589 return ps->start_postscript(pages, format, layout);
int Fl_Font
A font number is an index into the internal font table.
Definition Enumerations.H:707
const Fl_Font FL_HELVETICA
Helvetica (or Arial) normal (0)
Definition Enumerations.H:709
Fl_Color fl_rgb_color(uchar r, uchar g, uchar b)
Returns the 24-bit color value closest to r, g, b.
Definition Enumerations.H:829
unsigned int Fl_Color
an FLTK color value
Definition Enumerations.H:764
const Fl_Font FL_FREE_FONT
first one to allocate
Definition Enumerations.H:726
int Fl_Fontsize
Size of a font in pixels.
Definition Enumerations.H:736
FL_EXPORT Fl_Graphics_Driver * fl_graphics_driver
Points to the driver that currently receives all graphics requests.
Fl_Native_File_Chooser widget.
declaration of classes Fl_PostScript_Graphics_Driver, Fl_PostScript_File_Device.
static Fl_Display_Device * display_device()
Returns the platform display device.
Definition Fl_Device.H:626
A virtual class subclassed for each graphics driver FLTK uses.
Definition Fl_Device.H:110
virtual int height()=0
see fl_height().
Fl_Color color()
see fl_color(void).
Definition Fl_Device.H:400
Fl_Graphics_Driver()
The constructor.
Definition Fl_Device.cxx:77
static matrix * fl_matrix
Points to the current coordinate transformation matrix.
Definition Fl_Device.H:144
Fl_Font_Descriptor * font_descriptor()
Returns a pointer to the current Fl_Font_Descriptor for the graphics driver.
Definition Fl_Device.H:402
virtual void color(Fl_Color c)
see fl_color(Fl_Color c).
Definition Fl_Device.H:262
Fl_Fontsize size()
see fl_size().
Definition Fl_Device.H:388
virtual void font(Fl_Font face, Fl_Fontsize size)
see fl_font(Fl_Font face, Fl_Fontsize size).
Definition Fl_Device.H:384
Fl_Font font()
see fl_font(void).
Definition Fl_Device.H:386
This class lets an FLTK application easily and consistently access the operating system's native file...
Definition Fl_Native_File_Chooser.H:158
const char * filter() const
Returns the filter string last set.
Definition Fl_Native_File_Chooser_FLTK.cxx:300
void type(int)
Sets the current Fl_Native_File_Chooser::Type of browser.
Definition Fl_Native_File_Chooser_FLTK.cxx:112
void options(int)
Sets the platform specific chooser options to val.
Definition Fl_Native_File_Chooser_FLTK.cxx:137
const char * filename() const
Return the filename the user choose.
Definition Fl_Native_File_Chooser_FLTK.cxx:230
@ BROWSE_SAVE_FILE
browse to save a file
Definition Fl_Native_File_Chooser.H:165
int show()
Post the chooser's dialog.
Definition Fl_Native_File_Chooser_FLTK.cxx:155
@ SAVEAS_CONFIRM
Show native 'Save As' overwrite confirm dialog (if supported)
Definition Fl_Native_File_Chooser.H:170
void title(const char *)
Set the title of the file chooser's dialog window.
Definition Fl_Native_File_Chooser_FLTK.cxx:260
int y_offset
vertical offset to the origin of graphics coordinates
Definition Fl_Paged_Device.H:116
virtual void origin(int x, int y)
Sets the position in page coordinates of the origin of graphics functions.
Definition Fl_Paged_Device.cxx:204
Page_Layout
Possible page layouts.
Definition Fl_Paged_Device.H:90
@ REVERSED
Reversed orientation.
Definition Fl_Paged_Device.H:93
@ PORTRAIT
Portrait orientation.
Definition Fl_Paged_Device.H:91
@ LANDSCAPE
Landscape orientation.
Definition Fl_Paged_Device.H:92
int x_offset
horizontal offset to the origin of graphics coordinates
Definition Fl_Paged_Device.H:114
Page_Format
Possible page formats.
Definition Fl_Paged_Device.H:54
@ A4
A4 format.
Definition Fl_Paged_Device.H:59
@ LETTER
Letter format.
Definition Fl_Paged_Device.H:82
static const page_format page_formats[NO_PAGE_FORMATS]
width, height and name of all elements of the enum Page_Format.
Definition Fl_Paged_Device.H:254
void translate(int x, int y)
Translates the current graphics origin accounting for the current rotation.
Fl_PostScript_File_Device()
The constructor.
Definition Fl_PostScript.cxx:70
void untranslate(void)
Undoes the effect of a previous translate() call.
static const char * file_chooser_title
Label of the PostScript file chooser window.
Definition Fl_PostScript.H:246
~Fl_PostScript_File_Device()
The destructor.
Definition Fl_PostScript.cxx:145
int end_page(void)
To be called at the end of each page.
int start_job(int pagecount, enum Fl_Paged_Device::Page_Format format=Fl_Paged_Device::A4, enum Fl_Paged_Device::Page_Layout layout=Fl_Paged_Device::PORTRAIT)
Begins the session where all graphics requests will go to a local PostScript file.
Definition Fl_PostScript.cxx:96
void rotate(float angle)
Rotates the graphics operations relatively to paper.
Fl_PostScript_Graphics_Driver * driver()
Returns the PostScript driver of this drawing surface.
Definition Fl_PostScript.cxx:81
void margins(int *left, int *top, int *right, int *bottom)
Computes the dimensions of margins that lie between the printable page area and the full page.
void scale(float scale_x, float scale_y=0.)
Changes the scaling of page coordinates.
void end_job(void)
To be called at the end of a print job.
int start_page(void)
Starts a new printed page.
void origin(int *x, int *y)
Computes the page coordinates of the current origin of graphics functions.
int printable_rect(int *w, int *h)
Computes the width and height of the printable area of the page.
PostScript graphical backend.
Definition Fl_PostScript.H:64
void begin_polygon()
see fl_begin_polygon().
int clip_box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H)
see fl_clip_box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H).
void rect(int x, int y, int w, int h)
see fl_rect(int x, int y, int w, int h).
void arc(double x, double y, double r, double start, double a)
see fl_arc(double x, double y, double r, double start, double end).
void line_style(int style, int width=0, char *dashes=0)
see fl_line_style(int style, int width, char* dashes).
Fl_PostScript_Graphics_Driver()
The constructor.
Definition Fl_PostScript.cxx:51
void begin_line()
see fl_begin_line().
void pie(int x, int y, int w, int h, double a1, double a2)
see fl_pie(int x, int y, int w, int h, double a1, double a2).
void begin_loop()
see fl_begin_loop().
void pop_clip()
see fl_pop_clip().
void begin_points()
see fl_begin_points().
void end_points()
see fl_end_points().
void rtl_draw(const char *s, int n, int x, int y)
see fl_rtl_draw(const char *str, int n, int x, int y).
void transformed_vertex(double x, double y)
see fl_transformed_vertex(double xf, double yf).
void end_polygon()
see fl_end_polygon().
void xyline(int x, int y, int x1)
see fl_xyline(int x, int y, int x1).
double width(const char *, int)
see fl_width(const char *str, int n).
void polygon(int x0, int y0, int x1, int y1, int x2, int y2)
see fl_polygon(int x0, int y0, int x1, int y1, int x2, int y2).
void draw(const char *s, int n, int x, int y)
see fl_draw(const char *str, int n, int x, int y).
Definition Fl_PostScript.H:196
void loop(int x0, int y0, int x1, int y1, int x2, int y2)
see fl_loop(int x0, int y0, int x1, int y1, int x2, int y2).
void circle(double x, double y, double r)
see fl_circle(double x, double y, double r).
~Fl_PostScript_Graphics_Driver()
The destructor.
Definition Fl_PostScript.cxx:63
void line(int x1, int y1, int x2, int y2)
see fl_line(int x, int y, int x1, int y1).
void curve(double x, double y, double x1, double y1, double x2, double y2, double x3, double y3)
see fl_curve(double X0, double Y0, double X1, double Y1, double X2, double Y2, double X3,...
void rectf(int x, int y, int w, int h)
see fl_rectf(int x, int y, int w, int h).
void end_loop()
see fl_end_loop().
void push_no_clip()
see fl_push_no_clip().
void point(int x, int y)
see fl_point(int x, int y).
void vertex(double x, double y)
see fl_vertex(double x, double y).
void yxline(int x, int y, int y1)
see fl_yxline(int x, int y, int y1).
void push_clip(int x, int y, int w, int h)
see fl_push_clip(int x, int y, int w, int h).
void text_extents(const char *c, int n, int &dx, int &dy, int &w, int &h)
see fl_text_extents(const char*, int n, int& dx, int& dy, int& w, int& h).
int not_clipped(int x, int y, int w, int h)
see fl_not_clipped(int x, int y, int w, int h).
int height()
see fl_height().
int descent()
see fl_descent().
void end_line()
see fl_end_line().
int start_job(int pages, int *firstpage=NULL, int *lastpage=NULL)
Starts a print job.
void driver(Fl_Graphics_Driver *graphics_driver)
Sets the graphics driver of this drawing surface.
Definition Fl_Device.H:605
virtual void set_current(void)
Use this drawing surface for future graphics requests.
Definition Fl_Device.cxx:69
Fl_Graphics_Driver * driver()
Returns the graphics driver of this drawing surface.
Definition Fl_Device.H:607
static int wait()
Waits until "something happens" and then returns.
Definition Fl.cxx:605
utility header to pull drawing functions together
unsigned char uchar
unsigned char
Definition fl_types.h:39
FL_EXPORT Fl_Color fl_contrast(Fl_Color fg, Fl_Color bg)
Returns a color that contrasts with the background color.
Definition fl_color.cxx:412
FL_EXPORT double fl_width(const char *txt)
Returns the typographical width of a nul-terminated string.
Definition fl_font.cxx:68
static unsigned get_color(Fl_Color i)
Returns the RGB value(s) for the given FLTK color index.
Definition fl_color.cxx:330
Fl_Font fl_font()
Returns the face set by the most recent call to fl_font().
Definition fl_draw.H:508
Fl_Color fl_color()
Returns the last fl_color() that was set.
Definition fl_draw.H:79
void fl_begin_offscreen(Fl_Offscreen ctx)
Send all subsequent drawing commands to this offscreen buffer.
Definition Fl_Double_Window.cxx:258
Fl_Offscreen fl_create_offscreen(int w, int h)
Creation of an offscreen graphics buffer.
Definition Fl_Double_Window.cxx:200
void fl_rectf(int x, int y, int w, int h)
Colors with current color a rectangle that exactly fills the given bounding box.
Definition fl_draw.H:217
void fl_rtl_draw(const char *str, int n, int x, int y)
Draws an array of n characters right to left starting at given location.
Definition fl_draw.H:615
void fl_delete_offscreen(Fl_Offscreen ctx)
Deletion of an offscreen graphics buffer.
Definition Fl_Double_Window.cxx:241
FL_EXPORT uchar * fl_read_image(uchar *p, int X, int Y, int W, int H, int alpha=0)
Reads an RGB(A) image from the current window or off-screen buffer.
Definition fl_read_image.cxx:91
void fl_end_offscreen()
Quit sending drawing commands to the current offscreen buffer.
Definition Fl_Double_Window.cxx:276
FL_EXPORT void fl_draw(const char *str, int x, int y)
Draws a nul-terminated string starting at the given location.
Definition fl_font.cxx:73
@ FL_CAP_SQUARE
cap style: end wraps end point
Definition fl_draw.H:196
@ FL_SOLID
line style: ___________
Definition fl_draw.H:188
FL_EXPORT unsigned fl_utf8decode(const char *p, const char *end, int *len)
Definition fl_utf.c:140
int width
width in points
Definition Fl_Paged_Device.H:101
int height
height in points
Definition Fl_Paged_Device.H:103