[gs-cvs] rev 8272 - trunk/gs/src
ken at ghostscript.com
ken at ghostscript.com
Mon Oct 8 00:13:32 PDT 2007
Author: ken
Date: 2007-10-08 00:13:32 -0700 (Mon, 08 Oct 2007)
New Revision: 8272
Modified:
trunk/gs/src/gdevpdtt.c
Log:
pdfwrite: when encountering a glyph in a type 3 font for which no Charproc is defined
emit a simple setcachedevice operation instead of an empty stream.
DETAILS:
Bug #688834 "Undefined characters in Type 3 fonts cause PDF conversion to fail"
The original report, based on an older version of pdfwrite, states that an error occurs with
pdfwrite when using glyphs from a type 3 font where there is no charproc defined for the
glyphs.
In fact, with the current version of pdfwrite, no error occurs, but the resulting file
causes Acrobat to give warnings and display the result incorrectly. NB other PDF consumers
do not behave this way.
This appears to be caused by pdfwrite emitting an empty stream (length 0), because no charproc
is captured for the glyph (since it has none). For some reason Acrobat takes exception to this.
A simple solution is to write a stream which is not empty. The sequence '0 0 0 0 0 0 d1'
, a
setcachedevice with arguments all 0, resolves the problem.
(gdevpdtt.c) In pdf_text_process, after capturing a Charproc for a type 3 font, check the length
of the stream. If it is 0 bytes, then emit '0 0 0 0 0 0 d1' and carry on.
EXPECTED DIFFERENCES:
None.
Modified: trunk/gs/src/gdevpdtt.c
===================================================================
--- trunk/gs/src/gdevpdtt.c 2007-10-07 18:09:11 UTC (rev 8271)
+++ trunk/gs/src/gdevpdtt.c 2007-10-08 07:13:32 UTC (rev 8272)
@@ -2385,7 +2385,7 @@
gs_glyph glyphs[BUF_SIZE / sizeof(gs_glyph)];
} buf;
- if (!penum->pte_default && !penum->charproc_accum) {
+ if (!penum->pte_default && !penum->charproc_accum) {
/* Don't need to sync before exiting charproc. */
code = pdf_prepare_text_drawing(pdev, pte);
if (code == gs_error_rangecheck) {
@@ -2417,6 +2417,27 @@
code = pdf_choose_output_glyph_hame(pdev, penum, &gnstr, pte_default->returned.current_glyph);
if (code < 0)
return code;
+
+ if ((penum->current_font->FontType == ft_user_defined) && stell(pdev->strm) == 0)
+ {
+ char glyph[256], FontName[gs_font_name_max + 1], KeyName[256];
+ int len;
+
+ len = min(gs_font_name_max, gnstr.size);
+ memcpy(glyph, gnstr.data, len);
+ glyph[len] = 0x00;
+ len = min(255, penum->current_font->font_name.size);
+ memcpy(FontName, penum->current_font->font_name.chars, len);
+ FontName[len] = 0x00;
+ len = min(255, penum->current_font->key_name.size);
+ memcpy(KeyName, penum->current_font->key_name.chars, len);
+ KeyName[len] = 0x00;
+
+ eprintf4("ERROR: Page %d used undefined glyph '%s' from type 3 font '%s', key '%s'\n",
+ pdev->next_page, glyph, FontName, KeyName);
+ stream_puts(pdev->strm, "0 0 0 0 0 0 d1\n");
+ }
+
code = pdf_end_charproc_accum(pdev, penum->current_font, penum->cgp,
pte_default->returned.current_glyph, penum->output_char_code, &gnstr);
if (code < 0)
More information about the gs-cvs
mailing list