1 % Copyright (C) 2004 artofcode LLC. All rights reserved.
3 % This software is provided AS-IS with no warranty, either express or
6 % This software is distributed under license and may not be copied,
7 % modified or distributed except as expressly authorized under the terms
8 % of the license contained in the file LICENSE in this distribution.
10 % For more information about licensing, please refer to
11 % http://www.ghostscript.com/licensing/. For information on
12 % commercial licensing, go to http://www.artifex.com/licensing/ or
13 % contact Artifex Software, Inc., 101 Lucas Valley Road #110,
14 % San Rafael, CA 94903, U.S.A., +1(415)492-9861.
16 % $Id: mkcidfm.ps,v 1.1 2004/11/18 06:48:41 ghostgum Exp $
18 % Generate a cidfmap file for substituting CID fonts with TrueType
19 % fonts, based on fonts found in the directory FONTDIR.
21 % The directory FONTDIR is searched for fonts whose filename
22 % matches a Path in the cidsubs dictionary.
23 % Any matches are written out as a CID font substitution.
25 % For each fontname and alias in the fontaliases dictionary,
26 % write out each alias that matches a substituted font.
27 % Where multiple aliases are possible, use the first match.
29 % Note that the substitutions and aliases in this file were created
30 % by someone who doesn't understand Chinese, Japanese or Korean.
31 % The initial list contains only font files found in Windows XP.
32 % Please submit corrections and additions.
34 % Font filenames must match case.
35 % All font filenames are currently lower case.
37 % Usage: gswin32c -q -dBATCH -sFONTDIR=c:/windows/fonts
38 % -sCIDFMAP=c:/gs/cidfmap mkcidfm.ps
41 systemdict /FONTDIR known not { /FONTDIR (c:/windows/fonts) def } if
43 systemdict /CIDFMAP known { CIDFMAP } { (%stdout) } ifelse
44 /cidfmap exch (w) file def
46 % Directory separator as used by filenameforall
49 % This dictionary contains a list of font substitutions.
50 % The first matching substitution in the array will be used.
54 /MSung-Light [ /MingLiU ]
55 /MSung-Medium [ /MingLiU ]
56 /MHei-Medium [ /MingLiU ]
57 /MKai-Medium [ /Arial-Unicode-MS /MingLiU ]
60 /STSong-Light [ /SimSun ]
61 /STFangsong-Light [ /SimSun ]
62 /STHeiti-Regular [ /SimHei ]
63 /STKaiti-Regular [ /SimHei ]
66 /Ryumin-Light [ /MS-Mincho ]
67 /Ryumin-Medium [ /MS-Mincho ]
68 /GothicBBB-Medium [ /MS-Gothic ]
69 /HeiseiMin-W3 [ /MS-Mincho ]
70 /HeiseiKakuGo-W5 [ /MS-Gothic ]
73 /HYSMyeongJo-Medium [ /Batang ]
74 /HYRGoThic-Medium [ /Gulim ]
75 /HYGoThic-Medium [ /Dotum ]
80 % This dictionary contains a list of CID substitutions
108 % Traditional Chinese
243 % A dictionary for storing the names and paths of found fonts
244 /foundfonts 50 dict def
246 % Get the basename of a path
247 % For example, (c:/windows/fonts/msmincho.ps) --> (msmincho.ps)
248 /basename { % path -- subpath
257 % Check if a font basename matches one of the possible cid substitutions.
258 % If it does, add the font and full path to the foundfonts dictionary
264 2 index eq % Match case only
267 3 index dup length string copy put
278 % Add all matching fonts to foundfonts dictionary
279 /findfonts { % path --
280 dup length 2 add string dup 3 1 roll copy pop
281 dup dup length 2 sub dirsep 0 get put
282 dup dup length 1 sub (*) 0 get put
283 /checkfont load 256 string filenameforall
287 % Write out a cid substition, using the full font path
288 % name is the font name, e.g. /MS-Mincho
289 % path is the full path to the font file, e.g. (c:\windows\fonts\msmincho.ps)
290 % subs is the dictionary for CID font substition, from cidsubs
291 /emitsubs { % name path subs --
292 3 -1 roll cidfmap exch write==only % name
293 cidfmap ( << ) writestring
296 1 index /Path eq {pop 1 index} if % use full path, not basename
297 exch cidfmap exch write==only cidfmap ( ) writestring
298 cidfmap exch write==only cidfmap ( ) writestring
300 cidfmap (>> ;\n) writestring
304 % Write out all known cid substitutions.
306 cidfmap (% Substitutions\n) writestring
309 1 index cidsubs exch known
311 1 index cidsubs exch get % name path subs
322 % Write out aliases for which the cid substituted font exists.
324 cidfmap (\n% Aliases\n) writestring
330 foundfonts 1 index known
332 1 index cidfmap exch write==only cidfmap ( ) writestring
333 cidfmap exch write==only cidfmap ( ;\n) writestring
334 exit % after first match
337 pop % didn't find this name
348 % Write out a new cidfmap file to stdout
349 /writecidfmap { % path --
350 cidfmap (%!\n% cidfmap generated automatically by mkcidfm.ps from fonts found in\n) writestring
351 cidfmap (% ) writestring
352 dup cidfmap exch writestring cidfmap (\n\n) writestring