[gs-cvs] rev 8703 - branches/mtrender/lib

giles at ghostscript.com giles at ghostscript.com
Mon May 5 11:27:08 PDT 2008


Author: giles
Date: 2008-05-05 11:27:06 -0700 (Mon, 05 May 2008)
New Revision: 8703

Modified:
   branches/mtrender/lib/gs_cff.ps
   branches/mtrender/lib/gs_init.ps
   branches/mtrender/lib/gs_ttf.ps
   branches/mtrender/lib/opdfread.ps
   branches/mtrender/lib/pdf_base.ps
   branches/mtrender/lib/pdf_draw.ps
   branches/mtrender/lib/pdf_font.ps
   branches/mtrender/lib/pdf_main.ps
   branches/mtrender/lib/pdf_ops.ps
   branches/mtrender/lib/pdfopt.ps
   branches/mtrender/lib/pdfwrite.ps
   branches/mtrender/lib/pf2afm.ps
Log:
Merge changes in lib from trunk from r8564 (8.62 release) 
to r8702 (current HEAD).


Modified: branches/mtrender/lib/gs_cff.ps
===================================================================
--- branches/mtrender/lib/gs_cff.ps	2008-05-05 18:14:58 UTC (rev 8702)
+++ branches/mtrender/lib/gs_cff.ps	2008-05-05 18:27:06 UTC (rev 8703)
@@ -41,8 +41,8 @@
 		% If this is a font at all, it's an OpenType CFF font set.
     .init_otto_font_file
 	% Use a random FontSet resource name.  ****** WRONG ******
-    realtime rand xor =string cvs exch false
-    ReadData
+    realtime rand xor =string cvs exch //false //false
+    ReadData pop
   } {
 		% Not a TrueType font.
     .loadnonottofontfile
@@ -394,8 +394,8 @@
     /CIDCount 8720 def % Default value defined in CFF spec.
     3 dict begin
     /Supplement pxdef
-    idstring /Ordering pxdef
-    idstring /Registry pxdef
+    idstring dup type /nametype eq { .namestring } if /Ordering pxdef
+    idstring dup type /nametype eq { .namestring } if /Registry pxdef
     /CIDSystemInfo currentdict end def
   }
   63 { /CIDFontVersion pxdef }
@@ -563,9 +563,21 @@
 
 /readPrivate {		% <font> <size> readPrivate -
   2 dict begin
-  /PrivateStart pos def
-  f 3 1 roll exch 1 index f exch subfilefilter /f exch store
-  dup /FontType get exch
+  f 3 1 roll exch       % f <size> <font> 
+  StringCache queued_offset known {
+    /PrivateStart queued_offset def
+  } {
+    /PrivateStart pos def
+    1 index 0 gt {
+      f 2 index string readstring pop
+    } {
+      ()
+    } ifelse
+    StringCache queued_offset 2 index put
+    0 () /SubFileDecode filter
+    /f exch store
+  } ifelse
+  dup /FontType .knownget not { 2 } if exch
   /Private get begin
 		% Default lenIV to -1 even for Type 1 CharStrings.
   2 ne { /lenIV -1 def } if
@@ -651,24 +663,62 @@
   currentdict /FDSelect undef
   cleanupFont
 } bind def
