diff options
Diffstat (limited to 'Master/tlpkg/tlgs/Resource/Init/gs_ttf.ps')
-rw-r--r-- | Master/tlpkg/tlgs/Resource/Init/gs_ttf.ps | 78 |
1 files changed, 37 insertions, 41 deletions
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_ttf.ps b/Master/tlpkg/tlgs/Resource/Init/gs_ttf.ps index ebacc6bbd0d..8cb5b390c57 100644 --- a/Master/tlpkg/tlgs/Resource/Init/gs_ttf.ps +++ b/Master/tlpkg/tlgs/Resource/Init/gs_ttf.ps @@ -435,7 +435,7 @@ currentdict /woff_tag_dict .undef } bind def % Each procedure in this dictionary is called as follows: -% <encodingtable> proc <glypharray> +% <encodingtable> proc <glyph dictionary> /cmapformats mark 0 { % Apple standard 1-to-1 mapping. 6 256 getinterval_from_stringarray @@ -538,35 +538,20 @@ currentdict /woff_tag_dict .undef /putglyph { glyphs code 3 -1 roll put /code code 1 add def } bind def - % Do a first pass to compute the size of the glyphs array. - /numcodes 0 def /glyphs 0 dict def - 0 0 2 nseg2 3 sub { - % Stack: /glyphs numglyphs i2 - /i2 exch def - /scode startc i2 getu16a def - /ecode endc i2 getu16a def - - % Bug 693538: More undocumented nonsense: in cases where scode == ecode, - % see Bug 691326 below *except*, it seems when both are zero - scode 0 eq ecode 0 eq and not { - scode ecode 1 add gt { % Bug 691326. - /ecode scode 1 add def % Acrobat does this contrary to TTF spec that - } if % requires such intervals to be ignored. - numcodes scode firstcode sub - % Hack for fonts that have only 0x0000 and 0xf000 ranges - %dup 16#e000 ge { 255 and } if - % the previous line is obstructive to CJK fonts, so it was removed - exch sub 0 .max ecode scode sub 1 add add - exch 1 index add exch - numcodes add /numcodes exch def - } if - } for pop - - % Now fill in the array. /numcodes 0 def /code 0 def - 0 2 nseg2 3 sub { + % neg2 is number of segments x 2. A format 4 cmap, with usable + % mappings cannot (according to the spec) have only 1 segment, + % since format 4 requires a closing segment with start and end + % codes being 0xffff. Unfortunately, we have found badly subsetted + % TTF fonts which have one segment with valid mappings, and no + % closing segment. + % In such a case, force the loop to work as though as we have two + % segments - this works as we don't rely on the terminating segment + % but use the loop counter to spot completion - effrectively, we + % ignore the closing segment when it's present, anyway. + 0 2 nseg2 dup 4 lt {pop 4}if 3 sub { /i2 exch def /scode startc i2 getu16a def /ecode endc i2 getu16a def @@ -633,8 +618,8 @@ currentdict /woff_tag_dict .undef } bind .dicttomark readonly def % cmapformats -% <cmaptab> cmaparray <glypharray> -/cmaparray { +% <cmaptab> cmapdict <glyph dictionary> +/cmapdict { dup 0 getu16a cmapformats exch .knownget { TTFDEBUG { (cmap: format ) print 1 index 0 getu16a = flush @@ -1389,7 +1374,7 @@ mark def } if - /cmapa cmaptab cmaparray def + /cmapa cmaptab cmapdict def % Some badly designed Chinese fonts have a post table % in which all glyphs other than 0 are named .null. % Use CharStrings to keep track of the reverse map from @@ -1436,7 +1421,7 @@ mark TTFDEBUG { (\n1 setting alias: ) print dup ==only ( to be the same as ) print 2 index //== exec } if - 7 index 2 index 3 -1 roll exch //.growput superexec + 7 index 2 index 3 -1 roll exch //.growput systemdict /superexec known {//superexec}{1183615869 internaldict /superexec get exec} ifelse } forall pop pop pop } @@ -1454,7 +1439,7 @@ mark exch pop TTFDEBUG { (\n2 setting alias: ) print 1 index ==only ( to use glyph index: ) print dup //== exec } if - 5 index 3 1 roll //.growput superexec + 5 index 3 1 roll //.growput systemdict /superexec known {//superexec}{1183615869 internaldict /superexec get exec} ifelse //false } { @@ -1471,7 +1456,7 @@ mark { % CharStrings(dict) isunicode(boolean) cmap(dict) RAGL(dict) gname(name) codep(integer) gindex(integer) TTFDEBUG { (\3 nsetting alias: ) print 1 index ==only ( to be index: ) print dup //== exec } if - exch pop 5 index 3 1 roll //.growput superexec + exch pop 5 index 3 1 roll //.growput systemdict /superexec known {//superexec}{1183615869 internaldict /superexec get exec} ifelse } { pop pop @@ -1626,7 +1611,7 @@ currentdict /postalias undef mark .ttkeys /NumGlyphs numloca - /TT_cmap cmaptab cmaparray + /TT_cmap cmaptab cmapdict /file_table_pos file_table_pos /Decoding Decoding .dicttomark @@ -1645,7 +1630,7 @@ currentdict /postalias undef mark .ttkeys /NumGlyphs numloca - /TT_cmap cmaptab cmaparray + /TT_cmap cmaptab cmapdict % /file_table_pos file_table_pos /Decoding Decoding .dicttomark @@ -1767,9 +1752,8 @@ currentdict /postalias undef % <chartoglyphmap> <subcmap> <AGL> .pdfmapchars /CharStrings <charstrings> /.pdfmapchars { - exch cmaparray /cmapencoding exch def % c2g + exch cmapdict /cmapencoding exch def % c2g /CharStrings 0 dict % c2g /CS <<>> - % Add glyphs of <AGL>*<subcmap> : 3 2 roll { % /CS <<>> v dup type /arraytype eq { % /CS <<>> /name [] @@ -1806,13 +1790,12 @@ currentdict /postalias undef } forall dup /.notdef 0 put - } bind def % <subtable> .pdfmapsymbolic /Encoding [] /CharStrings <<>> /.pdfmapsymbolic { //true /.render_notdef gput - cmaparray + cmapdict dup length 1 add dict begin [ 64 { /.notdef /.notdef /.notdef /.notdef } repeat ] exch { % [] char glyph @@ -1845,7 +1828,7 @@ currentdict /postalias undef % The following algorithms are per the PDF 1.7 Reference. TTFDEBUG { (.pdfcharkeys beg) = } if - % if the flags say symbolic, *and* the font contains a symbol + % if the flags say symbolic, *and* the font contains a symbol or UCS-2 % cmap table, ignore Encoding if there is one, treat as symbolic. % If the flags say symbolic, and the font doesn't have a symbol cmap % and we have an Encoding, treat it as non-symbolic @@ -1853,7 +1836,20 @@ currentdict /postalias undef % Finally, if none of that works, remove the Encoding, and treat it % as non-symbolic. is_symbolic { - <00030000> .findcmap { //true } { prebuilt_encoding //null eq { <00010000> .findcmap}{//false}ifelse } ifelse { + <00030000> .findcmap + { //true } + { + prebuilt_encoding //null eq { + <00030001> .findcmap + {//true} + {<00010000> .findcmap} + ifelse + } + {//false} + ifelse + } ifelse + + { .pdfmapsymbolic /prebuilt_encoding //null def //false |