[gs-cvs] gs/src

Igor Melichev igor at casper.ghostscript.com
Mon Jul 29 04:47:21 PDT 2002


Update of /cvs/ghostscript/gs/src
In directory casper:/tmp/cvs-serv17407/gs/src

Modified Files:
	gdevpdtw.c 
Log Message:
pdfwrite/pdxtext: (1) Widths were computed wrongly,
(2) standard fonts missed Widths.


Index: gdevpdtw.c
===================================================================
RCS file: /cvs/ghostscript/gs/src/gdevpdtw.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- gdevpdtw.c	9 Jul 2002 14:29:35 -0000	1.5
+++ gdevpdtw.c	29 Jul 2002 11:47:19 -0000	1.6
@@ -48,6 +48,18 @@
     return 0;
 }
 
+/* Check whether a simple font has a replaced glyph width. */
+private bool
+pfd_simple_replaced_width(const pdf_font_resource_t *pdfont)
+{
+    int i;
+
+    for (i = pdfont->u.simple.FirstChar; i <= pdfont->u.simple.LastChar; ++i)
+	if (pdfont->Widths[i] != pdfont->real_widths[i])
+	    return true;
+    return false;
+}
+
 /* Write the Subtype and Encoding for a simple font. */
 private int
 pdf_write_simple_contents(gx_device_pdf *pdev,
@@ -128,7 +140,7 @@
 
 	memset(counts, 0, sizeof(counts));
 	while (!psf_enumerate_glyphs_next(&genum, &glyph)) {
-	    int width = pdfont->Widths[glyph - GS_MIN_CID_GLYPH];
+	    int width = pdfont->real_widths[glyph - GS_MIN_CID_GLYPH];
 
 	    counts[min(width, countof(counts) - 1)]++;
 	}
@@ -150,7 +162,7 @@
 
 	while (!psf_enumerate_glyphs_next(&genum, &glyph)) {
 	    int cid = glyph - GS_MIN_CID_GLYPH;
-	    int width = pdfont->Widths[cid];
+	    int width = pdfont->real_widths[cid];
 
 	    if (cid == prev + 1)
 		pprintd1(s, "\n%d", width);
@@ -204,7 +216,7 @@
     stream *s = pdev->strm;
 
     pdf_write_font_bbox(pdev, &pdfont->u.simple.s.type3.FontBBox);
-    pdf_write_Widths(pdev, 0, pdfont->u.simple.LastChar, pdfont->Widths);
+    pdf_write_Widths(pdev, 0, pdfont->u.simple.LastChar, pdfont->real_widths);
     stream_puts(s, "/Subtype/Type3>>\n");
     pdf_end_separate(pdev);
     return 0;
@@ -214,6 +226,9 @@
 int
 pdf_write_contents_std(gx_device_pdf *pdev, pdf_font_resource_t *pdfont)
 {
+    if (pfd_simple_replaced_width(pdfont))
+	pdf_write_Widths(pdev, pdfont->u.simple.FirstChar, 
+			 pdfont->u.simple.LastChar, pdfont->real_widths);
     return pdf_write_simple_contents(pdev, pdfont);
 }
 
@@ -222,7 +237,7 @@
 pdf_write_contents_simple(gx_device_pdf *pdev, pdf_font_resource_t *pdfont)
 {
     pdf_write_Widths(pdev, pdfont->u.simple.FirstChar,
-		     pdfont->u.simple.LastChar, pdfont->Widths);
+		     pdfont->u.simple.LastChar, pdfont->real_widths);
     return pdf_write_simple_contents(pdev, pdfont);
 }
 




More information about the gs-cvs mailing list