+
+% PDF may load OpenType font containing ordinary CFF data as a CIDFont.
+% Convert the ordinary font to a CIDFont.
+/makeCIDFont {        % (currentdict) finishCIDFont -
+  /CIDFontType 0 def
+  /FDBytes 0 def
+  /GDBytes 0 def
+  /CIDMapOffset 0 def
+
+  /CIDSystemInfo 3 dict begin  % bogus
+    /Registry   (Adobe) def
+    /Ordering   (Identity) def
+    /Supplement 0 def
+  currentdict end def
+
+  /FDArray 4 dict begin
+    /FontMatrix dup load { 1000 0 0 1000 0 0 } matrix concatmatrix def
+    /Private    dup load def
+    /FontType   dup load def
+    /PaintType  dup load def
+  currentdict end 1 array astore def
+
+  /FontType 9 def
+
+  /GlyphDirectory CharStringArray def
+  /CIDCount GlyphDirectory length def
+
+  Private /GlobalSubrs undef
+  currentdict /Encoding undef
+  currentdict /CharStrings undef
+  currentdict /UniqueID undef
+  currentdict /XUID undef
+  cleanupFont
+} bind def
+
 % We need to pass the file as a parameter for the sake of the PDF
 % interpreter. Also for the sake of PDF, a flag forces the font
 % to be defined as <resname> instead of the name embedded in the data.
 % This is needed for subsetted fonts; it is valid if the CFF
 % contains only a single font.
+% Finally, PDF interpreter may request creation of CIDFont out of an
+% ordinary CFF font.
 /StartData {          % <resname> <nbytes> StartData -
-  currentfile exch subfilefilter false ReadData
+  currentfile exch subfilefilter //false //false ReadData pop
 } bind def
