[gs-cvs] rev 9329 - trunk/gs/base

ken at ghostscript.com ken at ghostscript.com
Tue Jan 6 06:38:01 PST 2009


Author: ken
Date: 2009-01-06 06:38:01 -0800 (Tue, 06 Jan 2009)
New Revision: 9329

Modified:
   trunk/gs/base/gdevpdtc.c
Log:
Fix (pdfwrite): Missing glyphs in CIDFont causing errors.

Details:
Bug #690139: "Regression: Error writing PDF file: Missing glyph CID=0 in Bug689614.pdf".

When we find that a string in a PDF file uses a glyph which is not present in the current CIDFont we substitute the .notdef glyph (CID=0). However, if we do not have a width for the .notdef (this is the first missing glyph) we proceed to get one, and then attempt to run the CDevProc for the font.

This, unfortunately, attempts to use the original (missing) glyph, and so fails with a rangecheck error. Added a check to catch this condition and skip the CDevProc and caching.

Also improved the error message slightly.

EXPECTED DIFFERENCES:
Bug689614.pdf
singular_ctm_empty_fontbbox.pdf


Modified: trunk/gs/base/gdevpdtc.c
===================================================================
--- trunk/gs/base/gdevpdtc.c	2009-01-06 14:11:30 UTC (rev 9328)
+++ trunk/gs/base/gdevpdtc.c	2009-01-06 14:38:01 UTC (rev 9329)
@@ -482,6 +482,7 @@
 		    code += 0; /* A good place for a breakpoint. */
 		} else {
 		    pdf_font_resource_t *pdfont;
+		    bool notdef_subst = false;
 
 		    code = pdf_obtain_cidfont_widths_arrays(pdev, pdsubf, wmode, &w, &w0, &v);
 		    if (code < 0)
@@ -520,14 +521,22 @@
     
 			    memcpy(buf, subfont->font_name.chars, l);
 			    buf[l] = 0;
-			    eprintf2("Missing glyph CID=%d in the font %s . The output PDF may fail with some viewers.\n", 
-				    (int)cid, buf);
+			    eprintf3("Missing glyph CID=%d, glyph=%04x in the font %s . The output PDF may fail with some viewers.\n", 
+				    (int)cid, glyph - GS_MIN_CID_GLYPH, buf);
 			    pdsubf->used[cid >> 3] |= 0x80 >> (cid & 7);
 			}
 			cid = 0, code = 1;  /* undefined glyph. */
+			notdef_subst = true;
+			/* If this is the first use of CID=0, get its width */
+			if (pdsubf->Widths[cid] == 0) {
+			    pdf_glyph_widths_t widths;
+
+			    code = pdf_glyph_widths(pdsubf, wmode, glyph, (gs_font *)subfont, &widths,
+				pte->cdevproc_callout ? pte->cdevproc_result : NULL);
+			}
 		    } else if (code < 0)
 			return code;
-		    if (code == 0 /* just copied */ || pdsubf->Widths[cid] == 0) {
+		    if ((code == 0 /* just copied */ || pdsubf->Widths[cid] == 0) && !notdef_subst) {
 			pdf_glyph_widths_t widths;
 
 		    code = pdf_glyph_widths(pdsubf, wmode, glyph, (gs_font *)subfont, &widths,



More information about the gs-cvs mailing list