[gs-cvs] rev 8360 - trunk/gs/src
ken at ghostscript.com
ken at ghostscript.com
Tue Nov 13 02:01:55 PST 2007
Author: ken
Date: 2007-11-13 02:01:55 -0800 (Tue, 13 Nov 2007)
New Revision: 8360
Modified:
trunk/gs/src/gdevpdfu.c
trunk/gs/src/gdevpdfx.h
trunk/gs/src/gdevpdtf.h
trunk/gs/src/gdevpdtt.c
trunk/gs/src/gdevpdtw.c
Log:
Fix (pdfwrite): type 3 fonts with exceedingly small BoundingBox
entries were clamped to 0 or 1.
Details:
Bug #689537 "FontBBox wrong in pdf generated by ps2pdf (breaks
acrobat 8)".
The type 3 font has a FontBBox of [0 0 0.3 0.3]. Because
pdfwrite uses integers to record the font bounding box, this was
being clampled to [0 0 1 1]. This should not cause a prolem, but
for unknown reasons causes Acrobat 8 to render *very* slowly.
(gdevpdtf.h), 'struct /*type 3*/', alter the FontBBox member from
a gs_int_rect to a gs_rect to preserve floating point box values.
(gdevpdtt.c), pdf_make_font3_resource, copy the font bbox values
instead of floor'ing the lower and ceil'ing the upper values.
(gdevpdfu.c), create a new function 'pdf_write_font_bbox_float'
to write the bbox as floats instead of ints.
(gdevpdfx.h) prototype 'pdf_write_font_bbox_float'
(gdevpdtw.c), pdf_finish_write_contents_type3, use the new
routine to write out a floating point bounding box.
EXPECTED DIFFERENCES:
None.
Modified: trunk/gs/src/gdevpdfu.c
===================================================================
--- trunk/gs/src/gdevpdfu.c 2007-11-12 08:59:35 UTC (rev 8359)
+++ trunk/gs/src/gdevpdfu.c 2007-11-13 10:01:55 UTC (rev 8360)
@@ -2054,3 +2054,22 @@
pbox->p.x, pbox->p.y, x, y);
return 0;
}
+
+/* Write a FontBBox dictionary element using floats for the values. */
+int
+pdf_write_font_bbox_float(gx_device_pdf *pdev, const gs_rect *pbox)
+{
+ stream *s = pdev->strm;
+ /*
+ * AR 4 doesn't like fonts with empty FontBBox, which
+ * happens when the font contains only space characters.
+ * Small bbox causes AR 4 to display a hairline. So we use
+ * the full BBox.
+ */
+ float x = pbox->q.x + ((pbox->p.x == pbox->q.x) ? 1000 : 0);
+ float y = pbox->q.y + ((pbox->p.y == pbox->q.y) ? 1000 : 0);
+
+ pprintg4(s, "/FontBBox[%f %f %f %f]",
+ pbox->p.x, pbox->p.y, x, y);
+ return 0;
+}
Modified: trunk/gs/src/gdevpdfx.h
===================================================================
--- trunk/gs/src/gdevpdfx.h 2007-11-12 08:59:35 UTC (rev 8359)
+++ trunk/gs/src/gdevpdfx.h 2007-11-13 10:01:55 UTC (rev 8360)
@@ -1069,6 +1069,7 @@
/* Write a FontBBox dictionary element. */
int pdf_write_font_bbox(gx_device_pdf *pdev, const gs_int_rect *pbox);
+int pdf_write_font_bbox_float(gx_device_pdf *pdev, const gs_rect *pbox);
/* ---------------- Exported by gdevpdfm.c ---------------- */
Modified: trunk/gs/src/gdevpdtf.h
===================================================================
--- trunk/gs/src/gdevpdtf.h 2007-11-12 08:59:35 UTC (rev 8359)
+++ trunk/gs/src/gdevpdtf.h 2007-11-13 10:01:55 UTC (rev 8360)
@@ -285,7 +285,7 @@
} truetype;
struct /*type3*/ {
- gs_int_rect FontBBox;
+ gs_rect FontBBox;
gs_matrix FontMatrix;
pdf_char_proc_ownership_t *char_procs;
int max_y_offset;
Modified: trunk/gs/src/gdevpdtt.c
===================================================================
--- trunk/gs/src/gdevpdtt.c 2007-11-12 08:59:35 UTC (rev 8359)
+++ trunk/gs/src/gdevpdtt.c 2007-11-13 10:01:55 UTC (rev 8360)
@@ -1029,10 +1029,10 @@
bfont->nearest_encoding_index, true);
pdfont->u.simple.s.type3.char_procs = NULL;
pdfont->u.simple.s.type3.cached = cached;
- pdfont->u.simple.s.type3.FontBBox.p.x = (int)floor(bfont->FontBBox.p.x);
- pdfont->u.simple.s.type3.FontBBox.p.y = (int)floor(bfont->FontBBox.p.y);
- pdfont->u.simple.s.type3.FontBBox.q.x = (int)ceil(bfont->FontBBox.q.x);
- pdfont->u.simple.s.type3.FontBBox.q.y = (int)ceil(bfont->FontBBox.q.y);
+ pdfont->u.simple.s.type3.FontBBox.p.x = bfont->FontBBox.p.x;
+ pdfont->u.simple.s.type3.FontBBox.p.y = bfont->FontBBox.p.y;
+ pdfont->u.simple.s.type3.FontBBox.q.x = bfont->FontBBox.q.x;
+ pdfont->u.simple.s.type3.FontBBox.q.y = bfont->FontBBox.q.y;
pdfont->u.simple.s.type3.FontMatrix = bfont->FontMatrix;
pdfont->u.simple.s.type3.Resources = cos_dict_alloc(pdev, "pdf_make_font3_resource");
if (pdfont->u.simple.s.type3.Resources == NULL)
Modified: trunk/gs/src/gdevpdtw.c
===================================================================
--- trunk/gs/src/gdevpdtw.c 2007-11-12 08:59:35 UTC (rev 8359)
+++ trunk/gs/src/gdevpdtw.c 2007-11-13 10:01:55 UTC (rev 8360)
@@ -430,7 +430,7 @@
{
stream *s = pdev->strm;
- pdf_write_font_bbox(pdev, &pdfont->u.simple.s.type3.FontBBox);
+ pdf_write_font_bbox_float(pdev, &pdfont->u.simple.s.type3.FontBBox);
pdf_write_Widths(pdev, pdfont->u.simple.FirstChar,
pdfont->u.simple.LastChar, pdfont->Widths);
stream_puts(s, "/Subtype/Type3>>\n");
More information about the gs-cvs
mailing list