1 | #!/bin/sh |
---|
2 | # updmap-otf: v0.9 |
---|
3 | # 27 May 2006 by KOBAYASHI R. Taizo <tkoba965@mac.com> v0.9 |
---|
4 | # use noEmbed.map instead of noEmbeddedFont.map |
---|
5 | # 10 Jun 2005 by KOBAYASHI R. Taizo <tkoba965@mac.com> v0.8 |
---|
6 | # modified to use updmap-sys in teTeX3 |
---|
7 | # 07 Nov 2004 by KOBAYASHI R. Taizo <tkoba965@mac.com> v0.7 |
---|
8 | # do not echo back the message of updmap. |
---|
9 | # 17 Oct 2004 by KOBAYASHI R. Taizo <tkoba965@mac.com> v0.6 |
---|
10 | # set hiragino map file if nofont is installed and arg is auto. |
---|
11 | # 04 Oct 2004 by KOBAYASHI R. Taizo <tkoba965@mac.com> v0.5 |
---|
12 | # handl standby map files more strictly |
---|
13 | # 20 Sep 2004 by KOBAYASHI R. Taizo <tkoba965@mac.com> v0.4 |
---|
14 | # hand over current status to map file installer |
---|
15 | # 19 Sep 2004 by KOBAYASHI R. Taizo <tkoba965@mac.com> v0.3 |
---|
16 | # handl *-udvips.map in TEXMF/dvipdfm/config/otf/ |
---|
17 | # 02 Mar 2004 by KOBAYASHI R. Taizo <tkoba@ike-dyn.ritsumei.ac.jp> v0.2 |
---|
18 | # added noFont-udvips.map |
---|
19 | # 28 Feb 2004 by KOBAYASHI R. Taizo <tkoba@ike-dyn.ritsumei.ac.jp> v0.1 |
---|
20 | |
---|
21 | PREFIX=/usr/local |
---|
22 | TEXMF=${PREFIX}/share/texmf |
---|
23 | FONTDIR=${TEXMF}/fonts/opentype |
---|
24 | MAPDIR=${TEXMF}/fonts/map/dvipdfm |
---|
25 | STATEDIR=${TEXMF}-var/updmap-otf |
---|
26 | |
---|
27 | export TEXMFSYSVAR=${TEXMF}-var |
---|
28 | export PATH=${PREFIX}/bin:${PATH} |
---|
29 | |
---|
30 | ### |
---|
31 | ### Usage |
---|
32 | ### |
---|
33 | |
---|
34 | Usage() { |
---|
35 | cat <<EOF |
---|
36 | Usage: updmap-otf {hiragino|morisawa|kozuka|nofont|"installed font name"|auto|status} |
---|
37 | |
---|
38 | hiragino: set Hiragino Fonts embedded in pdf files by teTeX otf package |
---|
39 | morisawa: set Morisawa Fonts embedded in pdf files by teTeX otf package |
---|
40 | kozuka: set kozuka Fonts embedded in pdf files by teTeX otf package |
---|
41 | nofont: set no fonts are embedded |
---|
42 | If your system does not have above 3 font families, |
---|
43 | this target is selected automatically. |
---|
44 | "installed font name": |
---|
45 | set fonts which are installed as |
---|
46 | TEXMF/fonts/map/dvipdfm/otf-"install font name".map |
---|
47 | auto: set fonts automatically |
---|
48 | status: get information about current environment and usable font map |
---|
49 | |
---|
50 | EOF |
---|
51 | } |
---|
52 | |
---|
53 | |
---|
54 | ### |
---|
55 | ### Check Installed Font |
---|
56 | ### |
---|
57 | |
---|
58 | CheckInstallFont() { |
---|
59 | if [ -f ${FONTDIR}/HiraMinPro-W3.otf ]; then |
---|
60 | HIRAGINO=installed |
---|
61 | else |
---|
62 | HIRAGINO="" |
---|
63 | fi |
---|
64 | |
---|
65 | if [ -f ${FONTDIR}/A-OTF-RyuminPro-Light.otf ]; then |
---|
66 | MORISAWA=installed |
---|
67 | else |
---|
68 | MORISAWA="" |
---|
69 | fi |
---|
70 | |
---|
71 | if [ -f ${FONTDIR}/KozMinPro-Regular-Acro.otf ]; then |
---|
72 | KOZUKA=installed |
---|
73 | else |
---|
74 | KOZUKA="" |
---|
75 | fi |
---|
76 | } |
---|
77 | |
---|
78 | ### |
---|
79 | ### GetStatus |
---|
80 | ### |
---|
81 | |
---|
82 | GetStatus() { |
---|
83 | |
---|
84 | for i in $MAPDIR/otf-*.map |
---|
85 | do |
---|
86 | if [ "otf-cktx.map" != "`basename $i`" ] && [ -f $i ]; then |
---|
87 | MAPFILE=`basename $i | sed -e "s|.map||"` |
---|
88 | case "$MAPFILE" in |
---|
89 | otf-hiraginox) |
---|
90 | if [ "$HIRAGINO" = "installed" ]; then |
---|
91 | echo "Standby map file : $MAPFILE" |
---|
92 | fi |
---|
93 | ;; |
---|
94 | otf-morisawax) |
---|
95 | if [ "$MORISAWA" = "installed" ]; then |
---|
96 | echo "Standby map file : $MAPFILE" |
---|
97 | fi |
---|
98 | ;; |
---|
99 | otf-kozukax) |
---|
100 | if [ "$KOZUKA" = "installed" ]; then |
---|
101 | echo "Standby map file : $MAPFILE" |
---|
102 | fi |
---|
103 | ;; |
---|
104 | *) |
---|
105 | echo "Standby map file : $MAPFILE" |
---|
106 | ;; |
---|
107 | esac |
---|
108 | fi |
---|
109 | done |
---|
110 | |
---|
111 | for i in $STATEDIR/otf-*.map |
---|
112 | do |
---|
113 | if [ "otf-cktx.map" != "`basename $i`" ] && [ -f $i ]; then |
---|
114 | STATUS=`basename $i | sed -e "s|.map||" | sed -e "s|otf-||"` |
---|
115 | fi |
---|
116 | done |
---|
117 | |
---|
118 | if [ -f $STATEDIR/otf-${STATUS}.map ]; then |
---|
119 | echo "CURRENT map file : otf-$STATUS" |
---|
120 | fi |
---|
121 | } |
---|
122 | |
---|
123 | ### |
---|
124 | ### Cleanup |
---|
125 | ### |
---|
126 | |
---|
127 | CleanUp() { |
---|
128 | for TARGET in $STATEDIR/otf-*.map |
---|
129 | do |
---|
130 | if [ "otf-cktx.map" != "`basename ${TARGET}`" ] && [ -f ${TARGET} ]; then |
---|
131 | rm -f ${TARGET} |
---|
132 | echo "Removing ... `basename ${TARGET}`" |
---|
133 | ${PREFIX}/bin/updmap-sys --nostop --disable `basename ${TARGET}` 2> /dev/null |
---|
134 | fi |
---|
135 | done |
---|
136 | } |
---|
137 | |
---|
138 | ### |
---|
139 | ### Setup Map files |
---|
140 | ### |
---|
141 | |
---|
142 | SetupMapFile() { |
---|
143 | |
---|
144 | CleanUp |
---|
145 | |
---|
146 | MAPFILE=otf-$1.map |
---|
147 | |
---|
148 | if [ -f ${MAPDIR}/${MAPFILE} ]; then |
---|
149 | touch ${STATEDIR}/otf-$1.map |
---|
150 | echo "Setting up ... $MAPFILE" |
---|
151 | ${PREFIX}/bin/updmap-sys --nostop --enable KanjiMap ${MAPFILE} 2> /dev/null |
---|
152 | else |
---|
153 | echo "NOT EXIST $MAPFILE" |
---|
154 | return -1 |
---|
155 | fi |
---|
156 | } |
---|
157 | |
---|
158 | ### |
---|
159 | ### MAIN |
---|
160 | ### |
---|
161 | |
---|
162 | main() { |
---|
163 | |
---|
164 | ${PREFIX}/bin/texhash 2> /dev/null |
---|
165 | |
---|
166 | CheckInstallFont |
---|
167 | |
---|
168 | if [ $# != 1 ] ; then |
---|
169 | eval Usage ${0##*/} |
---|
170 | return -1 |
---|
171 | fi |
---|
172 | |
---|
173 | case "$1" in |
---|
174 | hiragino) |
---|
175 | if [ "$HIRAGINO" = "installed" ]; then |
---|
176 | SetupMapFile hiraginox |
---|
177 | else |
---|
178 | main auto |
---|
179 | fi |
---|
180 | ;; |
---|
181 | morisawa) |
---|
182 | if [ "$MORISAWA" = "installed" ]; then |
---|
183 | SetupMapFile morisawax |
---|
184 | else |
---|
185 | main auto |
---|
186 | fi |
---|
187 | ;; |
---|
188 | kozuka) |
---|
189 | if [ "$KOZUKA" = "installed" ]; then |
---|
190 | SetupMapFile kozukax |
---|
191 | else |
---|
192 | main auto |
---|
193 | fi |
---|
194 | ;; |
---|
195 | nofont) |
---|
196 | SetupMapFile noEmbed |
---|
197 | ;; |
---|
198 | auto) |
---|
199 | GetStatus |
---|
200 | MAPFILE=${MAPDIR}/otf-$STATUS.map |
---|
201 | if [ -f $MAPFILE ] && [ "$STATUS" != "noEmbeddedFont" ]; then |
---|
202 | SetupMapFile $STATUS |
---|
203 | elif [ "$STATUS" = "morisawa" ] && [ "$MORISAWA" = "installed" ]; then |
---|
204 | SetupMapFile morisawax |
---|
205 | elif [ "$STATUS" = "kozuka" ] && [ "$KOZUKA" = "installed" ]; then |
---|
206 | SetupMapFile kozukax |
---|
207 | elif [ "$STATUS" = "noEmbed" ] && [ "$HIRAGINO" = "installed" ]; then |
---|
208 | SetupMapFile hiraginox |
---|
209 | elif [ "$HIRAGINO" = "installed" ]; then |
---|
210 | SetupMapFile hiraginox |
---|
211 | elif [ "$MORISAWA" = "installed" ]; then |
---|
212 | SetupMapFile morisawax |
---|
213 | elif [ "$KOZUKA" = "installed" ]; then |
---|
214 | SetupMapFile kozukax |
---|
215 | else |
---|
216 | SetupMapFile noEmbed |
---|
217 | fi |
---|
218 | ;; |
---|
219 | status) |
---|
220 | GetStatus |
---|
221 | return 0 |
---|
222 | ;; |
---|
223 | *) |
---|
224 | if [ -f ${MAPDIR}/otf-$1.map ]; then |
---|
225 | SetupMapFile $1 |
---|
226 | else |
---|
227 | eval Usage ${0##*/} |
---|
228 | return -1 |
---|
229 | fi |
---|
230 | ;; |
---|
231 | esac |
---|
232 | } |
---|
233 | |
---|
234 | main $@ |
---|
235 | |
---|