1 | #!/bin/sh |
---|
2 | # updmap-otf: v0.9.1 |
---|
3 | # 11 Nov 2011 by PREINING Norbert <preining@logic.at> v0.9.1 |
---|
4 | # use kpsewhich for finding fonts |
---|
5 | # use updmap-sys --setoption kanjiEmbed to select the font family |
---|
6 | # use current names of map files |
---|
7 | # use different font name for Kozuka font, as used in the map file |
---|
8 | # get state from updmap.cfg, not from some state file |
---|
9 | # 27 May 2006 by KOBAYASHI R. Taizo <tkoba965@mac.com> v0.9 |
---|
10 | # use noEmbed.map instead of noEmbeddedFont.map |
---|
11 | # 10 Jun 2005 by KOBAYASHI R. Taizo <tkoba965@mac.com> v0.8 |
---|
12 | # modified to use updmap-sys in teTeX3 |
---|
13 | # 07 Nov 2004 by KOBAYASHI R. Taizo <tkoba965@mac.com> v0.7 |
---|
14 | # do not echo back the message of updmap. |
---|
15 | # 17 Oct 2004 by KOBAYASHI R. Taizo <tkoba965@mac.com> v0.6 |
---|
16 | # set hiragino map file if nofont is installed and arg is auto. |
---|
17 | # 04 Oct 2004 by KOBAYASHI R. Taizo <tkoba965@mac.com> v0.5 |
---|
18 | # handl standby map files more strictly |
---|
19 | # 20 Sep 2004 by KOBAYASHI R. Taizo <tkoba965@mac.com> v0.4 |
---|
20 | # hand over current status to map file installer |
---|
21 | # 19 Sep 2004 by KOBAYASHI R. Taizo <tkoba965@mac.com> v0.3 |
---|
22 | # handl *-udvips.map in TEXMF/dvipdfm/config/otf/ |
---|
23 | # 02 Mar 2004 by KOBAYASHI R. Taizo <tkoba@ike-dyn.ritsumei.ac.jp> v0.2 |
---|
24 | # added noFont-udvips.map |
---|
25 | # 28 Feb 2004 by KOBAYASHI R. Taizo <tkoba@ike-dyn.ritsumei.ac.jp> v0.1 |
---|
26 | |
---|
27 | ### |
---|
28 | ### Usage |
---|
29 | ### |
---|
30 | |
---|
31 | Usage() { |
---|
32 | cat <<EOF |
---|
33 | Usage: updmap-otf {hiragino|morisawa|kozuka|nofont|"installed font name"|auto|status} |
---|
34 | |
---|
35 | hiragino: set Hiragino Fonts embedded in pdf files by otf package |
---|
36 | morisawa: set Morisawa Fonts embedded in pdf files by otf package |
---|
37 | kozuka: set kozuka Fonts embedded in pdf files by otf package |
---|
38 | nofont: set no fonts are embedded |
---|
39 | If your system does not have above 3 font families, |
---|
40 | this target is selected automatically. |
---|
41 | "installed font name": |
---|
42 | set fonts which are installed as |
---|
43 | TEXMF/fonts/map/dvipdfm/otf-"install font name".map |
---|
44 | auto: set fonts automatically |
---|
45 | status: get information about current environment and usable font map |
---|
46 | |
---|
47 | EOF |
---|
48 | } |
---|
49 | |
---|
50 | |
---|
51 | ### |
---|
52 | ### Check Installed Font |
---|
53 | ### |
---|
54 | |
---|
55 | CheckInstallFont() { |
---|
56 | if kpsewhich HiraMinPro-W3.otf >/dev/null ; then |
---|
57 | HIRAGINO=installed |
---|
58 | else |
---|
59 | HIRAGINO="" |
---|
60 | fi |
---|
61 | |
---|
62 | if kpsewhich A-OTF-RyuminPro-Light.otf >/dev/null ; then |
---|
63 | MORISAWA=installed |
---|
64 | else |
---|
65 | MORISAWA="" |
---|
66 | fi |
---|
67 | |
---|
68 | if kpsewhich KozMinPro-Regular.otf >/dev/null ; then |
---|
69 | KOZUKA=installed |
---|
70 | else |
---|
71 | KOZUKA="" |
---|
72 | fi |
---|
73 | } |
---|
74 | |
---|
75 | ### |
---|
76 | ### GetStatus |
---|
77 | ### |
---|
78 | |
---|
79 | GetStatus() { |
---|
80 | |
---|
81 | STATUS=$(grep ^kanjiEmbed $(kpsewhich updmap.cfg) | awk '{print$2}') |
---|
82 | if kpsewhich otf-$STATUS.map >/dev/null ; then |
---|
83 | echo "CURRENT map file : otf-$STATUS.map" |
---|
84 | else |
---|
85 | echo "WARNING: Currently selected map file cannot be found: otf-$STATUS.map" |
---|
86 | fi |
---|
87 | |
---|
88 | |
---|
89 | for MAPFILE in otf-hiragino.map otf-morisawa.map otf-kozuka.map |
---|
90 | do |
---|
91 | if [ "$MAPFILE" = "otf-$STATUS.map" ] ; then |
---|
92 | continue |
---|
93 | fi |
---|
94 | mffound=`kpsewhich $MAPFILE` |
---|
95 | if [ -n "$mffound" ] ; then |
---|
96 | case "$MAPFILE" in |
---|
97 | otf-hiragino.map) |
---|
98 | if [ "$HIRAGINO" = "installed" ]; then |
---|
99 | echo "Standby map file : $MAPFILE" |
---|
100 | fi |
---|
101 | ;; |
---|
102 | otf-morisawa.map) |
---|
103 | if [ "$MORISAWA" = "installed" ]; then |
---|
104 | echo "Standby map file : $MAPFILE" |
---|
105 | fi |
---|
106 | ;; |
---|
107 | otf-kozuka.map) |
---|
108 | if [ "$KOZUKA" = "installed" ]; then |
---|
109 | echo "Standby map file : $MAPFILE" |
---|
110 | fi |
---|
111 | ;; |
---|
112 | *) |
---|
113 | echo "Should not happen!" |
---|
114 | ;; |
---|
115 | esac |
---|
116 | fi |
---|
117 | done |
---|
118 | |
---|
119 | } |
---|
120 | |
---|
121 | ### |
---|
122 | ### Setup Map files |
---|
123 | ### |
---|
124 | |
---|
125 | SetupMapFile() { |
---|
126 | |
---|
127 | MAPFILE=otf-$1.map |
---|
128 | |
---|
129 | if kpsewhich $MAPFILE >/dev/null ; then |
---|
130 | echo "Setting up ... $MAPFILE" |
---|
131 | updmap-sys -setoption kanjiEmbed $1 |
---|
132 | updmap-sys |
---|
133 | else |
---|
134 | echo "NOT EXIST $MAPFILE" |
---|
135 | return 1 |
---|
136 | fi |
---|
137 | } |
---|
138 | |
---|
139 | ### |
---|
140 | ### MAIN |
---|
141 | ### |
---|
142 | |
---|
143 | main() { |
---|
144 | |
---|
145 | mktexlsr 2> /dev/null |
---|
146 | |
---|
147 | CheckInstallFont |
---|
148 | |
---|
149 | if [ $# != 1 ] ; then |
---|
150 | eval Usage ${0##*/} |
---|
151 | return -1 |
---|
152 | fi |
---|
153 | |
---|
154 | case "$1" in |
---|
155 | hiragino) |
---|
156 | if [ "$HIRAGINO" = "installed" ]; then |
---|
157 | SetupMapFile hiragino |
---|
158 | else |
---|
159 | main auto |
---|
160 | fi |
---|
161 | ;; |
---|
162 | morisawa) |
---|
163 | if [ "$MORISAWA" = "installed" ]; then |
---|
164 | SetupMapFile morisawa |
---|
165 | else |
---|
166 | main auto |
---|
167 | fi |
---|
168 | ;; |
---|
169 | kozuka) |
---|
170 | if [ "$KOZUKA" = "installed" ]; then |
---|
171 | SetupMapFile kozuka |
---|
172 | else |
---|
173 | main auto |
---|
174 | fi |
---|
175 | ;; |
---|
176 | nofont) |
---|
177 | SetupMapFile noEmbed |
---|
178 | ;; |
---|
179 | auto) |
---|
180 | GetStatus |
---|
181 | if [ "$STATUS" = "morisawa" ] && [ "$MORISAWA" = "installed" ]; then |
---|
182 | SetupMapFile morisawa |
---|
183 | elif [ "$STATUS" = "kozuka" ] && [ "$KOZUKA" = "installed" ]; then |
---|
184 | SetupMapFile kozuka |
---|
185 | elif [ "$STATUS" = "noEmbed" ] && [ "$HIRAGINO" = "installed" ]; then |
---|
186 | SetupMapFile hiragino |
---|
187 | elif [ "$HIRAGINO" = "installed" ]; then |
---|
188 | SetupMapFile hiragino |
---|
189 | elif [ "$MORISAWA" = "installed" ]; then |
---|
190 | SetupMapFile morisawa |
---|
191 | elif [ "$KOZUKA" = "installed" ]; then |
---|
192 | SetupMapFile kozuka |
---|
193 | else |
---|
194 | SetupMapFile noEmbed |
---|
195 | fi |
---|
196 | ;; |
---|
197 | status) |
---|
198 | GetStatus |
---|
199 | return 0 |
---|
200 | ;; |
---|
201 | *) |
---|
202 | SetupMapFile $1 |
---|
203 | ;; |
---|
204 | esac |
---|
205 | } |
---|
206 | |
---|
207 | main $@ |
---|
208 | |
---|