The R Project SVN R

Rev

Rev 5731 | Rev 6994 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5731 Rev 6098
Line 250... Line 250...
250
    return Unknown;
250
    return Unknown;
251
}
251
}
252
 
252
 
253
static char *SkipToNextItem(char *p)
253
static char *SkipToNextItem(char *p)
254
{
254
{
255
    while (!isspace(*p)) p++;
255
    while (!isspace((int)*p)) p++;
256
    while (isspace(*p)) p++;
256
    while (isspace((int)*p)) p++;
257
    return p;
257
    return p;
258
}
258
}
259
 
259
 
260
static char *SkipToNextKey(char *p)
260
static char *SkipToNextKey(char *p)
261
{
261
{
262
    while (*p != ';') p++;
262
    while (*p != ';') p++;
263
    p++;
263
    p++;
264
    while (isspace(*p)) p++;
264
    while (isspace((int)*p)) p++;
265
    return p;
265
    return p;
266
}
266
}
267
 
267
 
268
static int GetFontBBox(char *buf, FontMetricInfo *metrics)
268
static int GetFontBBox(char *buf, FontMetricInfo *metrics)
269
{
269
{
Line 425... Line 425...
425
/* of the (unrotated) printer page in points whereas the graphics */
425
/* of the (unrotated) printer page in points whereas the graphics */
426
/* region box is for the rotated page. */
426
/* region box is for the rotated page. */
427
 
427
 
428
static void PSFileHeader(FILE *fp, int font, int encoding, char *papername,
428
static void PSFileHeader(FILE *fp, int font, int encoding, char *papername,
429
			 double paperwidth, double paperheight, int landscape,
429
			 double paperwidth, double paperheight, int landscape,
-
 
430
			 int EPSFheader,
430
			 double left, double bottom, double right, double top)
431
			 double left, double bottom, double right, double top)
431
{
432
{
-
 
433
    if(EPSFheader) 
-
 
434
	fprintf(fp, "%%!PS-Adobe-3.0 EPSF-3.0\n");
-
 
435
    else
432
    fprintf(fp, "%%!PS-Adobe-3.0\n");
436
	fprintf(fp, "%%!PS-Adobe-3.0\n");
433
    fprintf(fp, "%%%%DocumentFonts: %s %s %s\n%%%%+ %s %s\n",
437
    fprintf(fp, "%%%%DocumentFonts: %s %s %s\n%%%%+ %s %s\n",
434
	    Family[font].font[0].name, Family[font].font[1].name,
438
	    Family[font].font[0].name, Family[font].font[1].name,
435
	    Family[font].font[2].name, Family[font].font[3].name,
439
	    Family[font].font[2].name, Family[font].font[3].name,
436
	    Family[font].font[4].name);
440
	    Family[font].font[4].name);
-
 
441
    if(!EPSFheader)
437
    fprintf(fp, "%%%%DocumentMedia: %s %.0f %.0f 0 ()\n",
442
	fprintf(fp, "%%%%DocumentMedia: %s %.0f %.0f 0 ()\n",
438
	    papername, paperwidth, paperheight);
443
		papername, paperwidth, paperheight);
439
    fprintf(fp, "%%%%Title: R Graphics Output\n");
444
    fprintf(fp, "%%%%Title: R Graphics Output\n");
440
    fprintf(fp, "%%%%Creator: R Software\n");
445
    fprintf(fp, "%%%%Creator: R Software\n");
441
    fprintf(fp, "%%%%Pages: (atend)\n");
446
    fprintf(fp, "%%%%Pages: (atend)\n");
442
    if (landscape) {
447
    if (landscape) {
443
	fprintf(fp, "%%%%Orientation: Landscape\n");
448
	fprintf(fp, "%%%%Orientation: Landscape\n");
Line 620... Line 625...
620
 
625
 
621
    double width;	 /* plot width in points */
626
    double width;	 /* plot width in points */
622
    double height;	 /* plot height in points */
627
    double height;	 /* plot height in points */
623
    double pagewidth;	 /* page width in points */
628
    double pagewidth;	 /* page width in points */
624
    double pageheight;	 /* page height in points */
629
    double pageheight;	 /* page height in points */
-
 
630
    int pagecentre;      /* centre image on page? */
625
 
631
 
626
    double lwd;		 /* current line width */
632
    double lwd;		 /* current line width */
627
    int lty;		 /* current line type */
633
    int lty;		 /* current line type */
628
    rcolor col;		 /* current color */
634
    rcolor col;		 /* current color */
629
    rcolor fill;	 /* current fill color */
635
    rcolor fill;	 /* current fill color */
630
    rcolor bg;		 /* background color */
636
    rcolor bg;		 /* background color */
631
 
637
 
632
    FILE *psfp;		 /* output file */
638
    FILE *psfp;		 /* output file */
-
 
639
 
-
 
640
    int EPSFheader;      /* EPSF header */
633
}
641
}
634
PostScriptDesc;
642
PostScriptDesc;
635
 
643
 
636
static FontMetricInfo metrics[5];	/* font metrics */
644
static FontMetricInfo metrics[5];	/* font metrics */
637
 
645
 
Line 684... Line 692...
684
 
692
 
685
 
693
 
686
int PSDeviceDriver(DevDesc *dd, char *file, char *paper, char *family,
694
int PSDeviceDriver(DevDesc *dd, char *file, char *paper, char *family,
687
		   char *bg, char *fg,
695
		   char *bg, char *fg,
688
		   double width, double height,
696
		   double width, double height,
689
		   double horizontal, double ps)
697
		   double horizontal, double ps,
-
 
698
		   int onefile, int pagecentre)
690
{
699
{
691
    /* If we need to bail out with some sort of "error" */
700
    /* If we need to bail out with some sort of "error" */
692
    /* then we must free(dd) */
701
    /* then we must free(dd) */
693
 
702
 
694
    double xoff, yoff, pointsize;
703
    double xoff, yoff, pointsize;
Line 752... Line 761...
752
    else if(!strcmp(pd->papername, "Executive") ||
761
    else if(!strcmp(pd->papername, "Executive") ||
753
	    !strcmp(pd->papername, "executive")) {
762
	    !strcmp(pd->papername, "executive")) {
754
	pd->pagewidth  =  7.25;
763
	pd->pagewidth  =  7.25;
755
	pd->pageheight = 10.5;
764
	pd->pageheight = 10.5;
756
    }
765
    }
-
 
766
    else if(!strcmp(pd->papername, "special")) {
-
 
767
	if(pd->landscape) {
-
 
768
	    pd->pagewidth  = height;
-
 
769
	    pd->pageheight =  width;
-
 
770
	} else {
-
 
771
	    pd->pagewidth  =  width;
-
 
772
	    pd->pageheight = height;
-
 
773
	}
-
 
774
    }
757
    else {
775
    else {
758
	free(dd);
776
	free(dd);
759
	free(pd);
777
	free(pd);
760
	error("invalid page type (postscript)");
778
	error("invalid page type (postscript)");
761
    }
779
    }
-
 
780
    pd->pagecentre = pagecentre;
762
    pd->paperwidth = 72 * pd->pagewidth;
781
    pd->paperwidth = 72 * pd->pagewidth;
763
    pd->paperheight = 72 * pd->pageheight;
782
    pd->paperheight = 72 * pd->pageheight;
-
 
783
    pd->EPSFheader = !onefile;
764
    if(pd->landscape) {
784
    if(pd->landscape) {
765
	double tmp;
785
	double tmp;
766
	tmp = pd->pagewidth;
786
	tmp = pd->pagewidth;
767
	pd->pagewidth = pd->pageheight;
787
	pd->pagewidth = pd->pageheight;
768
	pd->pageheight = tmp;
788
	pd->pageheight = tmp;
769
    }
789
    }
-
 
790
    if(strcmp(pd->papername, "special")) 
-
 
791
    {
770
    if(pd->width < 0.1 || pd->width > pd->pagewidth-0.5)
792
	if(pd->width < 0.1 || pd->width > pd->pagewidth-0.5)
771
	pd->width = pd->pagewidth-0.5;
793
	    pd->width = pd->pagewidth-0.5;
772
    if(pd->height < 0.1 || pd->height > pd->pageheight-0.5)
794
	if(pd->height < 0.1 || pd->height > pd->pageheight-0.5)
773
	pd->height = pd->pageheight-0.5;
795
	    pd->height = pd->pageheight-0.5;
-
 
796
    }
-
 
797
    if(pagecentre) 
-
 
798
    {
774
    xoff = (pd->pagewidth - pd->width)/2.0;
799
	xoff = (pd->pagewidth - pd->width)/2.0;
775
    yoff = (pd->pageheight - pd->height)/2.0;
800
	yoff = (pd->pageheight - pd->height)/2.0;
-
 
801
    } else {
-
 
802
	xoff = yoff = 0.0;
-
 
803
    }
776
    pd->maxpointsize = 72.0 * ((pd->pageheight > pd->pagewidth) ?
804
    pd->maxpointsize = 72.0 * ((pd->pageheight > pd->pagewidth) ?
777
			       pd->pageheight : pd->pagewidth);
805
			       pd->pageheight : pd->pagewidth);
778
    pd->pageno = 0;
806
    pd->pageno = 0;
779
    pd->lty = 1;
807
    pd->lty = 1;
780
 
808
 
Line 943... Line 971...
943
		     pd->encoding,
971
		     pd->encoding,
944
		     pd->papername,
972
		     pd->papername,
945
		     pd->paperwidth,
973
		     pd->paperwidth,
946
		     pd->paperheight,
974
		     pd->paperheight,
947
		     pd->landscape,
975
		     pd->landscape,
-
 
976
		     pd->EPSFheader,
948
		     dd->dp.bottom,
977
		     dd->dp.bottom,
949
		     dd->dp.left,
978
		     dd->dp.left,
950
		     dd->dp.top,
979
		     dd->dp.top,
951
		     dd->dp.right);
980
		     dd->dp.right);
952
    else
981
    else
Line 955... Line 984...
955
		     pd->encoding,
984
		     pd->encoding,
956
		     pd->papername,
985
		     pd->papername,
957
		     pd->paperwidth,
986
		     pd->paperwidth,
958
		     pd->paperheight,
987
		     pd->paperheight,
959
		     pd->landscape,
988
		     pd->landscape,
-
 
989
		     pd->EPSFheader,
960
		     dd->dp.left,
990
		     dd->dp.left,
961
		     dd->dp.bottom,
991
		     dd->dp.bottom,
962
		     dd->dp.right,
992
		     dd->dp.right,
963
		     dd->dp.top);
993
		     dd->dp.top);
964
 
994
 
Line 982... Line 1012...
982
{
1012
{
983
    PostScriptDesc *pd = (PostScriptDesc *) dd->deviceSpecific;
1013
    PostScriptDesc *pd = (PostScriptDesc *) dd->deviceSpecific;
984
 
1014
 
985
    pd->pageno++;
1015
    pd->pageno++;
986
    if(pd->pageno > 1) PostScriptEndPage(pd->psfp);
1016
    if(pd->pageno > 1) PostScriptEndPage(pd->psfp);
-
 
1017
    if(pd->pageno > 1 && pd->EPSFheader) 
-
 
1018
	warning("multiple pages used in postscript() with onefile=FALSE");
987
    PostScriptStartPage(pd->psfp, pd->pageno);
1019
    PostScriptStartPage(pd->psfp, pd->pageno);
988
    PostScriptSetFont(pd->psfp, pd->fontstyle-1, pd->fontsize);
1020
    PostScriptSetFont(pd->psfp, pd->fontstyle-1, pd->fontsize);
989
    PostScriptSetLineWidth(pd->psfp, 0.75);
1021
    PostScriptSetLineWidth(pd->psfp, 0.75);
990
    PostScriptSetCol(pd->psfp,
1022
    PostScriptSetCol(pd->psfp,
991
		     R_RED(pd->col)/255.0,
1023
		     R_RED(pd->col)/255.0,