From baptiste.auguie at googlemail.com  Thu Dec 17 14:22:59 2009
From: baptiste.auguie at googlemail.com (baptiste auguie)
Date: Thu, 17 Dec 2009 14:22:59 +0100
Subject: [Rd] incorrect linetype with pdf device (PR#14128)
Message-ID: <de4e29f50912170522ka82a70n4d081426f4d489a9@mail.gmail.com>

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



[Rd] incorrect linetype with pdf device (PR#14128)
baptiste auguie