Skip to content

Commit 9088b49

Browse files
committed
When -Tp (keep postscript) do not remove the 'setpagedevice' lines.
This seems to one of the last bit to make all the tests pass even with /DPS_NO_DUP
1 parent c303fe9 commit 9088b49

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

src/psconvert.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,7 +1634,7 @@ GMT_LOCAL bool psconvert_gs_is_good (int major, int minor) {
16341634
return false; /* Not implemented (?) */
16351635
}
16361636

1637-
EXTERN_MSC int GMT_psconvert (void *V_API, int mode, void *args) {
1637+
EXTERN_MSC int GMT_psconvert(void *V_API, int mode, void *args) {
16381638
unsigned int i, j, k, pix_w = 0, pix_h = 0, got_BBatend;
16391639
int sys_retval = 0, r, pos_file, pos_ext, error = 0, trans_line;
16401640
int n_read_PS_lines, max_PS_lines;
@@ -2274,13 +2274,13 @@ EXTERN_MSC int GMT_psconvert (void *V_API, int mode, void *args) {
22742274
continue;
22752275
}
22762276
if (line[0] != '%') { /* Copy any non-comment line, except one containing setpagedevice in the Setup block */
2277-
if (!has_transparency) has_transparency = (strstr (line, " PSL_transp") != NULL);
2277+
if (!has_transparency) has_transparency = (strstr(line, " PSL_transp") != NULL);
22782278
if (look_for_transparency && has_transparency) {
22792279
transparency = true; /* Yes, found transparency */
22802280
look_for_transparency = false; /* No need to check anymore */
22812281
}
22822282

2283-
if (setup && strstr(line,"setpagedevice") != NULL) { /* This is a "setpagedevice" command that should be avoided */
2283+
if (setup && Ctrl->T.ps != 1 && strstr(line,"setpagedevice") != NULL) { /* This is a "setpagedevice" command that should be avoided */
22842284
if (Ctrl->O.active) {
22852285
size_t len = strlen(line);
22862286
fseek(fp, (off_t)-(len +1), SEEK_CUR); /* Seek back to start of line (+1 why?) */
@@ -2305,24 +2305,24 @@ EXTERN_MSC int GMT_psconvert (void *V_API, int mode, void *args) {
23052305
continue;
23062306
}
23072307

2308-
if (old_transparency_code_needed && strstr (line, ".setfillconstantalpha")) {
2308+
if (old_transparency_code_needed && strstr(line, ".setfillconstantalpha")) {
23092309
/* Our gs is too old so we must switch the modern transparency command to the older .setopacityalpha command.
23102310
* At some point in the future we will abandon support for 9.52 and older and remove this entire if-test */
23112311
if (trans_line == 0) { /* First time we warn and deal with line number one in PSL_transp function */
2312-
GMT_Report (API, GMT_MSG_DEBUG, "Your gs is older than 9.53 so we must replace .setfillconstantalpha with .setopacityalpha.\n");
2313-
fprintf (fpo, " /.setopacityalpha where\n"); /* Look for old .setopacityalpha instead */
2312+
GMT_Report(API, GMT_MSG_DEBUG, "Your gs is older than 9.53 so we must replace .setfillconstantalpha with .setopacityalpha.\n");
2313+
fprintf(fpo, " /.setopacityalpha where\n"); /* Look for old .setopacityalpha instead */
23142314
}
23152315
else
2316-
fprintf (fpo, " { pop PSL_BM_arg .setblendmode PSL_F_arg .setopacityalpha }\n"); /* Ignore the setstrokeconstantalpha value */
2316+
fprintf(fpo, " { pop PSL_BM_arg .setblendmode PSL_F_arg .setopacityalpha }\n"); /* Ignore the setstrokeconstantalpha value */
23172317
trans_line++;
23182318
}
2319-
else if (!old_transparency_code_needed && strstr (line, ".setopacityalpha")) {
2319+
else if (!old_transparency_code_needed && strstr(line, ".setopacityalpha")) {
23202320
/* Our PostScript file was made before 6.2 master was updated to deal with new gs settings */
2321-
GMT_Report (API, GMT_MSG_DEBUG, "Your gs is newer than 9.52 so we must replace .setopacityalpha in old PS files with .setfillconstantalpha.\n");
2322-
fprintf (fpo, "/.setfillconstantalpha where {pop .setblendmode dup .setstrokeconstantalpha .setfillconstantalpha }{\n"); /* Use the transparency for both fill and stroke */
2321+
GMT_Report(API, GMT_MSG_DEBUG, "Your gs is newer than 9.52 so we must replace .setopacityalpha in old PS files with .setfillconstantalpha.\n");
2322+
fprintf(fpo, "/.setfillconstantalpha where {pop .setblendmode dup .setstrokeconstantalpha .setfillconstantalpha }{\n"); /* Use the transparency for both fill and stroke */
23232323
}
23242324
else
2325-
fprintf (fpo, "%s\n", line);
2325+
fprintf(fpo, "%s\n", line);
23262326

23272327
continue;
23282328
}
@@ -2415,20 +2415,20 @@ EXTERN_MSC int GMT_psconvert (void *V_API, int mode, void *args) {
24152415
continue;
24162416
}
24172417
else if (Ctrl->P.active && landscape && !strncmp (line, "%%Orientation:", 14)) {
2418-
fprintf (fpo, "%%%%Orientation: Portrait\n");
2418+
fprintf(fpo, "%%%%Orientation: Portrait\n");
24192419
landscape = false;
24202420
continue;
24212421
}
2422-
else if (!strncmp (line, "%%BeginSetup", 12))
2422+
else if (!strncmp(line, "%%BeginSetup", 12))
24232423
setup = true;
2424-
else if (!strncmp (line, "%%EndSetup", 10)) {
2424+
else if (!strncmp(line, "%%EndSetup", 10)) {
24252425
setup = false;
24262426
if (Ctrl->T.eps == -1) /* -TE option. Write out setpagedevice command. Note: The -! option cannot be active here. */
2427-
fprintf (fpo, "<< /PageSize [%g %g] >> setpagedevice\n", w, h);
2427+
fprintf(fpo, "<< /PageSize [%g %g] >> setpagedevice\n", w, h);
24282428
if (r != 0)
2429-
fprintf (fpo, "%d rotate\n", r);
2429+
fprintf(fpo, "%d rotate\n", r);
24302430
if (!gmt_M_is_zero (xt) || !gmt_M_is_zero (yt))
2431-
fprintf (fpo, "%g %g translate\n", xt, yt);
2431+
fprintf(fpo, "%g %g translate\n", xt, yt);
24322432
xt = yt = 0.0;
24332433
r = 0;
24342434
}

0 commit comments

Comments
 (0)