[Rd] patch for textspecial and defaultfont in xfig
Sebastian Fischmeister
sfischme at uwaterloo.ca
Mon Jan 19 16:30:19 CET 2009
Thanks for the guidelines. The updated patch also includes an
exhaustive test in R for the two new options.
Sebastian
Index: src/library/grDevices/R/postscript.R
===================================================================
--- src/library/grDevices/R/postscript.R (revision 47637)
+++ src/library/grDevices/R/postscript.R (working copy)
@@ -273,7 +273,7 @@
paper = "default", horizontal = TRUE,
width = 0, height = 0, family = "Helvetica",
pointsize = 12, bg = "transparent", fg = "black",
- pagecentre = TRUE)
+ pagecentre = TRUE, defaultfont = FALSE, textspecial
= FALSE)
{
## do initialization if needed
initPSandPDFfonts()
@@ -281,7 +281,7 @@
if(!checkIntFormat(file)) stop("invalid 'file'")
.External(XFig, file, paper, family, bg, fg,
width, height, horizontal, pointsize,
- onefile, pagecentre, encoding)
+ onefile, pagecentre, defaultfont, textspecial, encoding)
invisible()
}
Index: src/library/grDevices/tests/xfig-tests.Rout.save
===================================================================
--- src/library/grDevices/tests/xfig-tests.Rout.save (revision 0)
+++ src/library/grDevices/tests/xfig-tests.Rout.save (revision 0)
@@ -0,0 +1,34 @@
+
+R version 2.9.0 Under development (unstable) (2009-01-17 r47633)
+Copyright (C) 2009 The R Foundation for Statistical Computing
+ISBN 3-900051-07-0
+
+R is free software and comes with ABSOLUTELY NO WARRANTY.
+You are welcome to redistribute it under certain conditions.
+Type 'license()' or 'licence()' for distribution details.
+
+ Natural language support but running in an English locale
+
+R is a collaborative project with many contributors.
+Type 'contributors()' for more information and
+'citation()' on how to cite R or R packages in publications.
+
+Type 'demo()' for some demos, 'help()' for on-line help, or
+'help.start()' for an HTML browser interface to help.
+Type 'q()' to quit R.
+
+> ## tests for the xfig device
+>
+>
+>
+> xfig("xfig-tests.fig",onefile=TRUE,defaultfont=TRUE,textspecial=TRUE)
+>
+> xfig("xfig-
tests.fig",onefile=TRUE,defaultfont=TRUE,textspecial=FALSE)
+>
+> xfig("xfig-
tests.fig",onefile=TRUE,defaultfont=FALSE,textspecial=TRUE)
+>
+> xfig("xfig-
tests.fig",onefile=TRUE,defaultfont=FALSE,textspecial=FALSE)
+>
+> unlink("xfig-tests.fig")
+>
+>
Index: src/library/grDevices/tests/xfig-tests.R
===================================================================
--- src/library/grDevices/tests/xfig-tests.R (revision 0)
+++ src/library/grDevices/tests/xfig-tests.R (revision 0)
@@ -0,0 +1,14 @@
+## tests for the xfig device
+
+
+
+xfig("xfig-tests.fig",onefile=TRUE,defaultfont=TRUE,textspecial=TRUE)
+
+xfig("xfig-tests.fig",onefile=TRUE,defaultfont=TRUE,textspecial=FALSE)
+
+xfig("xfig-tests.fig",onefile=TRUE,defaultfont=FALSE,textspecial=TRUE)
+
+xfig("xfig-tests.fig",onefile=TRUE,defaultfont=FALSE,textspecial=FALSE)
+
+unlink("xfig-tests.fig")
+
Index: src/library/grDevices/src/devPS.c
===================================================================
--- src/library/grDevices/src/devPS.c (revision 47637)
+++ src/library/grDevices/src/devPS.c (working copy)
@@ -4354,6 +4354,9 @@
int ymax; /* used to invert coord system */
char encoding[50]; /* for writing text */
+ Rboolean textspecial; /* use textspecial flag in xfig for latex
integration */
+ Rboolean defaultfont; /* use the default font in xfig */
+
/*
* Fonts and encodings used on the device
*
@@ -4553,6 +4556,7 @@
double width, double height,
Rboolean horizontal, double ps,
Rboolean onefile, Rboolean pagecentre,
+ Rboolean defaultfont, Rboolean textspecial,
const char *encoding)
{
/* If we need to bail out with some sort of "error" */
@@ -4591,6 +4595,8 @@
pd->width = width;
pd->height = height;
pd->landscape = horizontal;
+ pd->textspecial = textspecial;
+ pd->defaultfont = defaultfont;
pointsize = floor(ps);
if(R_TRANSPARENT(pd->bg) && R_TRANSPARENT(pd->col)) {
free(dd);
@@ -5108,7 +5114,7 @@
fprintf(fp, "4 %d ", (int)floor(2*hadj)); /* Text, how justified */
fprintf(fp, "%d 100 0 ", XF_SetColor(gc->col, pd));
/* color, depth, pen_style */
- fprintf(fp, "%d %d %.4f 4 ", fontnum, (int)size, rot * DEG2RAD);
+ fprintf(fp, "%d %d %.4f %d ", pd->defaultfont?-1:fontnum, (int)size,
rot * DEG2RAD,pd->textspecial?6:4);
/* font pointsize angle flags (Postscript font) */
fprintf(fp, "%d %d ", (int)(size*12),
(int)(16.667*XFig_StrWidth(str, gc, dd) +0.5));
@@ -7441,6 +7447,9 @@
* ps = pointsize
* onefile = {TRUE: normal; FALSE: single EPSF page}
* pagecentre = centre plot region on paper?
+ * defaultfont = {TRUE: use xfig default font; FALSE: use R font}
+ * textspecial = {TRUE: use textspecial; FALSE: use standard font}
+ *
* encoding
*/
@@ -7449,7 +7458,7 @@
pGEDevDesc gdd;
char *vmax;
const char *file, *paper, *family, *bg, *fg, *encoding;
- int horizontal, onefile, pagecentre;
+ int horizontal, onefile, pagecentre, defaultfont, textspecial;
double height, width, ps;
vmax = vmaxget();
@@ -7467,6 +7476,8 @@
ps = asReal(CAR(args)); args = CDR(args);
onefile = asLogical(CAR(args)); args = CDR(args);
pagecentre = asLogical(CAR(args));args = CDR(args);
+ defaultfont = asLogical(CAR(args)); args = CDR(args);
+ textspecial = asLogical(CAR(args)); args = CDR(args);
encoding = CHAR(asChar(CAR(args)));
R_GE_checkVersionOrDie(R_GE_version);
@@ -7476,7 +7487,7 @@
if (!(dev = (pDevDesc) calloc(1, sizeof(DevDesc))))
return 0;
if(!XFigDeviceDriver(dev, file, paper, family, bg, fg, width, height,
- (double) horizontal, ps, onefile, pagecentre,
+ (double) horizontal, ps, onefile, pagecentre, defaultfont,
textspecial,
encoding)) {
/* free(dev); No, freed inside XFigDeviceDriver */
error(_("unable to start device xfig"));
Index: src/library/grDevices/man/xfig.Rd
===================================================================
--- src/library/grDevices/man/xfig.Rd (revision 47637)
+++ src/library/grDevices/man/xfig.Rd (working copy)
@@ -20,7 +20,7 @@
paper = "default", horizontal = TRUE,
width = 0, height = 0, family = "Helvetica",
pointsize = 12, bg = "transparent", fg = "black",
- pagecentre = TRUE)
+ pagecentre = TRUE, defaultfont = FALSE, textspecial = FALSE)
}
\arguments{
\item{file}{a character string giving the name of the file. For use
@@ -60,6 +60,10 @@
\item{fg}{the initial foreground color to be used.}
\item{pagecentre}{logical: should the device region be centred on the
page?}
+ \item{defaultfont}{logical: should the device use xfig's default
+ font?}
+ \item{textspecial}{logical: should the device set the textspecial
flag
+ for all text elements. This is useful when generating pstex from
xfig figures.}
}
%%>>> REAL DOC in SOURCE: ../../../main/devices.c & ../../../
unix/devPS.c
\details{
More information about the R-devel
mailing list