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

ken at ghostscript.com ken at ghostscript.com
Fri Oct 8 12:01:25 UTC 2010

Author: ken
Date: 2010-10-08 12:01:24 +0000 (Fri, 08 Oct 2010)
New Revision: 11774

Fix (pdfwrite) : Check encoding compatibility when finding base fonts

Bug #691656 "crash in Chinese font: /typecheck in --.FAPIBuildGlyph--"

A typecheck error is not a crash of course, but when using the built in font interpreter
this did not produce an error, silently discarded the text instead. This was still

The problem is caused when dealing with type 0 fonts and producing multiple type 1 fonts
to handle the large number of glyphs. The code for finding an existing font (in order
to minimise the number of new fonts) or create a new font, did not consider the 
encoding of an existing font when trying to match it (this did work for regular fonts).

This could lead to a font with an incompatible encoding being used, which caused an
error later in text processing where a routine is supposed to be guaranteed no font
encoding problems. That led to an attempted fallback to the 'bitmapped type 3 font'
solution, but the text processing was passing ridiculous values to the font interpreter.

In the old font code this caused a silent discard of the text, with the FreeType code 
it produces an error.

Fixed by checking the base font we find to see if its encoding is compatible with the 
current text encoding, and manufacturing a new font if it is not.

No differences expected.

Modified: trunk/gs/base/gdevpdtt.c
--- trunk/gs/base/gdevpdtt.c	2010-10-08 05:09:27 UTC (rev 11773)
+++ trunk/gs/base/gdevpdtt.c	2010-10-08 12:01:24 UTC (rev 11774)
@@ -1745,13 +1745,13 @@
 	code = pdf_attached_font_resource(pdev, base_font, ppdfont, NULL, NULL, NULL, NULL);
 	if (code < 0)
 	    return code;
-	if (*ppdfont != NULL && base_font != font) {
+	if (base_font != font) {
 	    if (pdfont_not_allowed == *ppdfont)
 		*ppdfont = NULL;	
-	    else if(!pdf_is_compatible_encoding(pdev, *ppdfont, 
+	}
+	if(*ppdfont != NULL && !pdf_is_compatible_encoding(pdev, *ppdfont, 
 				    base_font, cgp->s, cgp->num_all_chars))
 		*ppdfont = NULL;
-	}
 	if (*ppdfont == NULL || *ppdfont == pdfont_not_allowed) {
 	    pdf_resource_type_t type = 
 		(pdf_is_CID_font(base_font) ? resourceCIDFont 

More information about the gs-commits mailing list