Dear list,
A small follow up on this issue. The same behavior is observed for
postscript() and pdf(), so I suspect the erroneous code is in
grDevices/src/devPS.c. In particular, this macro,
static void
PostScriptSetLineTexture(FILE *fp, const char *dashlist, int nlty, double lwd)
{
/* use same macro for Postscript and PDF */
#define PP_SetLineTexture(_CMD_) \
double dash; \
int i; \
fprintf(fp,"["); \
for (i = 0; i < nlty; i++) { \
dash = (lwd >= 1 ? lwd: 1) * \
((i % 2) ? dashlist[i] + 1 \
:((nlty == 1 && dashlist[i] == 1.) ? 1. : dashlist[i] - 1)); \
if (dash < 0) dash = 0; \
fprintf(fp," %.2f", dash); \
} \
fprintf(fp,"] 0 %s\n", _CMD_)
PP_SetLineTexture("setdash");
}
I think the dash pattern should be
dash = (lwd >= 1 ? lwd: 1) * \
((i % 2) ? dashlist[i] \
:((nlty == 1 && dashlist[i] == 1.) ? 1. : dashlist[i] ));
instead (but I don't know C well enough to be sure).
Best regards,
baptiste
incorrect linetype with pdf device (PR#14128)
2 messages · Baptiste Auguie
1 day later
Dear all,
Running this minimal example,
library(grid)
postscript("test-123456.eps")
grid.newpage()
grid.lines(gp=gpar(lty="123456", lineend = "butt"))
dev.off()
produces eps output with the following setdash description towards the
end of the file,
## [ 0.00 3.00 2.00 5.00 4.00 7.00] 0 setdash
I consulted the postscript reference manual (page 667 *), which
indicates that the array should rather be [1 2 3 4 5 6] as intended
(and as produced by, e.g., quartz())
(*): http://www.adobe.com/products/postscript/pdfs/PLRM.pdf
Regards,
baptiste