[gs-commits] rev 11652 - trunk/gs/base

ken at ghostscript.com ken at ghostscript.com
Tue Aug 24 13:46:30 UTC 2010


Author: ken
Date: 2010-08-24 13:46:29 +0000 (Tue, 24 Aug 2010)
New Revision: 11652

Modified:
   trunk/gs/base/gxfcopy.c
Log:
Enhancement - Font copying (pdfwrite)

Bug #691573 " invalidfont in xshow". The file does in fact contain an invalidfont, the
type 42 embedded fonts are defined by adding /.notdef to the CharStrings dictionary as 
if it were the Encoding array. The key /.notdef is added 256 times with values ranging
from 0 to 255. Of course only the last one is actually defined.

This means that when we come to copy the /.notdef glyph for our font copy, the type 42
GID is 255. However the font does not contain a glyph with GID 255, so the copy of the
font fails.

Although this is an illegal font, Adobe Acrobat Distiller does produce a PDF file from
it. In order to duplicate this, code has been added when copying a font. If we fail to
copy a glyph, and the glyph is /.notdef and the GID is non-zero, we try to copy a glyph
with GID 0 instead. If that fails we error out, otherwise we use the glyph with GID 0.
(TrueType font /.notdef glyph has GID 0)

This works for the supplied file but is not, of course, a guaranteed solution since 
another badly formed font may not contain a glyph with GID 0.

No Expected Differences


Modified: trunk/gs/base/gxfcopy.c
===================================================================
--- trunk/gs/base/gxfcopy.c	2010-08-24 12:33:34 UTC (rev 11651)
+++ trunk/gs/base/gxfcopy.c	2010-08-24 13:46:29 UTC (rev 11652)
@@ -1338,8 +1338,22 @@
 
     gdata.memory = font42->memory;
     code = font42->data.get_outline(font42, gid, &gdata);
+    /* If the glyph is a /.notdef, and the GID is not 0, and we failed to find 
+     * the /.notdef, try again with GID 0. We have seen fonts from GraphPad
+     * Prism which end up putting the /.notdef in the CharStrings dictionary
+     * with the wrong GID value (Bug #691573)
+     */
+    if (code < 0 && gid != 0) {
+	gs_const_string gnstr;
+	if (font->procs.glyph_name(font, glyph, &gnstr) >= 0 && gnstr.size == 7
+	    && !memcmp(gnstr.data, ".notdef", 7)) {
+	    gid = 0;
+	    code = font42->data.get_outline(font42, gid, &gdata);
+	} 
+    }
     if (code < 0)
 	return code;
+
     code = copy_glyph_data(font, gid + GS_MIN_GLYPH_INDEX, copied, options,
 			   &gdata, NULL, 0);
     if (code < 0)



More information about the gs-commits mailing list