[gs-cvs] rev 8261 - trunk/gs/lib

mpsuzuki at ghostscript.com mpsuzuki at ghostscript.com
Sun Sep 30 23:26:22 PDT 2007


Author: mpsuzuki
Date: 2007-09-30 23:26:21 -0700 (Sun, 30 Sep 2007)
New Revision: 8261

Modified:
   trunk/gs/lib/gs_ttf.ps
Log:
Fix: (TT font handler) : Use given prebuilt_encoding when Apple Roman TrueType cmap subtable is chosen

DETAILS:
As current implementation assumes /prebuilt_encoding[] is
compatible with WinAnsiEncoding when Microsoft UCS2 TrueType
cmap subtable is chosen, current implementation assumes
/prebuilt_encoding[] is same with MacRomanEncoding when
Apple Roman TrueType cmap subtable is chosen.
/prebuilt_encoding[] is completely ignored and the inverse
of MacRomanEncoding is used. Therefore, when Apple Roman
TrueType cmap subtable is chosen but /Encoding is
StandardEncoding or PDFDocEncoding, some characters are
shown by wrong glyphs. This patch uses /prebuild_encoding[]
if it's given, when Apple Roman TrueType cmap subtable is
chosen.

According to PDF Ref 1.7 p. 431, MacRomanEncoding does not
cover all characters in Apple Roman TrueType cmap subtable,
16 characters are missing. To exploit the glyphs as many
as possible via Apple Roman TrueType cmap subtable, this
patch introduces "MacRomanEncodingForTrueType" including
missing 16 characters. By this change, 16 glyphnames
can be exploited via Apple Roman TrueType cmap subtable.

There might be broken TrueType fonts that use the names
in MacRomanEncoding at incompatible 8bit charcode. The
text drawn by such fonts would be broken, the results are
unexpected.

EXPECTED DIFFERENCES:
None.


Modified: trunk/gs/lib/gs_ttf.ps
===================================================================
--- trunk/gs/lib/gs_ttf.ps	2007-10-01 06:19:18 UTC (rev 8260)
+++ trunk/gs/lib/gs_ttf.ps	2007-10-01 06:26:21 UTC (rev 8261)
@@ -138,12 +138,60 @@
   exch pop
 } bind def
 
+% Make /MacRomanEncodingForTrueType including additional
+% characters in Mac OS Roman encoding, which is missing
+% in /MacRomanEncoding. See PDF spec 1.7, p. 431 or
+% "Inside Macintosh: Text" 1-55, Figure 1-36.
+% This is useful to exploit the glyphs via Apple Roman
+% TrueType cmap subtable, but not appropriate for information
+% interchange.
+
+/MacRomanEncodingForTrueType
+  /MacRomanEncoding .findencoding
+  dup length array copy
+  <<
+	/notequal	173
+	/infinity	176
+	/lessequal	178
+	/greaterequal	179
+	/partialdiff	182
+	/summation	183
+	/product	184
+	/pi		185
+	/integral	186
+	/Omega		189
+	/radical	195
+	/approxequal	197
+	/Delta		198
+	/lozenge	215
+	/Euro		219
+	/apple		240
+  >> {
+    TTFDEBUG { (Extend MacRomanEncodingForTrueType for TrueType: ) =only } if
+
+    % check /.notdef to avoid overwriting
+    2 index 1 index get dup /.notdef eq {
+      TTFDEBUG { (insert /) =only 2 index =only ( @ ) =only 1 index == } if
+      pop
+      exch 2 index 3 1 roll put
+    } {
+      TTFDEBUG { (cannot insert /) =only 2 index =only ( @ ) =only 1 index =only ( used for ) =only dup == } if
+      pop
+      pop pop
+    } ifelse
+  } forall
+  aload pop
+  256 packedarray
+  5 1 index .registerencoding
+.defineencoding
+
 % Define the Macintosh standard mapping from characters to glyph indices.
 /MacRomanEncoding dup .findencoding def
 /MacGlyphEncoding dup .findencoding def
+/MacRomanEncodingForTrueType dup .findencoding def
 
 % Invert the MacRomanEncoding.
-/.romanmacdict MacRomanEncoding .invert_encoding def
+/.romanmacdict MacRomanEncodingForTrueType .invert_encoding def
 
 % Define remapping for misnamed glyphs in TrueType 'post' tables.
 % There are probably a lot more than this!
@@ -1798,7 +1846,12 @@
       <00010000> .findcmap {
         TTFDEBUG { (Using cmap 1.0 for non-symbolic.) = } if
 	.romanmacdict .pdfmapchars 
-        /Encoding /MacRomanEncoding .findencoding
+        /Encoding
+        prebuilt_encoding null ne {
+          prebuilt_encoding
+        } {
+          /MacRomanEncodingForTrueType .findencoding
+        } ifelse
       } {
         % Apply the default algorithm for using the 'post'.
 	.charkeys



More information about the gs-cvs mailing list