%! /me (alias-cid.ps by Taiji Yamada and gs-cjk project) def % % Usage: % % $ gs [-q] -dNODISPLAY [-dBATCH] \ % [-sOUTPUTDIR=[dir|-|=]] \ % [-soutputdir=[dir|-|=]] \ % [-sRO=Adobe-CNS1|Adobe-GB1|Adobe-Japan1|Adobe-Japan2|Adobe-Korea1|\ % Adobe-Identity] \ % [-dCOMPOSE [-sDELIMITER=--] [-sDOTDELIMITER=.]] \ % -- alias-cid.ps install|uninstall \ % cidfontname |\ % cidfontname=orig_cidfontname |\ % cidfontname=orig_cidfontname,Bold |\ % cidfontname=orig_cidfontname,.05 |\ % cidfontname=orig_cidfontname,Italic |\ % cidfontname=orig_cidfontname,[1,0,.5,1,0,0] |\ % cidfontname=orig_cidfontname,BoldItalic |\ % cidfontname=orig_cidfontname,.05,[1,0,.5,1,0,0] |\ % cidfontname=C:\path_to\filename.ttf |\ % cidfontname=C:\path_to\filename.ttc,2 |\ % cidfontname=C:\path_to\filename.ttc,Adobe-Japan2 |\ % cidfontname=C:\path_to\filename.ttc,2,Adobe-GB1 |\ % cidfontname-Adobe-CNS1=C:\path_to\filename.ttc,2 |\ % cidfontname,Adobe-CNS1=C:\path_to\filename.ttc,2 |\ % cidfontname:=C:\path_to\filename.ttf |\ % cidfontname:=C:\path_to\filename.ttc,2 |\ % cidfontname:=C:\path_to\filename.ttc,Adobe-Japan2 |\ % cidfontname:=C:\path_to\filename.ttc,2,Adobe-GB1 |\ % cidfontname-Adobe-CNS1:=C:\path_to\filename.ttc,2 |\ % cidfontname,Adobe-CNS1:=C:\path_to\filename.ttc,2 |\ % % Requirements: % aliascid.ps % ttcf2cid.ps % ghostscript 6.53 or ghostscript 7.05 % % References: % % [1] http://www.gyve.org/gs-cjk/supplement/ % /unknowndef { exch dup where { pop pop pop } { exch def } ifelse } bind def /UNINSTALL false unknowndef % delete fonts|cidfonts, UNINSTALL mode /RO (Adobe-Identity) unknowndef % Registry and Ordering used at COMPOSE mode /COMPOSE false unknowndef % Font/CIDFontName--CMapName creation mode /concat2strings { % str1 str2 concat2strings str 2 { dup type /stringtype ne { dup length string cvs } if exch } repeat exch dup length 3 2 roll dup length 2 index add string 0 5 1 roll 2 { dup 4 2 roll putinterval } repeat } bind def /concats { % [str ...] concats string () exch dup length 1 sub -1 0 { 1 index exch get 3 -1 roll concat2strings exch } for pop } bind def /cutoutstring { % string i len cutoutstring string 2 index 0 3 index getinterval 3 1 roll add % string pre i+len 2 index length 1 index sub % string pre i+len L-i-len 4 -1 roll 3 1 roll getinterval concat2strings % pre post concat2strings } bind def /insertstring { % str i substr insertstring string [ 3 index 3 index 5 index length 5 index sub getinterval 5 -2 roll 0 exch getinterval 4 -1 roll 3 -1 roll ] concats } bind def /replacestrings { % string [[src1 dst1] ...] replacestrings string 0 { % string [[]..] i 1 2 index { dup 0 get exch 1 get % string [[]..] i d src dst % string [[]..] i d src dst i+sl<=L 3 index 2 index length add 6 index length le { % string [[]..] i d src dst substr=src 5 index 4 index 3 index length getinterval 2 index eq { % string [[]..] i d src dst pre+post % string [[]..] i d src dst pre+dst+post 5 index 4 index 3 index length cutoutstring 4 index 2 index insertstring % pre+dst+post [[]..] i d src dst % pre+dst+post [[]..] i dl-1+d src dst 7 -1 roll pop 6 1 roll dup length 1 sub 4 -1 roll add 3 1 roll pop pop exit } if } if pop pop } forall % string [[]..] i d add dup 3 index length ge { exit } if } loop pop pop % string } bind def % string str headmatch post true % string str headmatch string false /headmatch { search { dup () eq { pop pop true } { exch concat2strings exch concat2strings false } ifelse } { false } ifelse } bind def % string str tailmatch pre true % string str tailmatch string false /tailmatch { 1 index length 1 index length 2 copy sub % S str L l L-l dup 0 gt { 4 index 1 index 3 index getinterval 4 index eq dup 6 1 roll { % S boolean str L l L-l % pre boolean str L l L-l 5 index 0 2 index getinterval 7 -1 roll pop 6 1 roll } if } { false 5 1 roll } ifelse 4 { pop } repeat } bind def /arrayadd { % array any arrayadd array 1 index length 1 add array dup 0 5 -1 roll putinterval dup dup length 1 sub 4 -1 roll put } bind def % % porting alias-cid.sh and cid.sh of gs-cjk into PostScript % /ro RO def [ /ARGUMENTS where { pop ARGUMENTS length 0 gt not { (%stderr) (w) file (Error: Invalid arguments\n) writestring stop } { ARGUMENTS 1 1 index length 1 sub getinterval cvx exec ARGUMENTS 0 get (uninstall) ne { ARGUMENTS 0 get (install) ne { (%stderr) (w) file (Error: Invalid arguments\n) writestring stop } { /UNINSTALL false def } ifelse } { /UNINSTALL true def } ifelse } ifelse } if %(Baekmuk-Batang) % with -dUNINSTALL and/or -dCOMPOSE only %(Batang=Baekmuk-Batang) %(SMGothic-Bold=HYGoThic-Medium,Bold) %(SMGothic-DemiBold=HYGoThic-Medium,.05) %(Gulim-BoldItalic=Gulim,[1,0,.5,1,0,0],.05) %(Gulim=/cygdrive/c/WINDOWS/Fonts/gulim.ttc) %(GulimChe=/cygdrive/c/WINDOWS/Fonts/gulim.ttc,2,Adobe-Korea1) %(Dotum:=/cygdrive/c/WINDOWS/Fonts/gulim.ttc,3) %(DotumChe:=/cygdrive/c/WINDOWS/Fonts/gulim.ttc,4,Adobe-Korea1) %(SimSun-18030-Adobe-CNS1=/cygdrive/c/WINDOWS/Fonts/SimSun18030.ttc) %(NSimSun-18030-Adobe-CNS1=/cygdrive/c/WINDOWS/Fonts/SimSun18030.ttc,2) %(SimSun-18030=/cygdrive/c/WINDOWS/Fonts/SimSun18030.ttc,Adobe-GB1) %(NSimSun-18030:=/cygdrive/c/WINDOWS/Fonts/SimSun18030.ttc,2,Adobe-GB1) %(HeiseiMin-W3,Adobe-Japan1=/cygdrive/c/WINDOWS/Fonts/msmincho.ttc) %(HeiseiMin-W3H,Adobe-Japan2:=/cygdrive/c/WINDOWS/Fonts/msmincho.ttc) %(HeiseiKakuGo-W5,Adobe-Japan1=/cygdrive/c/WINDOWS/Fonts/msgothic.ttc) %(HeiseiKakuGo-W5H,Adobe-Japan2:=/cygdrive/c/WINDOWS/Fonts/msgothic.ttc) %(HGSeikaishotaiPRO:=C:\\WINDOWS\\Fonts\\hgrskp.ttf,Adobe-Japan1-Unicode) %(HGSeikaishotaiPRO-Identity:=C:\\WINDOWS\\Fonts\\hgrskp.ttf) ] { /ARG [] def /ttcf2cid? false def /TTNAME null def /PSNAME null def /FNNAME null def /RO ro def [ [ (=) ( ) ] [ (,) ( ) ] [ ([) ({) ] [ (]) (}) ] [ (/) (\\) ] ] replacestrings { token { dup type /nametype eq { cvlit } if ARG exch arrayadd /ARG exch def } { exit } ifelse } loop ARG length 0 gt { ARG 0 get dup length string cvs (:) tailmatch { ARG 0 3 -1 roll cvn put UNINSTALL not { /ttcf2cid? true def } if } { pop } ifelse << (Adobe-CNS1) { /RO /Adobe-CNS1 def ARG RO arrayadd /ARG exch def } (Adobe-GB1) { /RO /Adobe-GB1 def ARG RO arrayadd /ARG exch def } (Adobe-Japan1) { /RO /Adobe-Japan1 def ARG RO arrayadd /ARG exch def } (Adobe-Japan2) { /RO /Adobe-Japan2 def ARG RO arrayadd /ARG exch def } (Adobe-Korea1) { /RO /Adobe-Korea1 def ARG RO arrayadd /ARG exch def } (Identity) { /RO /Adobe-Identity def ARG /Identity arrayadd /ARG exch def } >> { ARG 0 get dup length string cvs 3 -1 roll tailmatch { pop exec } { pop pop } ifelse } forall ARG length 1 gt { ARG 1 get dup length string cvs (:) tailmatch { ARG 1 3 -1 roll cvn put UNINSTALL not { /ttcf2cid? true def } if } { pop } ifelse << (Adobe-CNS1) { /RO /Adobe-CNS1 def } (Adobe-GB1) { /RO /Adobe-GB1 def } (Adobe-Japan1) { /RO /Adobe-Japan1 def } (Adobe-Japan2) { /RO /Adobe-Japan2 def } (Adobe-Korea1) { /RO /Adobe-Korea1 def } (Identity) { /RO /Adobe-Identity def } >> { ARG 1 get dup length string cvs 3 -1 roll dup length string cvs headmatch { pop exec ARG 1 get ARG 2 1 index length 2 sub getinterval ARG 1 3 -1 roll putinterval ARG dup length 1 sub 3 -1 roll put } { pop pop } ifelse } forall false ARG 1 get dup length string cvs [ (.ttf) (.ttc) (.TTF) (.TTC) ] { 1 index exch tailmatch exch pop { exch pop true exch exit } if } forall exch { ARG 1 3 -1 roll [ [ (\\) (/) ] ] replacestrings put } { pop } ifelse } if } if ttcf2cid? not { /PSNAME ARG cvx def (aliascid.ps) run } { /TTNAME ARG cvx def (ttcf2cid.ps) run COMPOSE { /FNNAME ARG 0 get def (aliascid.ps) run } if } ifelse } forall