ghostscript/020120720~01dc18e.patch
changeset 26 979f6bd117bc
equal deleted inserted replaced
25:1e6203fa0dde 26:979f6bd117bc
       
     1 From 01dc18e8418fc44a993840f0aeaf741929c1921a Mon Sep 17 00:00:00 2001
       
     2 From: Ken Sharp <ken.sharp@artifex.com>
       
     3 Date: Fri, 20 Jul 2012 10:27:32 +0100
       
     4 Subject: [PATCH] ps2write - Always ascii hex encode the eexec portion of type
       
     5  1 fonts
       
     6 
       
     7 Bug #693197 "ps2write outputs Type 1 fonts in pfb format"
       
     8 
       
     9 Technically it is possible for the eexec portion of a type 1 font to be in
       
    10 binary or ascii hex. Because we always ascii85 encode binary data if the
       
    11 device does not support it, we left eexec portion as binary.
       
    12 
       
    13 However it seems that at least some printers (Kyocera, possibly others) are
       
    14 unable to deal with this.
       
    15 
       
    16 This patch means that we alays use ascii hex data for the eexec encrypted
       
    17 portion of a type 1 font. We did consider making this a command line option
       
    18 but were unable to find any other tools which emitted binary here so opted
       
    19 simply to conform.
       
    20 
       
    21 All the investigation and the original patch (see bug report) by Chris Liddell
       
    22 
       
    23 
       
    24 No differences expected
       
    25 ---
       
    26  base/gdevpdtb.c |   26 +++++++++++++++++++-------
       
    27  base/gdevpsf1.c |    5 ++++-
       
    28  2 files changed, 23 insertions(+), 8 deletions(-)
       
    29 
       
    30 Index: ghostscript-9.05~dfsg/base/gdevpdtb.c
       
    31 ===================================================================
       
    32 --- ghostscript-9.05~dfsg.orig/base/gdevpdtb.c	2013-07-09 13:05:30.000000000 +0200
       
    33 +++ ghostscript-9.05~dfsg/base/gdevpdtb.c	2013-07-09 14:19:38.000000000 +0200
       
    34 @@ -549,17 +549,29 @@
       
    35      pdf_data_writer_t writer;
       
    36      byte digest[6] = {0,0,0,0,0,0};
       
    37      int code;
       
    38 +    int options=0;
       
    39  
       
    40      if (pbfont->written)
       
    41          return 0;		/* already written */
       
    42      code = copied_order_font((gs_font *)out_font);
       
    43      if (code < 0)
       
    44          return code;
       
    45 -    code = pdf_begin_data_stream(pdev, &writer, DATA_STREAM_BINARY |
       
    46 -                            /* Don't set DATA_STREAM_ENCRYPT since we write to a temporary file.
       
    47 -                               See comment in pdf_begin_encrypt. */
       
    48 -                                 (pdev->CompressFonts ?
       
    49 -                                  DATA_STREAM_COMPRESS : 0), 0);
       
    50 +    /* Since we now always ASCIIHex encode the eexec encrypted portion of a
       
    51 +     * Type 1 font, such a font cannot contain any binary data, if its not being
       
    52 +     * compressed then there is no reason to ASCII encode it (which will happen
       
    53 +     * we set DATA_STREAM_BINARY and the device does not permit binary output)
       
    54 +     * NB if HaveCFF is true then we convert type 1 to CFF which is a binary
       
    55 +     * format, so we still need to set DATA_STREAM_BINARY.
       
    56 +     */
       
    57 +    if (pdev->CompressFonts)
       
    58 +        options = DATA_STREAM_BINARY | DATA_STREAM_COMPRESS;
       
    59 +    else
       
    60 +         if (FontType != ft_encrypted || pdev->HaveCFF)
       
    61 +            options = DATA_STREAM_BINARY;
       
    62 +    /* Don't set DATA_STREAM_ENCRYPT since we write to a temporary file.
       
    63 +     * See comment in pdf_begin_encrypt.
       
    64 +     */
       
    65 +    code = pdf_begin_data_stream(pdev, &writer, options, 0);
       
    66      if (code < 0)
       
    67          return code;
       
    68      if (pdev->PDFA) {
       
    69 @@ -610,8 +622,8 @@
       
    70  
       
    71              code = psf_write_type1_font(writer.binary.strm,
       
    72                                  (gs_font_type1 *)out_font,
       
    73 -                                WRITE_TYPE1_WITH_LENIV |
       
    74 -                                    WRITE_TYPE1_EEXEC | WRITE_TYPE1_EEXEC_PAD,
       
    75 +                                WRITE_TYPE1_WITH_LENIV | WRITE_TYPE1_EEXEC |
       
    76 +                                WRITE_TYPE1_EEXEC_PAD | WRITE_TYPE1_ASCIIHEX,
       
    77                                  NULL, 0, &fnstr, lengths);
       
    78              if (lengths[0] > 0) {
       
    79                  if (code < 0)
       
    80 Index: ghostscript-9.05~dfsg/base/gdevpsf1.c
       
    81 ===================================================================
       
    82 --- ghostscript-9.05~dfsg.orig/base/gdevpsf1.c	2013-07-09 13:05:30.000000000 +0200
       
    83 +++ ghostscript-9.05~dfsg/base/gdevpsf1.c	2013-07-09 14:19:38.000000000 +0200
       
    84 @@ -857,9 +857,12 @@
       
    85          if (options & WRITE_TYPE1_ASCIIHEX) {
       
    86              s_init(&AXE_stream, s->memory);
       
    87              s_init_state((stream_state *)&AXE_state, &s_AXE_template, NULL);
       
    88 -            AXE_state.EndOfData = false;
       
    89              s_init_filter(&AXE_stream, (stream_state *)&AXE_state,
       
    90                            AXE_buf, sizeof(AXE_buf), es);
       
    91 +            /* We have to set this after s_init_filter() as that function
       
    92 +             * sets it to true.
       
    93 +             */
       
    94 +            AXE_state.EndOfData = false;
       
    95              es = &AXE_stream;
       
    96          }
       
    97          s_init(&exE_stream, s->memory);