summaryrefslogtreecommitdiff
path: root/devices
diff options
context:
space:
mode:
authorKen Sharp <ken.sharp@artifex.com>2023-02-20 16:57:50 +0000
committerKen Sharp <ken.sharp@artifex.com>2023-02-20 16:57:50 +0000
commitb0d49f3010f5759ad65f8aa2977ad174d5508376 (patch)
treee11b6eaad73f0349ffaa6ec2b28a1fa6c3e11830 /devices
parentec328c793bf5b703910a27a447bbd4dc4b577a15 (diff)
downloadghostpdl-b0d49f3010f5759ad65f8aa2977ad174d5508376.tar.gz
ps2write - fix emission of stroke adjust in type 3 fonts
No bug, but the specimen file /tests_private/comparefiles/bug688967.ps This turned up in weekly testing. The file output by ps2write was producing errors. This (eventually) turned out to be because a type 3 font contained a CharProc which was using an ExtGState Resource which was not in the /Resources dictionary of the Font. Why this happens is not entirely clear to me, it doesn't with pdfwrite. What seems to be happening is that we are only capturing the Resources required for the font when we run the BuildChar. In this case we have multiple instances of type 3 fonts which are using the same BuildChar but only the first apparently has the full set of Resources. Since we don't need to write stroke adjustment as an ExtGState for PostScript, and PDF output seems to work correctly, just do it differently for PostScript output and write the stroke adjustment directly. This is a fix for commit 95db9c543abdeb391d852aad7f0c5c419f808069 which I hadn't realised seems to have actually added the ability to write out stroke adjustment at all.
Diffstat (limited to 'devices')
-rw-r--r--devices/vector/gdevpdfg.c33
1 files changed, 26 insertions, 7 deletions
diff --git a/devices/vector/gdevpdfg.c b/devices/vector/gdevpdfg.c
index 73f78dd18..71b9b8bcb 100644
--- a/devices/vector/gdevpdfg.c
+++ b/devices/vector/gdevpdfg.c
@@ -3276,13 +3276,32 @@ pdf_try_prepare_stroke(gx_device_pdf *pdev, const gs_gstate *pgs, bool for_text)
pdev->fill_overprint = pgs->stroke_overprint;
}
if (pdev->state.stroke_adjust != pgs->stroke_adjust) {
- code = pdf_open_gstate(pdev, &pres);
- if (code < 0)
- return code;
- code = cos_dict_put_c_key_bool(resource_dict(pres), "/SA", pgs->stroke_adjust);
- if (code < 0)
- return code;
- pdev->state.stroke_adjust = pgs->stroke_adjust;
+ /* Frankly this is awfully hacky. There is a problem with ps2write and type 3 fonts, for
+ * reasons best known to itself it does not seem to collect all the /Resources required
+ * for CharProcs when we meddle with the stroke adjustment. This 'seems' to be because it
+ * only collects them when it runs the BuildChar, if we use the existing CharProc in a
+ * different font then it can miss the Resources needed for the ExtGState.
+ * This does not happen with pdfwrite!
+ * Since ps2write doesn't require us to store teh staroke adjustment in an ExtGState
+ * anyway, just emit it directly.
+ * File exhibiting this is tests_private/comparefiles/Bug688967.ps
+ */
+ if (!pdev->ForOPDFRead) {
+ code = pdf_open_gstate(pdev, &pres);
+ if (code < 0)
+ return code;
+ code = cos_dict_put_c_key_bool(resource_dict(pres), "/SA", pgs->stroke_adjust);
+ if (code < 0)
+ return code;
+ pdev->state.stroke_adjust = pgs->stroke_adjust;
+ } else {
+ if (pgs->stroke_adjust)
+ stream_puts(gdev_vector_stream((gx_device_vector *)pdev), "true setstrokeadjust\n");
+ else
+ stream_puts(gdev_vector_stream((gx_device_vector *)pdev), "false setstrokeadjust\n");
+ pdev->state.stroke_adjust = pgs->stroke_adjust;
+ }
+
}
return pdf_end_gstate(pdev, pres);
}