summaryrefslogtreecommitdiff
path: root/Master/tlpkg/tlgs/lib/gs_ttf.ps
diff options
context:
space:
mode:
Diffstat (limited to 'Master/tlpkg/tlgs/lib/gs_ttf.ps')
-rw-r--r--Master/tlpkg/tlgs/lib/gs_ttf.ps189
1 files changed, 167 insertions, 22 deletions
diff --git a/Master/tlpkg/tlgs/lib/gs_ttf.ps b/Master/tlpkg/tlgs/lib/gs_ttf.ps
index e657112b199..e6295825fbb 100644
--- a/Master/tlpkg/tlgs/lib/gs_ttf.ps
+++ b/Master/tlpkg/tlgs/lib/gs_ttf.ps
@@ -13,7 +13,7 @@
% contact Artifex Software, Inc., 101 Lucas Valley Road #110,
% San Rafael, CA 94903, U.S.A., +1(415)492-9861.
-% $Id: gs_ttf.ps 8022 2007-06-05 22:23:38Z giles $
+% $Id: gs_ttf.ps 8556 2008-02-28 14:56:32Z alexcher $
% Support code for direct use of TrueType fonts.
% (Not needed for Type 42 fonts.)
@@ -138,12 +138,61 @@ currentdict /tt_tag_dict .undef
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
+/.latin1isodict ISOLatin1Encoding .invert_encoding def
% Define remapping for misnamed glyphs in TrueType 'post' tables.
% There are probably a lot more than this!
@@ -527,13 +576,8 @@ currentdict /tt_tag_dict .undef
5 index 4 index 3 index % s o p lSi minl from s p minl
getinterval % s o p lSi minl from to
copy pop % s o p lSi minl
- 3 1 roll % s o minl p lSi
- sub % s o minl p'
- 3 1 roll add % s p' o'
- dup 3 index length ge {
- exch exit % s o p'
- } if
- exch % s o' p'
+ exch pop add exch pop 0 exch % s 0 p'
+ dup 3 index length ge { exit } if
} ifelse
} forall
pop pop % s
@@ -573,9 +617,41 @@ currentdict /tt_tag_dict .undef
postglyphs postpos //get_from_stringarray exec
postglyphs postpos 1 add 2 index //getinterval_from_stringarray exec cvn
exch postpos add 1 add /postpos exch def
- 2 index 3 1 roll put
+ 2 index 3 1 roll
+ put
} for
/postnames exch def
+
+ % Some TrueType fonts converted by "Windows Type 1 Installer" have
+ % problematic post table including MacGlyphEncoding entries which
+ % should be omitted. Such extra entries in the beginning of glyphName
+ % array make /Encoding broken. If we find populary predefined
+ % ISOLatin1Encoding glyph name in the post table, empty encoding is
+ % returned. Some TrueType fonts for Microsoft Windows redefines
+ % MacGlyphEncoding glyph name out of predefined range). To permit
+ % such fonts, ISOLatin1Encoding is used to find broken post. Bug 689495.
+ /.broken_post //false def
+ tabdict /name .knownget {
+ (Windows Type 1 Installer V1.0) search {
+ pop pop pop
+ .latin1isodict postnames {
+ dup //null ne
+ % dup /.notdef ne and
+ {
+ 2 copy known {
+ TTFDEBUG { (ignore post table that redefines ISOLatin1Encoding glyph name ) print dup == flush } if
+ /.broken_post //true def
+ pop exit
+ } if
+ } if
+ pop
+ } forall
+ pop
+ } {
+ pop
+ } ifelse
+ } if
+
numglyphs array 0 1 numglyphs 1 sub {
dup 2 mul 34 add postglyphs exch 2 //getinterval_from_stringarray exec
dup 0 get 8 bitshift exch 1 get add dup 258 lt {
@@ -603,6 +679,18 @@ currentdict /tt_tag_dict .undef
} ifelse
2 index 3 1 roll put
} for
+
+ .broken_post {
+ pop
+ 0 1 postnames length 1 sub {
+ postnames 1 index get null eq {
+ postnames 1 index /.notdef put
+ } if
+ pop
+ } for
+
+ [ postnames aload length 1 roll ]
+ } if
}
ifelse
} bind
@@ -1074,8 +1162,13 @@ mark
} if
/cmapsub 1 index def
dup 4 getu32 % bool [] i PlatID SpecID (cmap) (cmapsub) p
- cmaptab length 1 index sub % bool [] i PlatID SpecID (cmap) (cmapsub) p l
- cmaptab 3 1 roll getinterval
+ cmaptab 1 index getu16a % get cmap format
+ 8 lt { % length for traditional 16bit format 0, 2, 4, 6
+ cmaptab 1 index 2 add getu16a
+ } { % length for advanced 32bit format 8, 10, 12
+ cmaptab 1 index 4 add getu32a
+ } ifelse % bool [] i PlatID SpecID (cmap) (cmapsub) p l
+ cmaptab 3 1 roll getinterval_from_stringarray
/cmaptab exch def % bool [] i PlatID SpecID (cmap) (cmapsub)
5 index 5 index 1 add get % bool [] i PlatID SpecID (cmap) (cmapsub) /Decoding
/Decoding exch def % bool [] i PlatID SpecID (cmap) (cmapsub)
@@ -1378,14 +1471,10 @@ mark
exch
} if
2 index 1 index known
- { dup /.notdef eq {
- pop pop % discard duplicate .notdef glyphs
- } {
- % The same name maps to more than one glyph. Change the name.
- pop dup .nname 3 index 2 index 2 index put
- 2 index exch 3 -1 roll put
- }
- ifelse
+ { % The same name maps to more than one glyph. Change the name.
+ % No special treatment for /.notdef glyph. Bug 689408.
+ pop dup .nname 3 index 2 index 2 index put
+ 2 index exch 3 -1 roll put
} {
2 index exch 3 -1 roll put % unique name
} ifelse
@@ -1760,8 +1849,29 @@ currentdict /postalias undef
<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.
@@ -1776,7 +1886,12 @@ currentdict /postalias undef
<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
@@ -1793,6 +1908,36 @@ currentdict /postalias undef
/is_symbolic gput
//false 0 .loadttfonttables
.makesfnts
+ tabdict /cmap known not {
+ ( **** Warning: Embedded TT font lacks required cmap table. Using identity cmap.\n)
+ pdfformaterror
+ % Unknown (i.e. not 0 ) language ID brings in post table.
+ % Fields: cmap_version, number_of_subtables,
+ % plarform_id, encoding_id, offset,
+ % format, subtable_length, language,
+ % 256 bytes of identity mapping.
+ tabdict /cmap
+ < 0000 0001
+ 0001 D00D 0000000c
+ 0000 0106 0000
+ 00 01 02 03 04 05 06 07 08 09 0a 0d 0c 0d 0e 0f
+ 10 11 12 13 14 15 16 17 18 19 1a 1d 1c 1d 1e 1f
+ 20 21 22 23 24 25 26 27 28 29 2a 2d 2c 2d 2e 2f
+ 30 31 32 33 34 35 36 37 38 39 3a 3d 3c 3d 3e 3f
+ 40 41 42 43 44 45 46 47 48 49 4a 4d 4c 4d 4e 4f
+ 50 51 52 53 54 55 56 57 58 59 5a 5d 5c 5d 5e 5f
+ 60 61 62 63 64 65 66 67 68 69 6a 6d 6c 6d 6e 6f
+ 70 71 72 73 74 75 76 77 78 79 7a 7d 7c 7d 7e 7f
+ 80 81 82 83 84 85 86 87 88 89 8a 8d 8c 8d 8e 8f
+ 90 91 92 93 94 95 96 97 98 99 9a 9d 9c 9d 9e 9f
+ a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ad ac ad ae af
+ b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bd bc bd be bf
+ c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cd cc cd ce cf
+ d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da dd dc dd de df
+ e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea ed ec ed ee ef
+ f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fd fc fd fe ff
+ > readonly put
+ } if
.getpost
.pickcmap
mark