source: projects/specs/trunk/t/texmacro-otf/updmap-otf @ 1533

Revision 1533, 5.1 KB checked in by munepi, 14 years ago (diff)

NEW texlive and its related packages: replacement of teTeX

Line 
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
21PREFIX=/usr/local
22TEXMF=${PREFIX}/share/texmf
23FONTDIR=${TEXMF}/fonts/opentype
24MAPDIR=${TEXMF}/fonts/map/dvipdfm
25STATEDIR=${TEXMF}-var/updmap-otf
26
27export TEXMFSYSVAR=${TEXMF}-var
28export PATH=${PREFIX}/bin:${PATH}
29
30###
31### Usage
32###
33
34Usage() {
35cat <<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
50EOF
51}
52
53
54###
55### Check Installed Font
56###
57
58CheckInstallFont() {
59if [ -f ${FONTDIR}/HiraMinPro-W3.otf ]; then
60    HIRAGINO=installed
61else
62    HIRAGINO=""
63fi
64   
65if [ -f ${FONTDIR}/A-OTF-RyuminPro-Light.otf ]; then
66    MORISAWA=installed
67else
68    MORISAWA=""
69fi
70
71if [ -f ${FONTDIR}/KozMinPro-Regular-Acro.otf ]; then
72    KOZUKA=installed
73else
74    KOZUKA=""
75fi
76}
77
78###
79### GetStatus
80###
81
82GetStatus() {
83
84for i in $MAPDIR/otf-*.map
85do
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
109done
110
111for i in $STATEDIR/otf-*.map
112do
113    if [ "otf-cktx.map" != "`basename $i`" ] && [ -f $i ]; then
114        STATUS=`basename $i | sed -e "s|.map||" | sed -e "s|otf-||"`
115    fi
116done
117
118if [ -f $STATEDIR/otf-${STATUS}.map ]; then
119        echo "CURRENT map file : otf-$STATUS"
120fi
121}
122
123###
124### Cleanup
125###
126
127CleanUp() {
128for TARGET in $STATEDIR/otf-*.map
129do
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
135done
136}
137
138###
139### Setup Map files
140###
141
142SetupMapFile() {
143
144CleanUp
145
146MAPFILE=otf-$1.map
147
148if [ -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
152else
153    echo "NOT EXIST $MAPFILE"
154    return -1
155fi
156}
157
158###
159### MAIN
160###
161
162main() {
163
164${PREFIX}/bin/texhash 2> /dev/null
165
166CheckInstallFont
167
168if [ $# != 1 ] ; then
169    eval Usage ${0##*/}
170    return -1
171fi
172
173case "$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        ;;
231esac
232}
233
234main $@
235
Note: See TracBrowser for help on using the repository browser.