[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: DVIPS fix for better Macintosh PDF

Yesterday, on the PDFTeX and TeX-Fonts list, Melissa outlined a bug in the
   Macintosh Acrobat Reader (in combination with ATM Deluxe 4.0) where
   it doesn't like encodings that refer to glyphs not in the font. 
and suggested changing

      /ReEncodeFont{/Encoding exch def}def

   ... in texps.pro, to:

	 /Encoding exch 256 array copy def
	 CharStrings rcheck {
	   0 1 255 { dup Encoding exch get CharStrings exch known
			 { pop }
			 { Encoding exch /.notdef put }
		     ifelse } for
	 } if

   This approach does require 256 bytes extra per font (it copies the
   encoding rather than referencing it directly, and then deletes every
   entry for which there is no glyph in the CharStrings dictionary).

As an inveterate code-twiddler, (and incidentally the author of the original
version of ReEncodeFont), I couldn't resist the opportunity to play around 
with this to avoid copying the encoding every time, and came up with

/ReEncodeFont {
   CharStrings rcheck {
      /Encoding false def dup
      [ exch {
         dup CharStrings exch known not {
            pop /.notdef
            /Encoding true def
         } if
      } forall 
      Encoding {] exch pop} {cleartomark} ifelse
   } if
   /Encoding exch def 
} def

in which the new encoding vector is built on the stack
(the idea is that "[ exch {   } forall ]" copies an array,
and provides hooks which can be used to make alterations)
and simply discarded, using "cleartomark", if not needed.
Encoding is used as temporary storage to note whether any changes are made.

Hope this is useful