-/ReadData {           % <resname> <file> <forceresname> ReadData -
-
+/ReadData {           % <resname> <file> <forceresname> <forcecid> ReadData <fontset>
 	% Initialize.
 
   30 dict begin
+  /forcecidfont exch def
   /forceresname exch def
   /cff exch def
   /pos 0 def
   /resname exch cvlit def
   /DEBUG CFFDEBUG def	% bring the binding closer
+  /StringCache 1 dict def % Private DICT may be reused.
 
 	% Read the header.
 
@@ -722,9 +772,14 @@
     CFFDEBUG { (offsets: ) print [ offsets { pop } forall ] == } if
     [ offsets { pop } forall ] { lt } .sort	% process in order of appearance
     { 
-      /f cff def
       CFFDEBUG { (queued offset: ) print dup =print flush (, current pos=) print pos = } if
-      dup pos ne { dup pos sub nextstring pop } if	% negative advance will cause error
+      /queued_offset 1 index def
+      StringCache 1 index .knownget {
+        /f exch 0 () /SubFileDecode filter def
+      } {
+        /f cff def
+        dup pos ne { dup pos sub nextstring pop } if	% negative advance will cause error
+      } ifelse
       offsets exch 2 copy get 3 1 roll undef
       CFFDEBUG { (exec queued: ) print dup == } if
       exec
@@ -741,7 +796,11 @@
 
   fonts {
     begin
-    currentdict /CIDFontType known { finishCIDFont } { finishFont } ifelse
+    currentdict /CIDFontType known {
+      finishCIDFont
+    } {
+      forcecidfont //makeCIDFont //finishFont ifelse
+    } ifelse
     end
   } forall
 
@@ -765,7 +824,7 @@
   } for .dicttomark
   end		% temporary dict
   end		% FontSetInit ProcSet
-  /FontSet defineresource pop
+  /FontSet defineresource
 
 } bind def
 

Modified: branches/mtrender/lib/gs_init.ps
===================================================================
--- branches/mtrender/lib/gs_init.ps	2008-05-05 18:14:58 UTC (rev 8702)
+++ branches/mtrender/lib/gs_init.ps	2008-05-05 18:27:06 UTC (rev 8703)
@@ -30,7 +30,7 @@
 % Interpreter library version number
 % NOTE: the interpreter code requires that the first non-comment token
 % in this file be an integer, and that it match the compiled-in version!
-862
+863
 
 % Check the interpreter revision.
 dup revision ne
@@ -185,6 +185,7 @@
 currentdict /STRICT known   /STRICT exch def
 currentdict /TTYPAUSE known   /TTYPAUSE exch def
 currentdict /WRITESYSTEMDICT known   /WRITESYSTEMDICT exch def
+currentdict /RENDERTTNOTDEF known /RENDERTTNOTDEF exch def
 
 % Acquire environment variables.
 currentdict /DEVICE known not

Modified: branches/mtrender/lib/gs_ttf.ps
===================================================================
--- branches/mtrender/lib/gs_ttf.ps	2008-05-05 18:14:58 UTC (rev 8702)
+++ branches/mtrender/lib/gs_ttf.ps	2008-05-05 18:27:06 UTC (rev 8703)
@@ -1502,7 +1502,13 @@
   /Encoding [
       have_post {
         cmapa dup length 256 gt { 0 256 getinterval } if
-        { glyphencoding exch get } forall
+        { glyphencoding dup length
+          2 index le {
+            pop pop /.notdef
+          } {
+            exch get
+          } ifelse
+        } forall
       } {
         glyphencoding  dup length 256 gt { 0 256 getinterval } if
         aload pop

Modified: branches/mtrender/lib/opdfread.ps
===================================================================
--- branches/mtrender/lib/opdfread.ps	2008-05-05 18:14:58 UTC (rev 8702)
+++ branches/mtrender/lib/opdfread.ps	2008-05-05 18:27:06 UTC (rev 8703)
@@ -269,7 +269,7 @@
 /InitialExtGState 20 dict begin
   /BG2 currentblackgeneration cp2g def
   /UCR2 currentundercolorremoval cp2g def
-  /TR2 [ currentcolortransfer ] cp2g def
+  /TR2 currentglobal false setglobal [ currentcolortransfer ] exch setglobal cp2g def
   /HT currenthalftone cp2g def
 currentdict end readonly def
 

Modified: branches/mtrender/lib/pdf_base.ps
===================================================================
--- branches/mtrender/lib/pdf_base.ps	2008-05-05 18:14:58 UTC (rev 8702)
+++ branches/mtrender/lib/pdf_base.ps	2008-05-05 18:27:06 UTC (rev 8703)
@@ -550,6 +550,10 @@
 /resolveobjstreamopdict mark
   valueopdict { } forall
   (%%EOF) cvn { exit } bind
+  /endobj {  % bug 689795
+    (   **** Warning: Objects in an object stream should not have 'endobj'.\n)
+    pdfformaterror
+  } bind
 .dicttomark readonly def
 
 % Note: This version of this function is not currently being used.

Modified: branches/mtrender/lib/pdf_draw.ps
===================================================================
--- branches/mtrender/lib/pdf_draw.ps	2008-05-05 18:14:58 UTC (rev 8702)
+++ branches/mtrender/lib/pdf_draw.ps	2008-05-05 18:27:06 UTC (rev 8703)
@@ -394,7 +394,7 @@
       dup /Background exch 4 2 roll
       gsave
         1 index /G oget /Group oget /CS knownoget {
-	  csresolve dup setgcolorspace csput
+	  resolvecolorspace dup setgcolorspace csput
 	} if
         aload pop setcolor [ currentgray ]
       grestore
@@ -417,7 +417,7 @@
   PDFfile fileposition 4 1 roll
 	% We have to select the group's color space so that the
 	% background color will be interpreted correctly.
-  dup /Group oget /CS knownoget { csresolve dup setgcolorspace csput } if
+  dup /Group oget /CS knownoget { resolvecolorspace dup setgcolorspace csput } if
   exch dup /BBox get aload pop .begintransparencymaskgroup {
     dup /Resources knownoget { oforce } { 0 dict } ifelse
     exch false resolvestream
@@ -441,7 +441,7 @@
 
 /.beginformgroup {	% groupdict bbox .beginformgroup -
   exch mark exch			% bbox mark groupdict
-  dup /CS knownoget { csresolve setgcolorspace } if
+  dup /CS knownoget { resolvecolorspace setgcolorspace } if
   dup /I knownoget { /Isolated exch 3 2 roll } if
   dup /K knownoget { /Knockout exch 3 2 roll } if
   pop .dicttomark
@@ -740,9 +740,13 @@
   q
   //null sc1 //null SC1
 
-  % save old value of pdfemptycount on opstack, set to new value
-  pdfemptycount /pdfemptycount count 3 sub def 3 1 roll
-  countdictstack 3 1 roll
+  % Save old values on opstack, set pdfemptycount to new value.
+  pdfemptycount countdictstack
+  /pdfemptycount count 3 sub def 4 2 roll
+  %
+  % Stack: ... <old emptycount> <dictcount> <patdict> <resdict> 
+  %                                            |
+  %           New empty count points here -----+
 
   exch //false resolvestream pdfopdict .pdfruncontext
 

Modified: branches/mtrender/lib/pdf_font.ps
===================================================================
--- branches/mtrender/lib/pdf_font.ps	2008-05-05 18:14:58 UTC (rev 8702)
+++ branches/mtrender/lib/pdf_font.ps	2008-05-05 18:27:06 UTC (rev 8703)
@@ -830,14 +830,14 @@
       1 index begin 3 dict begin
       /Font 3 -1 roll def /CharCode 1 index def
       Encoding exch get CharProcs exch knownoget {
-        PDFfile fileposition exch
-        //false resolvestream
+        { //false resolvestream
 		% Stack: filepos stream
 		% Don't let setgcolor set the color inside the BuildGlyph
 		% procedure, because this causes an /undefined error.
-        q //null /FillColor gput //null /StrokeColor gput
-        Font /Resources get exch pdfopdict .pdfruncontext
-        Q
+          q //null /FillColor gput //null /StrokeColor gput
+          Font /Resources get exch pdfopdict .pdfruncontext
+          Q
+        } PDFfile fileposition 2 .execn % Keep pdfcount valid.
         PDFfile exch setfileposition
       } {
         % PDF Type 3 fonts don't use .notdef
@@ -1354,7 +1354,9 @@
 % Adjust a CIDFontType2 DW[2] and CIDToGIDMap in the font resource.
 /adjustCIDType2 {		% <font-resource> <font> adjustfont <font'>
   addCIDmetrics
-  processCIDToGIDMap
+  dup /CIDFontType get 2 eq {   % OpenType CFF font converts to CIDFontType 0
+    processCIDToGIDMap          %  that ignores CIDMap.
+  } if
   dup /CIDFontName get exch /CIDFont defineresource
 } bind def
 
@@ -1398,17 +1400,60 @@
 
 % Read an embedded OpenType font.
 /readOTTOfont {		% <font-resource> <stream-dict> readOTTOfont <font>
-  1 index exch
-  PDFfile fileposition 3 1 roll
-  dup true resolvestream dup readfontfilter
-		% Stack: pos resource streamdict stream filter
-  3 index /FontDescriptor oget /FontName oget
-  1 index
-  .init_otto_font_file //true ReadData
-  closefile closefile pop
-  PDFfile 3 -1 roll setfileposition
-  /FontDescriptor oget /FontName oget pdfaddcachedfont
-  exch pop
+  1 index exch                    % res res strdict
+  PDFfile fileposition 3 1 roll   % res pos res strdict
+  dup //true resolvestream        % res pos res strdict stream
+  dup readfontfilter              % res pos res strdict stream filter
+  3 index /FontDescriptor oget
+  /FontName oget                  % res pos res strdict stream filter /name
+  1 index .init_otto_font_file    % res pos res strdict stream filter /name filter'
+  //true
+  6 index /CIDSystemInfo known    % res pos res strdict stream filter /name filter' bool bool
+  ReadData                        % res pos res strdict stream filter fontset
+  { exch pop exit } forall        % res pos res strdict stream filter font
+  dup /FontType get 9 eq  {
+    % OpenType may contain simple CFF font, which is accesed as a CIDFont by PDF.
+    % The font is converted to Type 9 CIDFont resource, which ignores CIDMap attribute.
+    % The following code just shuffles GlyphDirectory to the same effect.
+    4 index /CIDToGIDMap knownoget {
+      dup type /dicttype eq {
+        1 index /GlyphDirectory get exch       % res pos res strdict stream filter font dir c2g
+        //true resolvestream                   % res pos res strdict stream filter font dir c2g_file
+        256 dict begin
+        0 2 index 0 get def  % copy .notdef
+        0 1 16#7fffffff {
+          1 index read not { pop exit } if     % res pos res strdict stream filter font dir c2g_file cid hi
+          256 mul                              % res pos res strdict stream filter font dir c2g_file cid hi
+          2 index read not { pop pop exit } if % res pos res strdict stream filter font dir c2g_file cid hi lo
+          add                                  % res pos res strdict stream filter font dir c2g_file cid gid
+          dup 0 ne {
+            dup 4 index length lt {
+              3 index exch get                 % res pos res strdict stream filter font dir c2g_file cid charstr
+              def                              % res pos res strdict stream filter font dir c2g_file
+            } {
+              pop pop
+            } ifelse
+          } {
+            pop pop
+          } ifelse
+        } for
+        closefile pop                          % res pos res strdict stream filter font
+        dup length dict copy                   % res pos res strdict stream filter font'
+        dup /GlyphDirectory currentdict put    % res pos res strdict stream filter font'
+        end
+        dup /GlyphDirectory get 0 exch {
+          pop .max
+        } forall
+        1 index exch /CIDCount exch 1 add put
+      } {
+      pop
+      } ifelse
+    } if
+  } if
+  7 1 roll                        % font res pos res strdict stream filter
+  closefile closefile pop pop     % font res pos
+  PDFfile exch setfileposition    % font res
+  pop                             % font
 } bdef
 
 % ---------------- Font lookup ---------------- %
@@ -1453,12 +1498,12 @@
   /no_stream 
     { pop pop 
       dup /Subtype get  % res res /subtype
-      fonttypeprocs exch dup / eq {
+      dup / eq {
         (   **** Warning: Font missing required Subtype, /Type1 assumed.\n)
 	pdfformaterror
         pop /Type1
       } if
-      get exec 
+      //fonttypeprocs exch get exec 
     } bdef
 
   /bad_stream 
@@ -1497,28 +1542,24 @@
 currentdict /bndef undef
 
 /resourcefont                   % <font-resource> resourcefont <font>
-{ dup /PSFont .knownget {
-    /FID knownoget { type /fonttype eq } { //false } ifelse 
-  } {
-    //false 
-  } ifelse {
+{ dup /PSFont .knownget dup {
+    pop /FID knownoget dup { pop type /fonttype eq } if
+  } if {
     /PSFont get 
   } {
     dup dup /FontDescriptor knownoget {
                                           % font-res font-res font-desc
+      % The same font descriptor can be reused in a CID and non-CID contexts.
+      % Store CID and non-CID fonts under different keys. Bug 689301
+      1 index /Subtype knownoget dup {
+        pop dup /CIDFontType0 eq exch /CIDFontType2 eq or
+      } if { /CIDFontObject } { /FontObject } ifelse
+                                          % font-res font-res font-desc /key
+      2 copy .knownget {
+        4 1 roll pop pop pop              % font-res obj
+      } {    
+        4 1 roll                          % /key font-res font-res font-desc
 
-      dup /FontObject .knownget dup {     % font-res font-res font-desc font? bool bool
-        % Check that the cached FontObject has the right resource type
-        % The same font descriptor can be reused in a CID and non-CID contexts. bug 689301
-        3 index /Subtype knownoget not { /Type1 } if
-        dup /CIDFontType0 eq exch /CIDFontType2 eq or  % font-res font-res font-desc font bool is_cid
-        2 index /CIDFontType known xor {
-          pop pop //false                 % font-res font-res font-desc false 
-        } if
-      } if {
-                                          % res res desc obj
-          3 1 roll pop pop                % res obj
-      } { 
         dup /FontFile knownoget not {
           dup /FontFile2 knownoget not {
             dup /FontFile3 knownoget not {
@@ -1526,7 +1567,7 @@
             } if
           } if
         } if
-                                          % res res desc stream
+                                          % /key res res desc stream
         dup //null ne {
           PDFfile fileposition 
           1 index //true resolvestream dup
@@ -1537,34 +1578,36 @@
         } {
           /no_stream
 	} ifelse
-                                          % res res desc stream tag	      
+                                          % /key res res desc stream tag	      
 
         //font_tag_dict 1 index known not {
           dup 0 2 getinterval <8001> eq {
-            0 2 getinterval               % res res desc stream pfb_tag
+            0 2 getinterval               % /key res res desc stream pfb_tag
 	  } { 
             (12345678>\n) dup /ASCIIHexEncode filter dup 4 -1 roll writestring closefile
             (   **** Warning: unrecognized font file starts with <) exch concatstrings
 	    pdfformaterror
-	    /no_stream                    % res res desc stream unknown_tag
+	    /no_stream                    % /key res res desc stream unknown_tag
           } ifelse    
 	} if		
 	      
 	//font_tag_dict exch get exec
    
-        1 index /FontDescriptor oget      % res font desc
-        1 index /FontObject exch put      % Save pointer to the font
+        1 index /FontDescriptor oget      % /key res font desc
+        4 -1 roll 2 index                 % res font desc /key font
+        put  % Save pointer to the font.
       } ifelse
     } {
-      dup /Subtype get fonttypeprocs exch dup / eq {
+      dup /Subtype get
+      dup / eq {
         (   **** Warning: Font missing required Subtype, /Type1 assumed.\n)
         pdfformaterror
         pop /Type1
       } if 
-      get exec
+      //fonttypeprocs exch get exec
     } ifelse
         % Stack: font-res font
-    1 index 3 1 roll
+    1 index exch
     1 index /Subtype get
     //adjustfonttypes exch .knownget { exec } { exch pop } ifelse
     dup 3 1 roll /PSFont exch put
@@ -1572,7 +1615,9 @@
   dup checkGlyphNames2Unicode
 } bdef
 
-currentdict /font_tag_dict undef
+currentdict /font_tag_dict .undef
+currentdict /fonttypeprocs .undef
+currentdict /adjustfonttypes .undef
 
 drawopdict begin
   /d0 {

Modified: branches/mtrender/lib/pdf_main.ps
===================================================================
--- branches/mtrender/lib/pdf_main.ps	2008-05-05 18:14:58 UTC (rev 8702)
+++ branches/mtrender/lib/pdf_main.ps	2008-05-05 18:27:06 UTC (rev 8703)
@@ -176,6 +176,8 @@
 
 /dopdfpages {   % firstpage# lastpage# dopdfpages -
   << /PDFScanRules //true >> setuserparams	% set scanning rules for PDF vs. PS
+  << /RenderTTNotdef systemdict 
+     /RENDERTTNOTDEF get >> setuserparams	% Should we render TT /.notdef
   1 exch
     { dup /Page# exch store
       QUIET not { (Page ) print dup == flush } if
@@ -1563,20 +1565,20 @@
 % of any other transparency features, they have no effect.
 /pageusestransparency {		% <pagedict> pageusestransparency <bool>
   PDFversion PDFtransparencyversion lt NOTRANSPARENCY or {
-    pop false
+    pop //false
   } {
-    dup false exch {
+    dup //false exch {
       4 dict 1 index resourceusestransparency { pop not exit } if
       /Parent knownoget not { exit } if
     } loop
     % Also check for transparency in the annotation (if not in resources).
-    { pop true } { annotsusetransparency } ifelse
+    { pop //true } { annotsusetransparency } ifelse
   } ifelse
 } bind def
 
 % Check if transparency is specified in an ExtGState dict
 /extgstateusestransparency {	% <gstate dict> extgstateusestransparency <bool>
-  false exch		% Assume no transparency
+  //false exch		% Assume no transparency
   {			% establish loop context
     exch pop oforce
     dup /BM knownoget { dup /Normal ne exch /Compatible ne and
@@ -1625,17 +1627,13 @@
 
 % Check if the annotations on a page use transparency
 /annotsusetransparency {	% <page dict> annotsusetransparency <bool>
-   false exch			% Assume no transparency
+   //false exch			% Assume no transparency
    /Annots knownoget {		% Get Annots array
      { oforce /AP knownoget {	% Get appearance dict for the annoation
-	/N knownoget { 	% Get the /N (i.e. normal) appearance stream
-	  /Resources knownoget {
-	    /ExtGState knownoget {
-	       extgstateusestransparency { pop true exit} if
-	     } if		% If ExtGState known
-	   } if			% If Resources known
-	 } if			% If annotation has a normal appearance
-       } if			% If AP dict known
+         /N knownoget { 	% Get the /N (i.e. normal) appearance stream
+           4 dict exch resourceusestransparency { pop //true exit } if
+         } if
+       } if  			% If AP dict known
      } forall			% For all annots on the page
    } if
 } bind def

Modified: branches/mtrender/lib/pdf_ops.ps
===================================================================
--- branches/mtrender/lib/pdf_ops.ps	2008-05-05 18:14:58 UTC (rev 8702)
+++ branches/mtrender/lib/pdf_ops.ps	2008-05-05 18:27:06 UTC (rev 8703)
@@ -543,7 +543,7 @@
 
 % Read a CFF font.
 /FRD		% <resname> <file> FRD -
- { /FontSetInit /ProcSet findresource begin //true ReadData
+ { /FontSetInit /ProcSet findresource begin //true //false ReadData pop
  } bdef
 
 % Copy a font, removing its FID.  If changed is true, also remove
@@ -706,7 +706,7 @@
 	            2 index setfillstate show % Tr was set to graphic state.
 	            setmatrix 
 		    % now set the currentpoint using the original matrix
-	            gsave nulldevice
+	            gsave
 	            setmatrix
 	            false charpath currentpoint newpath 
 	            grestore

Modified: branches/mtrender/lib/pdfopt.ps
===================================================================
--- branches/mtrender/lib/pdfopt.ps	2008-05-05 18:14:58 UTC (rev 8702)
+++ branches/mtrender/lib/pdfopt.ps	2008-05-05 18:27:06 UTC (rev 8703)
@@ -684,7 +684,7 @@
 /writePart3 {		% <xrefstart> writePart3 -
   {
     FirstPageXN NObjects 1 add 1 index sub pdfwritexref
-    Trailer dup length 1 add dict copy
+    Trailer dup length 1 add dict copy Trailer xcheck { cvx } if
     dup /Size NObjects 1 add put
     dup /Prev 4 -1 roll put
     pdfwritetrailer

Modified: branches/mtrender/lib/pdfwrite.ps
===================================================================
--- branches/mtrender/lib/pdfwrite.ps	2008-05-05 18:14:58 UTC (rev 8702)
+++ branches/mtrender/lib/pdfwrite.ps	2008-05-05 18:27:06 UTC (rev 8703)
@@ -151,7 +151,7 @@
 % set of valid name characters. PDF 1.1 and earlier allowed spaces in names
 % which probably wouldn't make it past the tokenizer anyway.
 /pdfnamechars
-  (!"#$&'*+,-.0123456789:;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ\\^_`abcdefghijklmnopqrstuvwxyz|~)
+  (!"$&'*+,-.0123456789:;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ\\^_`abcdefghijklmnopqrstuvwxyz|~)
 readonly def
 /pdfwritename {		% <name> pdfwritename -
   (/) ows .namestring {
@@ -335,7 +335,20 @@
   } for
 } bind def
 /pdfwritetrailer {	% <trailer> pdfwritetrailer -
-  (trailer\n) ows pdfwritevalue (\n) ows
+  (trailer\n) ows
+  % Since we always write a complete "classic" xref, the Trailer may need to be adjusted:
+  % - remove keys that pertain to xref-streams and hybrid-xref PDFs;
+  % - if it's a PDF stream, turn it into a PDF dict by removing keys used for 
+  %   PDF streams (both standard and GS-specific), and the executable attribute
+  dup /XRefStm known 1 index xcheck or {
+    dup length dict copy
+    dup {/Type/Index/W /XRefStm /Filter/DecodeParms/Length/File/FilePosition} {
+      undef dup
+    } forall pop
+    % note: the executable attribute is "removed" by not being copied
+  } if
+  pdfwritevalue
+  (\n) ows
 } bind def
 /pdfwritestartxref {	% <startpos> pdfwritestartxref -
   (startxref\n) ows OFile exch write=
@@ -374,7 +387,7 @@
 
   /xref OFile fileposition def
   0 XRef ld_length 1 add pdfwritexref
-  trailer dup length 1 add dict copy
+  trailer dup length 1 add dict copy trailer xcheck { cvx } if
   dup /Size XRef ld_length 1 add put pdfwritetrailer
   xref pdfwritestartxref
 

Modified: branches/mtrender/lib/pf2afm.ps
===================================================================
--- branches/mtrender/lib/pf2afm.ps	2008-05-05 18:14:58 UTC (rev 8702)
+++ branches/mtrender/lib/pf2afm.ps	2008-05-05 18:27:06 UTC (rev 8703)
@@ -419,8 +419,37 @@
   (EndFontMetrics) =to.ofi
 } def
 
+/pfa_pfb_dict <<
+  /.pfb /pfbn
+  /.pfB /pfbn
+  /.pFb /pfbn
+  /.pFB /pfbn
+  /.Pfb /pfbn
+  /.PfB /pfbn
+  /.PFb /pfbn
+  /.PFB /pfbn
+
+  /.pfa /pfan
+  /.pfA /pfan
+  /.pFa /pfan
+  /.pFA /pfan
+  /.Pfa /pfan
+  /.PfA /pfan
+  /.PFa /pfan
+  /.PFA /pfan
+>> readonly def
+
+% Check whether the file name has pfa or pfb extension.
+/pfa_or_pfb? {      % s -> false   |    /name true
+  dup length 4 lt {
+    pop //false
+  } {
+    dup length 4 sub 4 getinterval //pfa_pfb_dict exch .knownget
+  } ifelse
+} bind def
+
+
 % pf[ba]filename makeafm -
-
 /makeafm {
   count 0 eq {(Missing font file name\n) printquit} if
   /ifn edef
@@ -429,18 +458,11 @@
 % i.e., it analyses the supplied names, appends extensions if needed,
 % and check files:
   /pfbn () def /pfan () def /pfmn () def % initialisation
-  ifn (.pfb) search {
-    3 -1 roll length 0 eq {% file name extension = ".pfb"
-      ifn dup length string copy /pfbn edef
-      /ifn edef
-    }{pop} ifelse
-  } if pop
-  ifn (.pfa) search {
-    3 -1 roll length 0 eq {% file name extension = ".pfa"
-      ifn dup length string copy /pfan edef
-      /ifn edef
-    }{pop} ifelse
-  } if pop
+
+  ifn pfa_or_pfb? {
+      ifn dup length string copy def
+      ifn dup length 4 sub 0 exch getinterval /ifn edef
+  } if
   pfbn () eq pfan () eq and dup {% no extension was supplied, try ".pfb"
     /pfbn ifn (.pfb) concatstrings def
   } if
@@ -469,7 +491,7 @@
     pop pop pop pop
   }{
     () pfmn {
-      (/) search {
+      (/) search dup not { pop (\\) search } if {
         4 -1 roll exch concatstrings exch concatstrings exch
       }{
         exit



More information about the gs-cvs mailing list