[gs-cvs] rev 8260 - trunk/gs/lib
mpsuzuki at ghostscript.com
mpsuzuki at ghostscript.com
Sun Sep 30 23:19:18 PDT 2007
Author: mpsuzuki
Date: 2007-09-30 23:19:18 -0700 (Sun, 30 Sep 2007)
New Revision: 8260
Modified:
trunk/gs/lib/gs_ttf.ps
Log:
Fix: Preprocess the glyphnames in prebuilt_encoding by AdobeGlyphList for Microsft UCS2 cmap subtable
DETAILS:
According to PDF Ref 1.7 p. 430, Adobe modern products
always prioritize Microsoft UCS2 TrueType cmap subtable
regardless with /Encoding, as far as the font is declared
as Nonsymbolic by /Flags. For example, even if /Encoding
is MacRomanEncoding, Microsoft UCS2 TrueType cmap subtable
is prioritized than Apple Roman TrueType cmap subtable.
The encoding of Microsoft UCS2 TrueType cmap is not a
superset of MacRomanEncoding, see PDF Ref 1.7 Appendix D.
Current implementation expects the content of /Encoding
is always compatible with chosen TrueType cmap subtable,
thus unexpected mismatching causes loss of glyph like:
bug 689351 "Content Loss for certain Embedded Type42 Glyphs with gs8.57"
When Microsoft UCS2 TrueType cmap subtable is chosen,
the glyphnames used in /prebuilt_encoding[] should be
preprocessed: the glyphnames changed to the charcode
compatible with Microsoft UCS2 encoding scheme, before
combining with charcode-glyph mapping table in Microsoft
UCS2 TrueType cmap subtable. The preprocessing should
be done by AdobeGlyphList that maps known glyphnames
to UCS2 charcode. The unknown glyphnames are left to
second processing in /.pdfmapchars. This preprocess
fixes bug 689351.
There might be broken TrueType fonts that use the names
in AdobeGlyphList at incompatible UCS2 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-09-30 19:46:25 UTC (rev 8259)
+++ trunk/gs/lib/gs_ttf.ps 2007-10-01 06:19:18 UTC (rev 8260)
@@ -1761,8 +1761,29 @@
<00030001> .findcmap {
prebuilt_encoding null ne {
TTFDEBUG { (Using cmap 3.1 with prebuilt_encoding for non-symbolic.) = } if
+
+ % The character code in /prebuilt_encoding[] is not guaranteed to be
+ % compatible with the Microsoft UCS2 TrueType cmap subtable.
+ % If the glyphname is known by AdobeGlyphList, the charcode for the glyph
+ % is replaced by UCS2 charcode from AdobeGlyphList. Otherwise it is left
+ % as in /prebuilt_encoding[]. /.pdfmapchars should dredge them.
+
/.allow_uniXXXX_glyph_names //true def
- prebuilt_encoding .invert_encoding .pdfmapchars
+ AdobeGlyphList prebuilt_encoding .invert_encoding dup { % <<AGL>> <<pbe>> <glyphname> <pbecode>
+ pop % <<AGL>> <<pbe>> <glyphname>
+ TTFDEBUG { (check glypname /) print dup =only flush } if
+ 2 index 1 index .knownget { % <<AGL>> <<pbe>> <glyphname> <AGLcode>
+ 2 index 3 1 roll % <<AGL>> <<pbe>> <<pbe>> <glyphname> <AGLcode>
+ TTFDEBUG { ( redefine codepoint by AdobeGlyphList, ) print dup == flush } if
+ put % <<AGL>> <<pbe>>
+ } { % <<AGL>> <<pbe>> <glyphname>
+ TTFDEBUG { ( unknown glyphname, leave as it is ) print flush } if
+ pop % <<AGL>> <<pbe>>
+ } ifelse
+ } forall
+ exch pop % <<pbe>>
+ TTFDEBUG { dup (<<\n) print { exch ( ) print =only (\t) print == } forall (>>\n) print flush } if
+ .pdfmapchars
/Encoding prebuilt_encoding
} {
% Likely this branch is now obsolete.
More information about the gs-cvs
mailing list