[gs-cvs] gs/lib
Igor Melichev
igor at ghostscript.com
Thu Dec 16 04:39:21 PST 2004
Update of /cvs/ghostscript/gs/lib
In directory casper2:/tmp/cvs-serv7869/gs/lib
Modified Files:
Tag: GS_8_1X
gs_ttf.ps gs_typ42.ps
Log Message:
Fix (PDF interpreter) : Prefer 'post' to cmap 1.0, because obsolete PDF writers misuse the latter.
DETAILS :
Bug 687828 "pages retain some of earlier pages displayed/"
The bug title above is misleading.
Real problem is missing characters and rendering .notdef instead.
This patch improves hewristics for choosing an encoding
for True Type fonts. Obsolete versions of Distiller and Ghostscript
wrote a cmap 1.0 (Macintosh Roman) into a PDF, which really uses a
random encoding. For example, the test case of the bug 687828
encodes Arabian characters with cmap 1.0.
Thits patch prefers to use 'post' table instead cmap 1.0,
when a 'post' table presents, and font resource dictionary
doesn't specify Encoding.
Also improved a debug printing.
EXPECTED DIFFERENCES :
None.
Index: gs_ttf.ps
===================================================================
RCS file: /cvs/ghostscript/gs/lib/gs_ttf.ps,v
retrieving revision 1.28.2.5
retrieving revision 1.28.2.6
diff -u -d -r1.28.2.5 -r1.28.2.6
--- gs_ttf.ps 4 Aug 2004 15:20:10 -0000 1.28.2.5
+++ gs_ttf.ps 16 Dec 2004 12:39:19 -0000 1.28.2.6
@@ -830,7 +830,9 @@
} {
TTFDEBUG { (post: unknown format ) print post 0 getu32 = flush } if [ ]
} ifelse
- } ifelse def
+ } ifelse
+ TTFDEBUG { (post=) print dup == } if
+ def
} bind def
% - .ttkeys <key> <value> ...
@@ -988,8 +990,14 @@
} if
% Hack: if there is no usable post table but the cmap uses
% the Microsoft Unicode encoding, use ISOLatin1Encoding.
- glyphencoding length 0 eq cmapsub 0 4 getinterval <00030001> eq and {
+ glyphencoding length 0 eq {
+ cmapsub 0 4 getinterval <00030001> eq {
+ PDFDEBUG { (No post but have cmap 3.1, so use ISOLatin1Encoding) } if
/glyphencoding ISOLatin1Encoding dup length array copy def
+ } {
+ PDFDEBUG { (No encoding info, use .GS_extended_SymbolEncoding) } if
+ /glyphencoding /.GS_extended_SymbolEncoding findencoding dup length array copy def
+ } ifelse
} if
% If necessary, fabricate additional glyphencoding entries
% to cover all of loca, or truncate glyphencoding.
@@ -1245,6 +1253,7 @@
%
( **** Warning: Embedded symbolic TT fonts should not contain a cmap for Platform=3 Encoding=1.\n)
pdfformaterror
+ TTFDEBUG { (Using cmap 3.1) = } if
AdobeGlyphList .pdfmapchars
/Encoding /WinAnsiEncoding .findencoding
} {
@@ -1265,11 +1274,16 @@
%
<00010000> .findcmap {
prebuilt_encoding null ne {
+ TTFDEBUG { (Using cmap 1.0 with prebuilt_encoding.) = } if
prebuilt_encoding .invert_encoding .pdfmapchars
/Encoding prebuilt_encoding
} {
- .symbol_list .pdfmapchars
- /Encoding /.GS_extended_SymbolEncoding .findencoding
+ % This is a case, in which an obsolete software could stupidly specify Macintosh Roman
+ % for a random encoding. Particulatrly GPL Ghostscript 7.06 does so.
+ % Trying to recover with 'post'.
+ pop % The table itself doesn't contain useful data.
+ TTFDEBUG { (Using cmap 1.0 with post or .GS_extended_SymbolEncoding) = } if
+ .charkeys
} ifelse
} {
% This is illegal with PDF spec.
@@ -1277,6 +1291,7 @@
pdfformaterror
% Try to map Unicode to SymbolEncoding
<00030001> .findcmap {
+ TTFDEBUG { (Using cmap 3.1) = } if
AdobeGlyphList .pdfmapchars
/Encoding /SymbolEncoding .findencoding
} {
@@ -1294,6 +1309,7 @@
% Try another cmap format 3,0 -- Adobe doesn't mention it, but does
% use it apparently (empirically determined).
<00030000> .findcmap {
+ TTFDEBUG { (Adding cmap 3.0) = } if
5 1 roll pop pop pop pop
prebuilt_encoding null ne {
prebuilt_encoding .invert_encoding .pdfmapchars
@@ -1310,6 +1326,7 @@
} ifelse
} {
<00030001> .findcmap {
+ TTFDEBUG { (Using cmap 3.1 for non-symbolic.) = } if
AdobeGlyphList .pdfmapchars
/Encoding /WinAnsiEncoding .findencoding
% WinAnsiEncoding is just a stub here.
@@ -1317,6 +1334,7 @@
% because PDF spec requires it.
} {
<00010000> .findcmap {
+ TTFDEBUG { (Using cmap 1.0 for non-symbolic.) = } if
.romanmacdict .pdfmapchars
/Encoding /MacRomanEncoding .findencoding
} {
Index: gs_typ42.ps
===================================================================
RCS file: /cvs/ghostscript/gs/lib/gs_typ42.ps,v
retrieving revision 1.6
retrieving revision 1.6.2.1
diff -u -d -r1.6 -r1.6.2.1
--- gs_typ42.ps 21 Feb 2002 21:49:28 -0000 1.6
+++ gs_typ42.ps 16 Dec 2004 12:39:19 -0000 1.6.2.1
@@ -32,7 +32,10 @@
dup CharStrings exch .knownget not
{ 2 copy eq { exch pop /.notdef exch } if
QUIET not
- { (Substituting .notdef for ) print = flush }
+ { (Substituting .notdef for ) print
+ =string cvs print ( in the font ) print
+ 1 index /FontName get = flush
+ }
{ pop }
ifelse
/.notdef CharStrings /.notdef get
More information about the gs-cvs
mailing list