The patch below fixes some pdfwrite problems for ghostscript and
the LuxiMono fonts in /usr/X11R6/lib/X11/fonts/TTF.

See also http://bugs.ghostscript.com/show_bug.cgi?id=688536

Please test and let me know about any regressions.

Ciao,
        Kili

Index: print/ghostscript/gnu/patches/patch-src_gdevpsft_c
===================================================================
RCS file: print/ghostscript/gnu/patches/patch-src_gdevpsft_c
diff -N print/ghostscript/gnu/patches/patch-src_gdevpsft_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ print/ghostscript/gnu/patches/patch-src_gdevpsft_c  1 Jan 2007 23:20:18 
-0000
@@ -0,0 +1,54 @@
+$OpenBSD$
+
+# Fix for bug 688536. From upstream svn.
+
+--- src/gdevpsft.c.orig        Thu Mar 23 13:39:23 2006
++++ src/gdevpsft.c     Mon Jan  1 19:42:31 2007
+@@ -479,7 +479,8 @@ write_name(stream *s, const gs_const_str
+ /* ------ OS/2 ------ */
+ 
+ /* Write a generated OS/2 table. */
+-#define OS_2_LENGTH sizeof(ttf_OS_2_t)
++#define OS_2_LENGTH1 offset_of(ttf_OS_2_t, sxHeight[0]) /* OS/2 version 1. */
++#define OS_2_LENGTH2 sizeof(ttf_OS_2_t) /* OS/2 version 2. */
+ private void
+ update_OS_2(ttf_OS_2_t *pos2, uint first_glyph, int num_glyphs)
+ {
+@@ -504,15 +505,16 @@ write_OS_2(stream *s, gs_font *font, uin
+      * We don't bother to set most of the fields.  The really important
+      * ones, which affect character mapping, are usFirst/LastCharIndex.
+      * We also need to set usWeightClass and usWidthClass to avoid
+-     * crashing ttfdump.
++     * crashing ttfdump. Version 1 86-byte structure has all the fields
++     * we need.
+      */
+     memset(&os2, 0, sizeof(os2));
+     put_u16(os2.version, 1);
+     put_u16(os2.usWeightClass, 400); /* Normal */
+     put_u16(os2.usWidthClass, 5); /* Normal */
+     update_OS_2(&os2, first_glyph, num_glyphs);
+-    stream_write(s, &os2, sizeof(os2));
+-    put_pad(s, sizeof(os2));
++    stream_write(s, &os2, offset_of(ttf_OS_2_t, sxHeight[0]));
++    put_pad(s, offset_of(ttf_OS_2_t, sxHeight[0]));
+ }
+ 
+ /* ------ post ------ */
+@@ -688,7 +690,7 @@ psf_write_truetype_data(stream *s, gs_fo
+     int have_hvhea[2];
+     uint cmap_length = 0;
+     ulong OS_2_start = 0;
+-    uint OS_2_length = OS_2_LENGTH;
++    uint OS_2_length = OS_2_LENGTH1;
+     int code;
+ 
+     have_hvhea[0] = have_hvhea[1] = 0;
+@@ -755,7 +757,7 @@ psf_write_truetype_data(stream *s, gs_fo
+           if (writing_cid)
+               continue;
+           have_OS_2 = true;
+-          if (length > OS_2_LENGTH)
++          if (length > OS_2_LENGTH2)
+               return_error(gs_error_invalidfont);
+           OS_2_start = start;
+           OS_2_length = length;
Index: print/ghostscript/gnu/patches/patch-src_gxttf_h
===================================================================
RCS file: print/ghostscript/gnu/patches/patch-src_gxttf_h
diff -N print/ghostscript/gnu/patches/patch-src_gxttf_h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ print/ghostscript/gnu/patches/patch-src_gxttf_h     1 Jan 2007 23:20:18 
-0000
@@ -0,0 +1,21 @@
+$OpenBSD$
+
+# Fix for bug 688536. From upstream svn.
+
+--- src/gxttf.h.orig   Mon Mar 13 17:18:19 2006
++++ src/gxttf.h        Mon Jan  1 20:19:11 2007
+@@ -134,7 +134,13 @@ typedef struct ttf_OS_2_s {
+       sTypoLineGap[2],
+       usWinAscent[2],
+       usWinDescent[2],
+-      ulCodePageRanges[8];
++      ulCodePageRanges[8],
++
++        sxHeight[2],            /* version 2 */
++              sCapHeight[2],
++              usDefaultChar[2],
++              usBreakChar[2],
++        usMaxContext[2];
+ } ttf_OS_2_t;
+ 
+ /* ------ vhea ------ */

Reply via email to