[gs-cvs] gs/src

Igor Melichev igor at casper.ghostscript.com
Tue Jul 16 06:33:51 PDT 2002


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

Modified Files:
      Tag: GS_7_0X
	gdevpdfe.c gdevpsf2.c gdevpsf.h 
Log Message:
Fix: (pdfwrite) Enforce writing FontBBox into CFF.
Source Forge bug "[ 578899 ] Missing /FontBBox when converting to ps?"


Index: gdevpdfe.c
===================================================================
RCS file: /cvs/ghostscript/gs/src/gdevpdfe.c,v
retrieving revision 1.10.2.1
retrieving revision 1.10.2.2
diff -u -d -r1.10.2.1 -r1.10.2.2
--- gdevpdfe.c	22 Feb 2002 19:45:56 -0000	1.10.2.1
+++ gdevpdfe.c	16 Jul 2002 13:33:49 -0000	1.10.2.2
@@ -118,7 +118,8 @@
 private int
 pdf_embed_font_as_type2(gx_device_pdf *pdev, gs_font_type1 *font,
 			long FontFile_id, gs_glyph subset_glyphs[256],
-			uint subset_size, const gs_const_string *pfname)
+			uint subset_size, const gs_const_string *pfname,
+			gs_int_rect *FontBBox)
 {
     int code;
     pdf_data_writer_t writer;
@@ -130,7 +131,8 @@
     if (code < 0)
 	return code;
     code = psf_write_type2_font(writer.binary.strm, font, options,
-				subset_glyphs, subset_size, pfname);
+				subset_glyphs, subset_size, pfname,
+				FontBBox);
     pdf_end_fontfile(pdev, &writer);
     return code;
 }
@@ -139,7 +141,8 @@
 private int
 pdf_embed_font_type1(gx_device_pdf *pdev, gs_font_type1 *font,
 		     long FontFile_id, gs_glyph subset_glyphs[256],
-		     uint subset_size, const gs_const_string *pfname)
+		     uint subset_size, const gs_const_string *pfname,
+		     gs_int_rect *FontBBox)
 {
     switch (((const gs_font *)font)->FontType) {
     case ft_encrypted:
@@ -149,7 +152,7 @@
 	/* For PDF 1.2 and later, write Type 1 fonts as Type1C. */
     case ft_encrypted2:
 	return pdf_embed_font_as_type2(pdev, font, FontFile_id,
-				       subset_glyphs, subset_size, pfname);
+			       subset_glyphs, subset_size, pfname, FontBBox);
     default:
 	return_error(gs_error_rangecheck);
     }
@@ -328,7 +331,8 @@
 	    }
 	    code = pdf_embed_font_type1(pdev, (gs_font_type1 *)font,
 					FontFile_id, subset_list,
-					subset_size, &font_name);
+					subset_size, &font_name, 
+					&pfd->values.FontBBox);
 	    break;
 	case ft_TrueType:
 	    if (do_subset) {

Index: gdevpsf2.c
===================================================================
RCS file: /cvs/ghostscript/gs/src/gdevpsf2.c,v
retrieving revision 1.15.2.1
retrieving revision 1.15.2.2
diff -u -d -r1.15.2.1 -r1.15.2.2
--- gdevpsf2.c	22 Feb 2002 19:45:56 -0000	1.15.2.1
+++ gdevpsf2.c	16 Jul 2002 13:33:49 -0000	1.15.2.2
@@ -65,6 +65,7 @@
     long start_pos;
     cff_string_table_t std_strings;
     cff_string_table_t strings;
+    gs_int_rect FontBBox;
 } cff_writer_t;
 typedef struct cff_glyph_subset_s {
     psf_outline_glyphs_t glyphs;
@@ -546,14 +547,20 @@
 	cff_put_string_value(pcw, pinfo->FamilyName.data,
 			     pinfo->FamilyName.size, TOP_FamilyName);
     /* (Weight) */
-    if (pbfont->FontBBox.p.x != 0 || pbfont->FontBBox.p.y != 0 ||
-	pbfont->FontBBox.q.x != 0 || pbfont->FontBBox.q.y != 0
+    if (pcw->FontBBox.p.x != 0 || pcw->FontBBox.p.y != 0 ||
+	pcw->FontBBox.q.x != 0 || pcw->FontBBox.q.y != 0
 	) {
 	/* An omitted FontBBox is equivalent to an empty one. */
-	cff_put_real(pcw, pbfont->FontBBox.p.x);
-	cff_put_real(pcw, pbfont->FontBBox.p.y);
-	cff_put_real(pcw, pbfont->FontBBox.q.x);
-	cff_put_real(pcw, pbfont->FontBBox.q.y);
+	/*
+	 * Since Acrobat Reader 4 on Solaris doesn't like 
+	 * an omitted FontBBox, we copy it here from
+	 * the font descriptor, because the base font
+	 * is allowed to omit it's FontBBox.
+	 */
+	cff_put_real(pcw, pcw->FontBBox.p.x);
+	cff_put_real(pcw, pcw->FontBBox.p.y);
+	cff_put_real(pcw, pcw->FontBBox.q.x);
+	cff_put_real(pcw, pcw->FontBBox.q.y);
 	cff_put_op(pcw, TOP_FontBBox);
     }
     if (uid_is_UniqueID(&pbfont->UID))
@@ -1105,7 +1112,8 @@
 int
 psf_write_type2_font(stream *s, gs_font_type1 *pfont, int options,
 		      gs_glyph *subset_glyphs, uint subset_size,
-		      const gs_const_string *alt_font_name)
+		      const gs_const_string *alt_font_name,
+		      gs_int_rect *FontBBox)
 {
     gs_font_base *const pbfont = (gs_font_base *)pfont;
     cff_writer_t writer;
@@ -1159,6 +1167,7 @@
     writer.glyph_data = psf_type1_glyph_data;
     writer.offset_size = 1;	/* arbitrary */
     writer.start_pos = stell(s);
+    writer.FontBBox = *FontBBox;
 
     /* Initialize the enumeration of the glyphs. */
     psf_enumerate_glyphs_begin(&genum, (gs_font *)pfont,

Index: gdevpsf.h
===================================================================
RCS file: /cvs/ghostscript/gs/src/gdevpsf.h,v
retrieving revision 1.10.2.1
retrieving revision 1.10.2.2
diff -u -d -r1.10.2.1 -r1.10.2.2
--- gdevpsf.h	22 Feb 2002 19:45:56 -0000	1.10.2.1
+++ gdevpsf.h	16 Jul 2002 13:33:49 -0000	1.10.2.2
@@ -192,9 +192,10 @@
 #define WRITE_TYPE2_NO_LENIV 1	/* always use lenIV = -1 */
 #define WRITE_TYPE2_CHARSTRINGS 2 /* convert T1 charstrings to T2 */
 #define WRITE_TYPE2_AR3 4	/* work around bugs in Acrobat Reader 3 */
-int psf_write_type2_font(P6(stream *s, gs_font_type1 *pfont, int options,
+int psf_write_type2_font(P7(stream *s, gs_font_type1 *pfont, int options,
 			    gs_glyph *subset_glyphs, uint subset_size,
-			    const gs_const_string *alt_font_name));
+			    const gs_const_string *alt_font_name,
+			    gs_int_rect *FontBBox));
 
 #ifndef gs_font_cid0_DEFINED
 #  define gs_font_cid0_DEFINED




More information about the gs-cvs mailing list