[gs-cvs] rev 7063 - trunk/gs/src

leonardo at ghostscript.com leonardo at ghostscript.com
Thu Sep 21 05:36:26 PDT 2006


Author: leonardo
Date: 2006-09-21 05:36:25 -0700 (Thu, 21 Sep 2006)
New Revision: 7063

Modified:
   trunk/gs/src/gdevpdtb.c
   trunk/gs/src/gdevpdtb.h
   trunk/gs/src/gdevpdtd.c
   trunk/gs/src/gdevpdtt.c
   trunk/gs/src/gdevpdtw.c
   trunk/gs/src/gxfcopy.c
   trunk/gs/src/gxfcopy.h
Log:
Fix (pdfwrite) : Wrinting a PDF/A, convert True Type fonts into CIDFontType2 (continued 2).

DETAILS :

This completes the fix the bug 688790  
"pdfwrite : The PDF/A conversion needs to re-encode texts".

Adobe PDF/A preflight tool appears to check whether all glyphs
in the font have corresponding entries in W, W2 or Width array.
This includes unused glyphs and .notdef .
This patch implements creating a W array element for
.notdef when a Type 42 font is being converted into CIDFontType2.

Besides that, before this patch, when converting a Type 42 into
CIDFontType2, the W array was not written at all,
because pdf_write_embedded_font did not know about the conversion.
Adding a new argument to it for passing that information.

EXPECTED DIFFERENCES :

None.


Modified: trunk/gs/src/gdevpdtb.c
===================================================================
--- trunk/gs/src/gdevpdtb.c	2006-09-20 18:26:17 UTC (rev 7062)
+++ trunk/gs/src/gdevpdtb.c	2006-09-21 12:36:25 UTC (rev 7063)
@@ -430,7 +430,7 @@
  * Write an embedded font.
  */
 int
