|
Line 0
Link Here
|
|
|
1 |
%! |
| 2 |
% |
| 3 |
% Developed by AXE,Inc., BBR Inc. and Turbolinux Inc. |
| 4 |
% under the technical advice by suzuki toshiya (Hiroshima University) |
| 5 |
% For questions, please send mail to espgs8-cjk@printing-japan.org |
| 6 |
% |
| 7 |
% (C) Copyright 2006 Center of the International Cooperation for |
| 8 |
% Computerization |
| 9 |
% |
| 10 |
% |
| 11 |
% Based on gs-cjk patches |
| 12 |
% Copyright (C) 2001-2003 gs-cjk project: |
| 13 |
% Taiji Yamada, Hideyuki Suzuki, Masatake Yamato and suzuki toshiya. |
| 14 |
% Enhancements by Akira Tagoh and Taiji Yamada, 2005. |
| 15 |
% All rights reserved. |
| 16 |
% |
| 17 |
% |
| 18 |
% Based on GNU Ghostscript 7.07 and 8.15 |
| 19 |
% Copyright (C) 1996-2003 artofcode LLC. All rights reserved. |
| 20 |
% |
| 21 |
% This software is provided AS-IS with no warranty, either express or |
| 22 |
% implied. |
| 23 |
% |
| 24 |
% |
| 25 |
% This program is free software; you can redistribute it and/or |
| 26 |
% modify it under the terms of the GNU General Public License as |
| 27 |
% published by the Free Software Foundation; either version 2 of |
| 28 |
% the License, or (at your option) any later version. |
| 29 |
% |
| 30 |
% This program is distributed in the hope that it will be useful, |
| 31 |
% but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 32 |
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 33 |
% See the GNU General Public License for more details. |
| 34 |
% |
| 35 |
% You should have received a copy of the GNU General Public License |
| 36 |
% along with this program; if not, write to the Free Software Foundation, |
| 37 |
% Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 38 |
% |
| 39 |
|
| 40 |
|
| 41 |
[ |
| 42 |
/CJKV_DEBUG_TT11 |
| 43 |
/CJKV_DEBUG_OS2 |
| 44 |
/CJKV_DEBUG_GSUB |
| 45 |
] {dup where {pop pop} { currentdict exch false def pop } ifelse} forall |
| 46 |
|
| 47 |
% ---------------- CIDFontType 2 font loading ---------------- % |
| 48 |
|
| 49 |
/_cjkv_type11_tmp 15 dict def |
| 50 |
|
| 51 |
/_cjkv_type11_util 30 dict dup begin |
| 52 |
|
| 53 |
% Create a string with array of CIDs |
| 54 |
% [ <cid1> ... <cidN> ] .cjkv_makecidmapstring <string> |
| 55 |
/.cjkv_makecidmapstring { |
| 56 |
CJKV_DEBUG_TT11 { (.cjkv_makecidmapstring\n) print flush } if |
| 57 |
mark exch cvx exec counttomark % mark 1..N len |
| 58 |
dup 2 mul string % mark 1..N len s |
| 59 |
dup 3 -1 roll 1 sub 2 mul -2 0 { % mark 1..N s s |
| 60 |
2 copy 5 index -8 bitshift put % mark 1..N s s j2 |
| 61 |
1 add 4 -1 roll 16#ff and put dup % mark 1..N-1 s s |
| 62 |
} for pop % mark s |
| 63 |
exch pop % s |
| 64 |
} bind def |
| 65 |
|
| 66 |
% Create a string or an array of strings with array of CIDs |
| 67 |
% [ <cid1> ... <cidN> ] .makecidmap <string>|[<string> ...] |
| 68 |
% written by Taiji Yamada <taiji@aihara.co.jp> |
| 69 |
/.cjkv_makecidmap { |
| 70 |
CJKV_DEBUG_TT11 { (.cjkv_makecidmap\n) print flush } if |
| 71 |
dup length maxstring le { |
| 72 |
_cjkv_type11_util /.cjkv_makecidmapstring get exec |
| 73 |
} { |
| 74 |
dup length dup maxstring idiv exch |
| 75 |
maxstring mod 0 ne { 1 add } if array exch |
| 76 |
0 1 3 index length 1 sub { |
| 77 |
dup maxstring mul 1 index 1 add maxstring mul |
| 78 |
3 index length .min 1 index sub |
| 79 |
3 index 3 1 roll getinterval |
| 80 |
_cjkv_type11_util /.cjkv_makecidmapstring get exec |
| 81 |
3 index 3 1 roll put |
| 82 |
} for pop |
| 83 |
} ifelse |
| 84 |
} bind def |
| 85 |
|
| 86 |
% <file> .cjkv_loadttcidfont <cidtype2font> |
| 87 |
/.cjkv_loadttcidfont { |
| 88 |
CJKV_DEBUG_TT11 { (+++ .cjkv_loadttcidfont\n) print flush } if |
| 89 |
_cjkv_type42_util /.cjkv_loadttfonttables get exec |
| 90 |
.cjkv_makesfnts |
| 91 |
% CIDFontType2 fonts don't have a cmap: they are indexed by CID. |
| 92 |
/.cjkv_ttencmapproc false def |
| 93 |
mark |
| 94 |
CJKV_DEBUG_TT11 { (+++ mark ok\n) print flush } if |
| 95 |
.cjkv_ttkeys |
| 96 |
CJKV_DEBUG_TT11 { (+++ .cjkv_ttkeys finished\n) print flush } if |
| 97 |
.cjkv_definettcidfont |
| 98 |
CJKV_DEBUG_TT11 { (+++ .cjkv_definettcidfont finished\n) print flush } if |
| 99 |
} bind def |
| 100 |
|
| 101 |
% - .getgsub - |
| 102 |
% Defines gsubh, gsubv, gsubh2v and also defines gsubver, gsubfmt |
| 103 |
% in the case that GSUB table has 'Single Substitution Format 2' |
| 104 |
% which is formally used for vertically oriented glyphs such as CJK fonts. |
| 105 |
% Written by Hideyuki Suzuki <hideyuki@sat.t.u-tokyo.ac.jp> |
| 106 |
% Modified by Taiji Yamada <taiji@aihara.co.jp> |
| 107 |
% |
| 108 |
% [GSUB - The Glyph Substitution Table] |
| 109 |
% Index Size Type Name of Entry |
| 110 |
% ----------------------------------- |
| 111 |
% 0 4 Fixed Version |
| 112 |
% 4 2 Offset ScriptList |
| 113 |
% 6 2 Offset FeatureList |
| 114 |
% 8 2 Offset LookupList |
| 115 |
% |
| 116 |
% [Single Substitution Format 2, Subtable at LookupList] |
| 117 |
% Index Size Type Name of Entry |
| 118 |
% ----------------------------------- |
| 119 |
% 0 2 uint16 SubstFormat |
| 120 |
% 4 2 Offset Coverage(--) |
| 121 |
% 6 2 uint16 GlyphCount |
| 122 |
% 8 2 GlyphID Substitute(vertically oriented glyphs) |
| 123 |
% -- 2 uint16 SubstFormat |
| 124 |
% +2 2 uint16 GlyphCount(same as above GlyphCount) |
| 125 |
% +4 2 GlyphID GlyphArray(horizontally oriented glyphs) |
| 126 |
% ----------------------------------- |
| 127 |
% References |
| 128 |
% 1. http://www.microsoft.com/typography/OTSPEC/gsub.htm |
| 129 |
% |
| 130 |
/.cjkv_getgsub { |
| 131 |
CJKV_DEBUG_TT11 { (*** getgsub start\n) print } if |
| 132 |
_cjkv_type11_tmp /gsubhog null put |
| 133 |
_cjkv_type11_tmp /gsubvog null put |
| 134 |
_cjkv_type11_tmp /gsubh2v null put |
| 135 |
tabdict /GSUB .knownget { % if |
| 136 |
CJKV_DEBUG_TT11 { (*** GSUB is known\n) print } if |
| 137 |
dup /gsubver exch 0 .cjkv_getu32 _cjkv_type11_tmp 3 1 roll put |
| 138 |
% dup /gsubosl exch 4 .cjkv_getu16 _cjkv_type11_tmp 3 1 roll put |
| 139 |
% dup /gsubofl exch 6 .cjkv_getu16 _cjkv_type11_tmp 3 1 roll put |
| 140 |
dup /gsuboll exch 8 .cjkv_getu16 _cjkv_type11_tmp 3 1 roll put |
| 141 |
CJKV_DEBUG_GSUB { |
| 142 |
(gsubver: ) print _cjkv_type11_tmp /gsubver get = |
| 143 |
% (gsubosl: ) print _cjkv_type11_tmp /gsubosl get = |
| 144 |
% (gsubofl: ) print _cjkv_type11_tmp /gsubofl get = |
| 145 |
(gsuboll: ) print _cjkv_type11_tmp /gsuboll get = |
| 146 |
} if |
| 147 |
% dup /gsubfmt exch _cjkv_type11_tmp /gsuboll get 0 add .cjkv_getu16 _cjkv_type11_tmp 3 1 roll put |
| 148 |
dup /gsublc exch _cjkv_type11_tmp /gsuboll get 0 add .cjkv_getu16 _cjkv_type11_tmp 3 1 roll put |
| 149 |
CJKV_DEBUG_GSUB { |
| 150 |
(gsublc: ) print _cjkv_type11_tmp /gsublc get = |
| 151 |
% (gsubfmt: ) print _cjkv_type11_tmp /gsubfmt get = |
| 152 |
} if |
| 153 |
_cjkv_type11_tmp /gsublc get 0 ne { |
| 154 |
0 1 _cjkv_type11_tmp /gsublc get 1 sub { |
| 155 |
2 mul /gsubolt exch 2 index exch _cjkv_type11_tmp /gsuboll get 2 add add .cjkv_getu16 _cjkv_type11_tmp /gsuboll get add _cjkv_type11_tmp 3 1 roll put |
| 156 |
dup /gsubltype exch _cjkv_type11_tmp /gsubolt get 0 add .cjkv_getu16 _cjkv_type11_tmp 3 1 roll put |
| 157 |
dup /gsublflag exch _cjkv_type11_tmp /gsubolt get 2 add .cjkv_getu16 _cjkv_type11_tmp 3 1 roll put |
| 158 |
dup /gsubsubc exch _cjkv_type11_tmp /gsubolt get 4 add .cjkv_getu16 _cjkv_type11_tmp 3 1 roll put |
| 159 |
CJKV_DEBUG_GSUB { |
| 160 |
(gsubolt: ) print _cjkv_type11_tmp /gsubolt get = |
| 161 |
(gsubltype: ) print _cjkv_type11_tmp /gsubltype get = |
| 162 |
(gsublflag: ) print _cjkv_type11_tmp /gsublflag get = |
| 163 |
(gsubsubc: ) print _cjkv_type11_tmp /gsubsubc get = |
| 164 |
} if |
| 165 |
_cjkv_type11_tmp /gsubsubc get 0 ne { |
| 166 |
0 1 _cjkv_type11_tmp /gsubsubc get 1 sub { |
| 167 |
2 mul /gsubost exch 2 index exch _cjkv_type11_tmp /gsubolt get 6 add add .cjkv_getu16 _cjkv_type11_tmp /gsubolt get add _cjkv_type11_tmp 3 1 roll put |
| 168 |
dup /substfmt exch _cjkv_type11_tmp /gsubost get 0 add .cjkv_getu16 _cjkv_type11_tmp 3 1 roll put |
| 169 |
CJKV_DEBUG_GSUB { |
| 170 |
(gsubost: ) print _cjkv_type11_tmp /gsubost get = |
| 171 |
(substfmt: ) print _cjkv_type11_tmp /substfmt get = |
| 172 |
} if |
| 173 |
% _cjkv_type11_tmp /gsubver get 16#00010000 eq { % ifelse |
| 174 |
_cjkv_type11_tmp /gsubltype get 1 eq _cjkv_type11_tmp /substfmt get 2 eq and { % ifelse |
| 175 |
dup /gsubocv exch _cjkv_type11_tmp /gsubost get 2 add .cjkv_getu16 _cjkv_type11_tmp 3 1 roll put |
| 176 |
dup /gsubglc exch _cjkv_type11_tmp /gsubost get 4 add .cjkv_getu16 _cjkv_type11_tmp 3 1 roll put |
| 177 |
% hacked by suzuki toshiya at 2001/3/6 |
| 178 |
%dup /gsubvog exch _cjkv_type11_tmp /gsubost get 6 add _cjkv_type11_tmp /gsubglc get getinterval _cjkv_type11_tmp 3 1 roll put |
| 179 |
%dup /gsubhog exch _cjkv_type11_tmp /gsubost get _cjkv_type11_tmp /gsubocv get add 4 add _cjkv_type11_tmp /gsubglc get getinterval _cjkv_type11_tmp 3 1 roll put |
| 180 |
dup /gsubvog exch _cjkv_type11_tmp /gsubost get 6 add _cjkv_type11_tmp /gsubglc get 2 mul getinterval _cjkv_type11_tmp 3 1 roll put |
| 181 |
dup /cvfmt exch _cjkv_type11_tmp /gsubost get _cjkv_type11_tmp /gsubocv get add 0 add .cjkv_getu16 _cjkv_type11_tmp 3 1 roll put |
| 182 |
dup /cvglc exch _cjkv_type11_tmp /gsubost get _cjkv_type11_tmp /gsubocv get add 2 add .cjkv_getu16 _cjkv_type11_tmp 3 1 roll put |
| 183 |
dup /gsubhog exch _cjkv_type11_tmp /gsubost get _cjkv_type11_tmp /gsubocv get add 4 add _cjkv_type11_tmp /cvglc get 2 mul getinterval _cjkv_type11_tmp 3 1 roll put |
| 184 |
CJKV_DEBUG_GSUB { |
| 185 |
(gsubocv: ) print _cjkv_type11_tmp /gsubocv get = |
| 186 |
(gsubglc: ) print _cjkv_type11_tmp /gsubglc get = |
| 187 |
(cvfmt: ) print _cjkv_type11_tmp /cvfmt get = |
| 188 |
|
| 189 |
(gsubhog->gsubvog ) = |
| 190 |
0 2 _cjkv_type11_tmp /gsubhog get length 2 sub { % for |
| 191 |
dup |
| 192 |
_cjkv_type11_tmp /gsubhog get exch .cjkv_getu16 =only |
| 193 |
(->) =only |
| 194 |
_cjkv_type11_tmp /gsubvog get exch .cjkv_getu16 = |
| 195 |
} for |
| 196 |
} if |
| 197 |
_cjkv_type11_tmp /cvfmt get 1 eq { |
| 198 |
/gsubh2v << 0 2 _cjkv_type11_tmp /gsubhog get length 2 sub { |
| 199 |
dup _cjkv_type11_tmp /gsubhog get exch .cjkv_getu16 |
| 200 |
exch _cjkv_type11_tmp /gsubvog get exch .cjkv_getu16 |
| 201 |
} for >> _cjkv_type11_tmp 3 1 roll put |
| 202 |
} { |
| 203 |
_cjkv_type11_tmp /cvfmt get 2 eq { |
| 204 |
/gsubh2v << 0 6 _cjkv_type11_tmp /gsubhog get length 6 sub { |
| 205 |
dup 0 add /fgid exch _cjkv_type11_tmp /gsubhog get exch .cjkv_getu16 _cjkv_type11_tmp 3 1 roll put |
| 206 |
dup 2 add /lgid exch _cjkv_type11_tmp /gsubhog get exch .cjkv_getu16 _cjkv_type11_tmp 3 1 roll put |
| 207 |
4 add /cvidx exch _cjkv_type11_tmp /gsubhog get exch .cjkv_getu16 _cjkv_type11_tmp 3 1 roll put |
| 208 |
CJKV_DEBUG_GSUB { |
| 209 |
(fgid: ) print _cjkv_type11_tmp /fgid get = |
| 210 |
(lgid: ) print _cjkv_type11_tmp /lgid get = |
| 211 |
(cvidx: ) print _cjkv_type11_tmp /cvidx get = |
| 212 |
} if |
| 213 |
_cjkv_type11_tmp /fgid get 1 _cjkv_type11_tmp /lgid get { |
| 214 |
dup _cjkv_type11_tmp /cvidx get add _cjkv_type11_tmp /fgid get sub |
| 215 |
exch _cjkv_type11_tmp /gsubvog get exch .cjkv_getu16 |
| 216 |
} for |
| 217 |
} for >> _cjkv_type11_tmp 3 1 roll put |
| 218 |
} { |
| 219 |
%(UNKNWON COVERAGE FORMAT.) = flush |
| 220 |
} ifelse |
| 221 |
} ifelse |
| 222 |
} { |
| 223 |
%(UNKNOWN GSUB FORMAT.) = flush |
| 224 |
} ifelse |
| 225 |
% } { |
| 226 |
% (ILLEGAL GSUB VERSION.) = flush |
| 227 |
% } ifelse |
| 228 |
} for |
| 229 |
} if |
| 230 |
} for |
| 231 |
} if |
| 232 |
pop |
| 233 |
} if |
| 234 |
} bind def |
| 235 |
|
| 236 |
% glyphid .gsublookup glyphid |
| 237 |
% Lookup substitute table. return the origin if not found. |
| 238 |
% modified by Taiji Yamada <taiji@aihara.co.jp> and Hideyuki Suzuki |
| 239 |
/.gsublookup { |
| 240 |
CJKV_DEBUG_TT11 { (.gsublookup\n) print flush } if |
| 241 |
dup _cjkv_type11_tmp /gsubh2v get exch .knownget { exch pop } if |
| 242 |
} bind def |
| 243 |
|
| 244 |
% - .cjkv_getos2 - |
| 245 |
% Defines os2ver, os2cp1, os2cp2 |
| 246 |
% to detect the kind of CID with the OS/2 table of a TrueType font. |
| 247 |
% Written by Taiji Yamada <taiji@aihara.co.jp> |
| 248 |
% |
| 249 |
% [OS/2 - OS/2 and Windows Metrics] |
| 250 |
% Index Size Type Name of Entry |
| 251 |
% ----------------------------------- |
| 252 |
% 0 2 USHORT version |
| 253 |
% 2 2 SHORT xAvgCharWidth |
| 254 |
% 4 2 USHORT usWeightClass |
| 255 |
% 6 2 USHORT usWidthClass |
| 256 |
% 8 2 SHORT fsType |
| 257 |
% 10 2 SHORT ySubscriptXSize |
| 258 |
% 12 2 SHORT ySubscriptYSize |
| 259 |
% 14 2 SHORT ySubscriptXOffset |
| 260 |
% 16 2 SHORT ySubscriptYOffset |
| 261 |
% 18 2 SHORT ySuperscriptXSize |
| 262 |
% 20 2 SHORT ySuperscriptYSize |
| 263 |
% 22 2 SHORT ySuperscriptXOffset |
| 264 |
% 24 2 SHORT ySuperscriptYOffset |
| 265 |
% 26 2 SHORT yStrikeoutSize |
| 266 |
% 28 2 SHORT yStrikeoutPosition |
| 267 |
% 30 2 SHORT sFamilyClass |
| 268 |
% 32 10 BYTE panose[10] |
| 269 |
% 42 4 ULONG ulUnicodeRange1 |
| 270 |
% 46 4 ULONG ulUnicodeRange2 |
| 271 |
% 50 4 ULONG ulUnicodeRange3 |
| 272 |
% 54 4 ULONG ulUnicodeRange4 |
| 273 |
% 58 4 CHAR achVendID[4] |
| 274 |
% 62 2 USHORT fsSelection |
| 275 |
% 64 2 USHORT usFirstCharIndex |
| 276 |
% 66 2 USHORT usLastCharIndex |
| 277 |
% 68 2 SHORT sTypoAscender |
| 278 |
% 70 2 SHORT sTypoDescender |
| 279 |
% 72 2 SHORT sTypoLineGap |
| 280 |
% 74 2 USHORT usWinAscent |
| 281 |
% 76 2 USHORT usWinDescent |
| 282 |
% 78 4 ULONG ulCodePageRange1 |
| 283 |
% 82 4 ULONG ulCodePageRange2 |
| 284 |
% 86 2 SHORT sxHeight |
| 285 |
% 88 2 SHORT sCapHeight |
| 286 |
% 90 2 USHORT usDefaultChar |
| 287 |
% 92 2 USHORT usBreakChar |
| 288 |
% 94 2 USHORT usMaxContext |
| 289 |
% ----------------------------------- |
| 290 |
% References |
| 291 |
% 1. http://www.microsoft.com/typography/OTSPEC/os2.htm |
| 292 |
% |
| 293 |
/.cjkv_getos2 { |
| 294 |
CJKV_DEBUG_TT11 { (.cjkv_getos2\n) print flush } if |
| 295 |
/os2ver 0 def |
| 296 |
tabdict (OS/2) cvn .knownget { % if |
| 297 |
dup /os2ver exch 0 .cjkv_getu16 def |
| 298 |
os2ver 0 gt { % if |
| 299 |
%dup /os2typ exch 8 .cjkv_gets16 def |
| 300 |
%dup /os2fam exch 30 .cjkv_gets16 def |
| 301 |
dup /os2ur1 exch 42 .cjkv_getu32 def |
| 302 |
dup /os2ur2 exch 46 .cjkv_getu32 def |
| 303 |
dup /os2ur3 exch 50 .cjkv_getu32 def |
| 304 |
dup /os2ur4 exch 54 .cjkv_getu32 def |
| 305 |
%dup /os2sel exch 62 .cjkv_getu16 def |
| 306 |
%dup /os2fci exch 64 .cjkv_getu16 def |
| 307 |
%dup /os2lci exch 64 .cjkv_getu16 def |
| 308 |
dup /os2cp1 exch 78 .cjkv_getu32 def |
| 309 |
dup /os2cp2 exch 82 .cjkv_getu32 def |
| 310 |
CJKV_DEBUG_OS2 { |
| 311 |
/tmp 64 string def |
| 312 |
(os2ver: ) print os2ver 2 tmp cvrs = |
| 313 |
%(os2typ: ) print os2typ 2 tmp cvrs = |
| 314 |
%(os2fam: ) print os2fam 2 tmp cvrs = |
| 315 |
(os2ur1: ) print os2ur1 2 tmp cvrs = |
| 316 |
(os2ur2: ) print os2ur2 2 tmp cvrs = |
| 317 |
(os2ur3: ) print os2ur3 2 tmp cvrs = |
| 318 |
(os2ur4: ) print os2ur4 2 tmp cvrs = |
| 319 |
%(os2sel: ) print os2sel 2 tmp cvrs = |
| 320 |
%(os2fci: ) print os2fci 2 tmp cvrs = |
| 321 |
%(os2lci: ) print os2lci 2 tmp cvrs = |
| 322 |
(os2cp1: ) print os2cp1 2 tmp cvrs = |
| 323 |
(os2cp2: ) print os2cp2 2 tmp cvrs = |
| 324 |
[ |
| 325 |
[ 1 0 bitshift (Latin 1) ] |
| 326 |
[ 1 1 bitshift (Latin 2) ] |
| 327 |
[ 1 2 bitshift (Cyrillic) ] |
| 328 |
[ 1 3 bitshift (Greek) ] |
| 329 |
[ 1 4 bitshift (Turkish) ] |
| 330 |
[ 1 5 bitshift (Hebrew) ] |
| 331 |
[ 1 6 bitshift (Arabic) ] |
| 332 |
[ 1 7 bitshift (Baltic) ] |
| 333 |
[ 1 8 bitshift (Vietnamese) ] |
| 334 |
[ 1 16 bitshift (Thai) ] |
| 335 |
[ 1 17 bitshift (Japanese) ] |
| 336 |
[ 1 18 bitshift (Simplified Chinese) ] |
| 337 |
[ 1 19 bitshift (Korean Wansung) ] |
| 338 |
[ 1 20 bitshift (Traditional Chinese) ] |
| 339 |
[ 1 21 bitshift (Korean Johab) ] |
| 340 |
[ 1 31 bitshift (Symbol) ] |
| 341 |
] { % forall |
| 342 |
dup 0 get os2cp1 and 0 gt { % if |
| 343 |
(CodePage: ) print 1 get = |
| 344 |
} { |
| 345 |
pop |
| 346 |
} ifelse |
| 347 |
} forall |
| 348 |
} if |
| 349 |
} if |
| 350 |
pop |
| 351 |
} if |
| 352 |
} bind def |
| 353 |
|
| 354 |
% ---------------- CJK TrueType font loading ---------------- % |
| 355 |
|
| 356 |
% Written by the gs-cjk project |
| 357 |
|
| 358 |
% .parsecmap |
| 359 |
% push an array as a result of reading a CMap file. |
| 360 |
% the array is of the following form. |
| 361 |
% [ [ [ dst src num ] [ dst src num ] ... [ dst src num ] ] |
| 362 |
% [ [ dst src num ] [ dst src num ] ... [ dst src num ] ] |
| 363 |
% ... |
| 364 |
% [ [ dst src num ] [ dst src num ] ... [ dst src num ] ] ] |
| 365 |
% each array [dst src num] corresponds to each line within |
| 366 |
% /begin{bf,cid}{char,range}/end{bf,cid}{char,range} pairs. |
| 367 |
|
| 368 |
/.parsecmapdict mark |
| 369 |
|
| 370 |
CJKV_DEBUG_TT11 { (.parsecmapdict\n) print flush } if |
| 371 |
% override system operators |
| 372 |
/findresource { pop } bind |
| 373 |
/defineresource { pop pop } bind |
| 374 |
/dict {} |
| 375 |
/def { pop pop } bind |
| 376 |
/dup null |
| 377 |
/begin { pop } bind |
| 378 |
/end {} |
| 379 |
/currentdict null |
| 380 |
|
| 381 |
% override CMap operators |
| 382 |
/usecmap { pop } bind |
| 383 |
/CMapName null |
| 384 |
/begincmap { [ } bind |
| 385 |
/endcmap { ] } bind |
| 386 |
/begincodespacerange { pop mark } bind |
| 387 |
/endcodespacerange { cleartomark } bind |
| 388 |
/beginnotdefrange { pop mark } bind |
| 389 |
/endnotdefrange { cleartomark } bind |
| 390 |
/beginbfchar { /parsecmapcounter exch def } bind % for FromCID CMaps |
| 391 |
/endbfchar { |
| 392 |
parsecmapcounter dup array exch 1 sub -1 0 { |
| 393 |
[ 5 3 roll exch .cjkv_strtoint 1 ] |
| 394 |
2 index 3 1 roll put |
| 395 |
} for |
| 396 |
} bind |
| 397 |
/beginbfrange { begincidrange } % for FromCID CMaps |
| 398 |
/endbfrange { endcidrange } |
| 399 |
/begincidchar { beginbfchar } % for ToCID CMaps |
| 400 |
/endcidchar { endbfchar } |
| 401 |
/begincidrange { /parsecmapcounter exch def } bind % for ToCID CMaps |
| 402 |
/endcidrange { |
| 403 |
parsecmapcounter dup array exch 1 sub -1 0 { |
| 404 |
[ 6 3 roll 3 1 roll .cjkv_strtoint exch .cjkv_strtoint exch 1 index sub 1 add ] |
| 405 |
2 index 3 1 roll put |
| 406 |
} for |
| 407 |
} bind |
| 408 |
|
| 409 |
% misc |
| 410 |
/parsecmapcounter 0 |
| 411 |
|
| 412 |
.dicttomark def % .parsecmapdict |
| 413 |
|
| 414 |
|
| 415 |
/.parsecmapfname 100 string def |
| 416 |
|
| 417 |
% <CMapName> .parsecmap <array> |
| 418 |
% Return the contents of the CMap. If the CMap is not found, empty array |
| 419 |
% is returned. Note that usecmap is ignored because of efficiency. |
| 420 |
/.parsecmap { |
| 421 |
CJKV_DEBUG_TT11 { (.parsecmap\n) print flush } if |
| 422 |
/CMap /Category findresource begin |
| 423 |
//.parsecmapfname ResourceFileName end % filename |
| 424 |
dup status { |
| 425 |
pop pop pop pop |
| 426 |
_cjkv_type11_util /.parsecmapdict get begin run end |
| 427 |
} { |
| 428 |
pop [] |
| 429 |
} ifelse |
| 430 |
} bind def |
| 431 |
|
| 432 |
% .cjkv_buildcmaptab |
| 433 |
% construct a cmap table using information obtained from horizontal/vertical |
| 434 |
% CMaps, ToUnicode CMap, and substition data. |
| 435 |
|
| 436 |
% cmap /CMap proc .applyCMap cmap |
| 437 |
/.applyCMap { |
| 438 |
CJKV_DEBUG_TT11 { (.applyCMap\n) print flush } if |
| 439 |
exch _cjkv_type11_util /.parsecmap get exec % {} [[[].].] |
| 440 |
dup length 1 sub -1 0 { % {} [[[].].] len-1 -1 0 {} for |
| 441 |
1 index exch get % {} [[[].].] [[].] |
| 442 |
dup length 1 sub -1 0 { % {} [[[].].] [[].] len-1 -1 0 for {} |
| 443 |
1 index exch get % {} [[[].].] [[].] [ cid gid num ] |
| 444 |
cvx exec cmapglyphs % {} [[[].].] [[].] cid gid num gmap |
| 445 |
3 1 roll .cjkv_safegetinterval { % {} [[[].].] [[].] cid [gid'..] |
| 446 |
4 index exec dup cmapglyphs 0 get eq 1 index 0 eq or { |
| 447 |
% found no glyph |
| 448 |
pop |
| 449 |
} { |
| 450 |
% found a glyph |
| 451 |
5 index exch 2 index exch .cjkv_safeput |
| 452 |
} ifelse |
| 453 |
1 add % {} [[[].].] [[].] cid++ |
| 454 |
} forall pop |
| 455 |
} for % {} [[[].].] [[].] |
| 456 |
pop % {} [[[].].] |
| 457 |
} for % {} [[[].].] |
| 458 |
pop pop % |
| 459 |
} bind def |
| 460 |
|
| 461 |
% cmap /CMap-V .applyvCMap cmap |
| 462 |
/.applyvCMap { |
| 463 |
CJKV_DEBUG_TT11 { (.applyvCMap\n) print flush } if |
| 464 |
_cjkv_type11_tmp /gsubh2v get null ne { |
| 465 |
{ _cjkv_type11_util /.gsublookup get exec } _cjkv_type11_util /.applyCMap get exec |
| 466 |
} { |
| 467 |
{ } _cjkv_type11_util /.applyCMap get exec |
| 468 |
} ifelse |
| 469 |
} bind def |
| 470 |
|
| 471 |
% cmap /CMap-H .applyhCMap cmap |
| 472 |
/.applyhCMap { |
| 473 |
CJKV_DEBUG_TT11 { (.applyhCMap\n) print flush } if |
| 474 |
{ } _cjkv_type11_util /.applyCMap get exec |
| 475 |
} bind def |
| 476 |
|
| 477 |
% cmap /CMap-V .applyvCMapUnicode cmap |
| 478 |
/.applyvCMapUnicode { |
| 479 |
CJKV_DEBUG_TT11 { (.applyvCMapUnicode\n) print flush } if |
| 480 |
_cjkv_type11_tmp /gsubh2v get null ne { |
| 481 |
{ |
| 482 |
dup 16#f900 ge |
| 483 |
1 index 16#ff00 ge 2 index 16#ff9f le and not |
| 484 |
and not { |
| 485 |
_cjkv_type11_util /.gsublookup get exec |
| 486 |
} if |
| 487 |
} bind _cjkv_type11_util /.applyCMap get exec |
| 488 |
} { |
| 489 |
{ } _cjkv_type11_util /.applyCMap get exec |
| 490 |
} ifelse |
| 491 |
} bind def |
| 492 |
|
| 493 |
% cmap /Adobe-*-* .applyCIDToCode cmap |
| 494 |
/.applyCIDToCode { |
| 495 |
CJKV_DEBUG_TT11 { (.applyCIDToCode\n) print flush } if |
| 496 |
_cjkv_type11_util /.parsecmap get exec |
| 497 |
{ |
| 498 |
{ % cmap [ dist cid num ] |
| 499 |
dup 0 get length 2 gt { % multi-byte dist is not supported yet. |
| 500 |
pop |
| 501 |
} { |
| 502 |
cvx exec exch % cmap dist num cid |
| 503 |
cmapglyphs 4 2 roll % cmap cid cmapglyphs dist num |
| 504 |
exch .cjkv_strtoint exch |
| 505 |
.cjkv_safegetinterval % cmap cid subcmapglyphs |
| 506 |
{ % cmap cid gid |
| 507 |
2 index 2 index % cmap cid gid cmap cid |
| 508 |
3 2 roll % cmap cid cmap cid gid |
| 509 |
.cjkv_safeput % cmap cid |
| 510 |
1 add % cmap nextcid |
| 511 |
} forall pop |
| 512 |
} ifelse |
| 513 |
} forall |
| 514 |
} forall |
| 515 |
} bind def |
| 516 |
|
| 517 |
% cmap /Adobe-*-UCS2 .applyCIDToUnicode cmap |
| 518 |
/.applyCIDToUnicode { |
| 519 |
CJKV_DEBUG_TT11 { (.applyCIDToUnicode\n) print flush } if |
| 520 |
_cjkv_type11_util /.parsecmap get exec |
| 521 |
{ |
| 522 |
{ % cmap [ distuni cid num ] |
| 523 |
dup 0 get length 2 gt % multi-byte dist is not supported yet. |
| 524 |
1 index 0 get <fffd> eq % the value <fffd> is regard as undefined code. |
| 525 |
or { |
| 526 |
pop |
| 527 |
} { |
| 528 |
cvx exec exch % cmap distuni num cid |
| 529 |
cmapglyphs 4 2 roll % cmap cid cmapglyphs distuni num |
| 530 |
exch .cjkv_strtoint exch % cmap cid cmapglyphs distuni num |
| 531 |
.cjkv_safegetinterval % cmap cid subcmapglyphs |
| 532 |
{ % cmap cid gid |
| 533 |
2 index 2 index % cmap cid gid cmap cid |
| 534 |
3 2 roll % cmap cid cmap cid gid |
| 535 |
.cjkv_safeput % cmap cid |
| 536 |
1 add % cmap nextcid |
| 537 |
} forall pop |
| 538 |
} ifelse |
| 539 |
} forall |
| 540 |
} forall |
| 541 |
} bind def |
| 542 |
|
| 543 |
/.cjkv_buildcmapdict mark |
| 544 |
/Adobe-CNS1 << |
| 545 |
/Registry (Adobe) |
| 546 |
/Ordering (CNS1) |
| 547 |
/CIDCounts [ 14099 17408 17601 18846 18962 ] |
| 548 |
/Big5 { 0 { |
| 549 |
/Adobe-CNS1-ETen-B5 _cjkv_type11_util /.applyCIDToCode get exec |
| 550 |
/ETen-B5-V _cjkv_type11_util /.applyvCMap get exec |
| 551 |
/ETen-B5-H _cjkv_type11_util /.applyhCMap get exec |
| 552 |
} } |
| 553 |
/Unicode { 3 { |
| 554 |
/Adobe-CNS1-UCS2 _cjkv_type11_util /.applyCIDToUnicode get exec |
| 555 |
/UniCNS-UCS2-V _cjkv_type11_util /.applyvCMapUnicode get exec |
| 556 |
/UniCNS-UCS2-H _cjkv_type11_util /.applyhCMap get exec |
| 557 |
} } |
| 558 |
>> |
| 559 |
/Adobe-GB1 << |
| 560 |
/Registry (Adobe) |
| 561 |
/Ordering (GB1) |
| 562 |
/CIDCounts [ 7717 9897 22127 22353 29064 ] |
| 563 |
/PRC { 2 { |
| 564 |
/Adobe-GB1-GBK-EUC _cjkv_type11_util /.applyCIDToCode get exec |
| 565 |
/GBK-EUC-V _cjkv_type11_util /.applyvCMap get exec |
| 566 |
/GBK-EUC-H _cjkv_type11_util /.applyhCMap get exec |
| 567 |
} } |
| 568 |
/Unicode { 4 { |
| 569 |
/Adobe-GB1-UCS2 _cjkv_type11_util /.applyCIDToUnicode get exec |
| 570 |
/UniGB-UCS2-V _cjkv_type11_util /.applyvCMapUnicode get exec |
| 571 |
/UniGB-UCS2-H _cjkv_type11_util /.applyhCMap get exec |
| 572 |
} } |
| 573 |
>> |
| 574 |
/Adobe-Japan1 << |
| 575 |
/Registry (Adobe) |
| 576 |
/Ordering (Japan1) |
| 577 |
/CIDCounts [ 8284 8359 8720 9354 15444 20317 23058 ] |
| 578 |
/ShiftJIS { 2 { |
| 579 |
/Adobe-Japan1-90ms-RKSJ _cjkv_type11_util /.applyCIDToCode get exec |
| 580 |
/90ms-RKSJ-V _cjkv_type11_util /.applyvCMap get exec |
| 581 |
/90ms-RKSJ-H _cjkv_type11_util /.applyhCMap get exec |
| 582 |
} } |
| 583 |
/Unicode { 4 { |
| 584 |
/Adobe-Japan1-UCS2 _cjkv_type11_util /.applyCIDToUnicode get exec |
| 585 |
/UniJIS-UCS2-V _cjkv_type11_util /.applyvCMapUnicode get exec |
| 586 |
/UniJIS-UCS2-H _cjkv_type11_util /.applyhCMap get exec |
| 587 |
} } |
| 588 |
>> |
| 589 |
/Adobe-Japan2 << |
| 590 |
/Registry (Adobe) |
| 591 |
/Ordering (Japan2) |
| 592 |
/CIDCounts [ 6068 ] |
| 593 |
/Unicode { 0 { |
| 594 |
/UniHojo-UCS2-V _cjkv_type11_util /.applyvCMapUnicode get exec |
| 595 |
/UniHojo-UCS2-H _cjkv_type11_util /.applyhCMap get exec |
| 596 |
} } |
| 597 |
>> |
| 598 |
/Adobe-Korea1 << |
| 599 |
/Registry (Adobe) |
| 600 |
/Ordering (Korea1) |
| 601 |
/CIDCounts [ 9333 18155 18352 ] |
| 602 |
/Johab { 1 { |
| 603 |
/KSC-Johab-V _cjkv_type11_util /.applyvCMap get exec |
| 604 |
/KSC-Johab-H _cjkv_type11_util /.applyhCMap get exec |
| 605 |
} } |
| 606 |
/Unicode { 2 { |
| 607 |
/Adobe-Korea1-UCS2 _cjkv_type11_util /.applyCIDToUnicode get exec |
| 608 |
/UniKS-UCS2-V _cjkv_type11_util /.applyvCMapUnicode get exec |
| 609 |
/UniKS-UCS2-H _cjkv_type11_util /.applyhCMap get exec |
| 610 |
} } |
| 611 |
/Wansung { 1 { |
| 612 |
/Adobe-Korea1-KSCms-UHC _cjkv_type11_util /.applyCIDToCode get exec |
| 613 |
/KSCms-UHC-V _cjkv_type11_util /.applyvCMap get exec |
| 614 |
/KSCms-UHC-H _cjkv_type11_util /.applyhCMap get exec |
| 615 |
} } |
| 616 |
>> |
| 617 |
/Identity << % ttcmap ordering CIDMap only for specific and rare CJK TTF |
| 618 |
/Registry (Unregistered) % Thus Registry value is unpredictable. This |
| 619 |
/Ordering (Identity) % CIDFont can be used with Identity-H|V CMap |
| 620 |
/CIDCounts [ 65535 ] |
| 621 |
/H { 0 { |
| 622 |
/Identity-H _cjkv_type11_util /.applyhCMap get exec % for ttcmap-order CIDMap |
| 623 |
} } |
| 624 |
/V { 0 { |
| 625 |
/Identity-H _cjkv_type11_util /.applyvCMap get exec % for ttcmap-order and vertically-used CIDMap |
| 626 |
} } |
| 627 |
>> |
| 628 |
.dicttomark def |
| 629 |
|
| 630 |
/.cjkv_ttencmap << |
| 631 |
/Identity false |
| 632 |
/Auto { |
| 633 |
CJKV_DEBUG_TT11 { (+++ ttencmap->Auto exec\n) print flush } if |
| 634 |
_cjkv_type11_util /.cjkv_ttencoding get exec { |
| 635 |
dup |
| 636 |
_cjkv_type11_util /.cjkv_ttcharset get |
| 637 |
exch get |
| 638 |
CJKV_DEBUG_TT11 { (+++ exec\n) print flush } if |
| 639 |
exec |
| 640 |
CJKV_DEBUG_TT11 { (+++ ok\n) print flush } if |
| 641 |
exch true |
| 642 |
} { |
| 643 |
false |
| 644 |
} ifelse |
| 645 |
} bind |
| 646 |
/Adobe-CNS1 { /Adobe-CNS1 _cjkv_type11_util /.cjkv_ttencoding get exec } |
| 647 |
/Adobe-GB1 { /Adobe-GB1 _cjkv_type11_util /.cjkv_ttencoding get exec } |
| 648 |
/Adobe-Japan1 { /Adobe-Japan1 _cjkv_type11_util /.cjkv_ttencoding get exec } |
| 649 |
/Adobe-Japan2 { /Adobe-Japan2 _cjkv_type11_util /.cjkv_ttencoding get exec } |
| 650 |
/Adobe-Korea1 { /Adobe-Korea1 _cjkv_type11_util /.cjkv_ttencoding get exec } |
| 651 |
/Adobe-CNS1-Big5 { /Adobe-CNS1 /Big5 true } |
| 652 |
/Adobe-CNS1-Unicode { /Adobe-CNS1 /Unicode true } |
| 653 |
/Adobe-GB1-PRC { /Adobe-GB1 /PRC true } |
| 654 |
/Adobe-GB1-Unicode { /Adobe-GB1 /Unicode true } |
| 655 |
/Adobe-Japan1-ShiftJIS { /Adobe-Japan1 /ShiftJIS true } |
| 656 |
/Adobe-Japan1-Unicode { /Adobe-Japan1 /Unicode true } |
| 657 |
/Adobe-Japan2-Unicode { /Adobe-Japan2 /Unicode true } |
| 658 |
/Adobe-Korea1-Johab { /Adobe-Korea1 /Johab true } |
| 659 |
/Adobe-Korea1-Unicode { /Adobe-Korea1 /Unicode true } |
| 660 |
/Adobe-Korea1-Wansung { /Adobe-Korea1 /Wansung true } |
| 661 |
/Identity-H { /Identity /H true } |
| 662 |
/Identity-V { /Identity /V true } |
| 663 |
>> def |
| 664 |
|
| 665 |
/.cjkv_ttcharset << |
| 666 |
/Unicode { _cjkv_type11_util /.cjkv_detectos2 get exec } |
| 667 |
/ShiftJIS /Adobe-Japan1 |
| 668 |
/Big5 /Adobe-CNS1 |
| 669 |
/PRC /Adobe-GB1 |
| 670 |
/Wansung /Adobe-Korea1 |
| 671 |
/Johab /Adobe-Korea1 |
| 672 |
>> def |
| 673 |
|
| 674 |
/.cjkv_ttencdict << |
| 675 |
<00030001> /Unicode |
| 676 |
<00030002> /ShiftJIS |
| 677 |
<00030003> /Big5 |
| 678 |
<00030004> /PRC |
| 679 |
<00030005> /Wansung |
| 680 |
<00030006> /Johab |
| 681 |
>> def |
| 682 |
|
| 683 |
/.cjkv_ttencoding { |
| 684 |
CJKV_DEBUG_TT11 { (.cjkv_ttencoding\n) print flush } if |
| 685 |
_cjkv_type11_util /.cjkv_ttencdict get _cjkv_ttcmap_tmp /cmapsub get 0 4 getinterval .knownget |
| 686 |
} bind def |
| 687 |
|
| 688 |
/.cjkv_ttos2tab [ |
| 689 |
[ 1 20 bitshift /Adobe-CNS1 ] |
| 690 |
[ 1 18 bitshift /Adobe-GB1 ] |
| 691 |
[ 1 17 bitshift /Adobe-Japan1 ] |
| 692 |
[ 1 19 bitshift /Adobe-Korea1 ] |
| 693 |
[ 1 21 bitshift /Adobe-Korea1 ] |
| 694 |
] def |
| 695 |
|
| 696 |
/.cjkv_detectos2 { |
| 697 |
CJKV_DEBUG_TT11 { (.cjkv_detectos2\n) print flush } if |
| 698 |
/Identity % default linear ordering to GID, Adobe Identity CIDs |
| 699 |
os2ver 0 gt { |
| 700 |
_cjkv_type11_util /.cjkv_ttos2tab get { |
| 701 |
dup 0 get os2cp1 and 0 ne { |
| 702 |
1 get exch |
| 703 |
} if pop |
| 704 |
} forall |
| 705 |
} if |
| 706 |
} bind def |
| 707 |
|
| 708 |
end readonly def |