-pdf_write_embedded_font(gx_device_pdf *pdev, pdf_base_font_t *pbfont,
+pdf_write_embedded_font(gx_device_pdf *pdev, pdf_base_font_t *pbfont, font_type FontType,
 			gs_int_rect *FontBBox, gs_id rid, cos_dict_t **ppcd)
 {
     bool do_subset = pdf_do_subset_font(pdev, pbfont, rid);
@@ -477,7 +477,7 @@
     fnstr.data = pbfont->font_name.data;
     fnstr.size = pbfont->font_name.size;
     /* Now write the font (or subset). */
-    switch (out_font->FontType) {
+    switch (FontType) {
 
     case ft_composite:
 	/* Nothing to embed -- the descendant fonts do it all. */

Modified: trunk/gs/src/gdevpdtb.h
===================================================================
--- trunk/gs/src/gdevpdtb.h	2006-09-20 18:26:17 UTC (rev 7062)
+++ trunk/gs/src/gdevpdtb.h	2006-09-21 12:36:25 UTC (rev 7063)
@@ -131,7 +131,7 @@
 /*
  * Write an embedded font, possibly subsetted.
  */
-int pdf_write_embedded_font(gx_device_pdf *pdev, pdf_base_font_t *pbfont,
+int pdf_write_embedded_font(gx_device_pdf *pdev, pdf_base_font_t *pbfont, font_type FontType,
 			gs_int_rect *FontBBox, gs_id rid, cos_dict_t **ppcd);
 
 /*

Modified: trunk/gs/src/gdevpdtd.c
===================================================================
--- trunk/gs/src/gdevpdtd.c	2006-09-20 18:26:17 UTC (rev 7062)
+++ trunk/gs/src/gdevpdtd.c	2006-09-21 12:36:25 UTC (rev 7063)
@@ -559,6 +559,7 @@
 	(code = pdf_compute_font_descriptor(pdev, pfd)) >= 0 &&
 	(!pfd->embed ||
 	 (code = pdf_write_embedded_font(pdev, pfd->base_font, 
+				pfd->FontType,
 				&pfd->common.values.FontBBox, 
 				pfd->common.rid, &pcd)) >= 0)
 	) {

Modified: trunk/gs/src/gdevpdtt.c
===================================================================
--- trunk/gs/src/gdevpdtt.c	2006-09-20 18:26:17 UTC (rev 7062)
+++ trunk/gs/src/gdevpdtt.c	2006-09-21 12:36:25 UTC (rev 7063)
@@ -1202,6 +1202,32 @@
 	pdfont->mark_glyph = font->dir->ccache.mark_glyph;
     }
 
+    if (pdev->PDFA && font->FontType == ft_TrueType) {
+	/* The Adobe preflight tool for PDF/A
+	   checks whether Widht or W include elements
+	   for all characters in the True Type font.
+	   Due to that we need to provide a width
+	   for .notdef glyph.
+	   (It's a part of the bug 688790).
+	 */
+	gs_font_base *cfont = pdf_font_descriptor_font(pfd, false/*any*/);
+	gs_glyph notdef_glyph = copied_get_notdef((const gs_font *)cfont);
+	pdf_glyph_widths_t widths;
+	double cdevproc_result[10] = {0,0,0,0,0, 0,0,0,0,0};
+	double *real_widths, *w, *v, *w0;
+	int char_cache_size, width_cache_size;
+
+	if (notdef_glyph != GS_NO_GLYPH) {
+	    code = pdf_obtain_cidfont_widths_arrays(pdev, pdfont, font->WMode, &w, &w0, &v);
+	    if (code < 0)
+		return code;
+	    widths.Width.w = 0;
+	    code = pdf_glyph_widths(pdfont, font->WMode, notdef_glyph,
+		 font, &widths, cdevproc_result);
+	    w[0] = widths.Width.w;
+	    pdfont->used[0] |= 0x80;
+	}
+    }
     *ppdfont = pdfont;
     return 1;
 }

Modified: trunk/gs/src/gdevpdtw.c
===================================================================
--- trunk/gs/src/gdevpdtw.c	2006-09-20 18:26:17 UTC (rev 7062)
+++ trunk/gs/src/gdevpdtw.c	2006-09-21 12:36:25 UTC (rev 7063)
@@ -343,7 +343,20 @@
 		gs_glyph_info_t info;
 
 		if (pdfont != NULL) {
-		    if (pfont->procs.glyph_info((gs_font *)pfont, glyph, NULL, 0, &info) < 0)
+		    if (pfont->FontType == ft_TrueType) {
+			/* We're converting a Type 42 into CIDFontType2. */
+			/* We know that CIDs equal to char codes. */
+			gs_glyph glyph1;
+			int ch = glyph & 0xff;
+
+			glyph1 = pfont->procs.encode_char((gs_font *)pfont, ch, GLYPH_SPACE_NAME);
+			if (cid == 0 && glyph1 == GS_NO_GLYPH)
+			    glyph1 = copied_get_notdef(pdf_font_resource_font(pdfont, false));
+			if (glyph1 == GS_NO_GLYPH)
+			    continue;
+			if (pfont->procs.glyph_info((gs_font *)pfont, glyph1, NULL, 0, &info) < 0)
+			    continue;
+		    } else if (pfont->procs.glyph_info((gs_font *)pfont, glyph, NULL, 0, &info) < 0)
 			continue;
 		}
 	    }
@@ -356,7 +369,7 @@
 		    pprintd3(s, "\n%d %d %d", width, vx, vy);
 		} else
 		    pprintd1(s, "\n%d", width);
-	    } else if (width == dw && 
+	    } else if (!pdev->PDFA && width == dw && 
 		    (!wmode || (int)(pdfont->u.cidfont.v[cid * 2 + 0] + 0.5) == 
 				(int)(pdfont->Widths[cid] / 2 + 0.5)) &&
 		    (!wmode || (int)(pdfont->u.cidfont.v[cid * 2 + 1] + 0.5) == dv))

Modified: trunk/gs/src/gxfcopy.c
===================================================================
--- trunk/gs/src/gxfcopy.c	2006-09-20 18:26:17 UTC (rev 7062)
+++ trunk/gs/src/gxfcopy.c	2006-09-21 12:36:25 UTC (rev 7063)
@@ -710,9 +710,8 @@
 
     if (glyph == GS_NO_GLYPH) {
 	glyph = font->procs.encode_char(font, chr, GLYPH_SPACE_INDEX);
-	if (glyph == GS_NO_GLYPH) {
+	if (glyph == GS_NO_GLYPH)
 	    glyph = cf_data(font)->notdef;
-	}
     }
     /*
      * Type 1/2 outlines don't require a current point, but TrueType
@@ -2414,3 +2413,12 @@
 	return order_font_data(cfdata, font->memory);
     }
 }
+
+/* Get .nmotdef glyph. */
+gs_glyph
+copied_get_notdef(const gs_font *font)
+{
+    gs_copied_font_data_t * cfdata = cf_data(font);
+
+    return cfdata->notdef;
+}

Modified: trunk/gs/src/gxfcopy.h
===================================================================
--- trunk/gs/src/gxfcopy.h	2006-09-20 18:26:17 UTC (rev 7062)
+++ trunk/gs/src/gxfcopy.h	2006-09-21 12:36:25 UTC (rev 7063)
@@ -174,4 +174,7 @@
 */
 int copied_order_font(gs_font *font);
 
+/* Get .nmotdef glyph. */
+gs_glyph copied_get_notdef(const gs_font *font);
+
 #endif /* gxfcopy_INCLUDED */



More information about the gs-cvs mailing list