updmap-otf 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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. PREFIX=/usr/local
  21. TEXMF=${PREFIX}/share/texmf
  22. FONTDIR=${TEXMF}/fonts/opentype
  23. MAPDIR=${TEXMF}/fonts/map/dvipdfm
  24. STATEDIR=${TEXMF}-var/updmap-otf
  25. export TEXMFSYSVAR=${TEXMF}-var
  26. export PATH=${PREFIX}/bin:${PATH}
  27. ###
  28. ### Usage
  29. ###
  30. Usage() {
  31. cat <<EOF
  32. Usage: updmap-otf {hiragino|morisawa|kozuka|nofont|"installed font name"|auto|status}
  33. hiragino: set Hiragino Fonts embedded in pdf files by teTeX otf package
  34. morisawa: set Morisawa Fonts embedded in pdf files by teTeX otf package
  35. kozuka: set kozuka Fonts embedded in pdf files by teTeX otf package
  36. nofont: set no fonts are embedded
  37. If your system does not have above 3 font families,
  38. this target is selected automatically.
  39. "installed font name":
  40. set fonts which are installed as
  41. TEXMF/fonts/map/dvipdfm/otf-"install font name".map
  42. auto: set fonts automatically
  43. status: get information about current environment and usable font map
  44. EOF
  45. }
  46. ###
  47. ### Check Installed Font
  48. ###
  49. CheckInstallFont() {
  50. if [ -f ${FONTDIR}/HiraMinPro-W3.otf ]; then
  51. HIRAGINO=installed
  52. else
  53. HIRAGINO=""
  54. fi
  55. if [ -f ${FONTDIR}/A-OTF-RyuminPro-Light.otf ]; then
  56. MORISAWA=installed
  57. else
  58. MORISAWA=""
  59. fi
  60. if [ -f ${FONTDIR}/KozMinPro-Regular-Acro.otf ]; then
  61. KOZUKA=installed
  62. else
  63. KOZUKA=""
  64. fi
  65. }
  66. ###
  67. ### GetStatus
  68. ###
  69. GetStatus() {
  70. for i in $MAPDIR/otf-*.map
  71. do
  72. if [ "otf-cktx.map" != "`basename $i`" ] && [ -f $i ]; then
  73. MAPFILE=`basename $i | sed -e "s|.map||"`
  74. case "$MAPFILE" in
  75. otf-hiraginox)
  76. if [ "$HIRAGINO" = "installed" ]; then
  77. echo "Standby map file : $MAPFILE"
  78. fi
  79. ;;
  80. otf-morisawax)
  81. if [ "$MORISAWA" = "installed" ]; then
  82. echo "Standby map file : $MAPFILE"
  83. fi
  84. ;;
  85. otf-kozukax)
  86. if [ "$KOZUKA" = "installed" ]; then
  87. echo "Standby map file : $MAPFILE"
  88. fi
  89. ;;
  90. *)
  91. echo "Standby map file : $MAPFILE"
  92. ;;
  93. esac
  94. fi
  95. done
  96. for i in $STATEDIR/otf-*.map
  97. do
  98. if [ "otf-cktx.map" != "`basename $i`" ] && [ -f $i ]; then
  99. STATUS=`basename $i | sed -e "s|.map||" | sed -e "s|otf-||"`
  100. fi
  101. done
  102. if [ -f $STATEDIR/otf-${STATUS}.map ]; then
  103. echo "CURRENT map file : otf-$STATUS"
  104. fi
  105. }
  106. ###
  107. ### Cleanup
  108. ###
  109. CleanUp() {
  110. for TARGET in $STATEDIR/otf-*.map
  111. do
  112. if [ "otf-cktx.map" != "`basename ${TARGET}`" ] && [ -f ${TARGET} ]; then
  113. rm -f ${TARGET}
  114. echo "Removing ... `basename ${TARGET}`"
  115. ${PREFIX}/bin/updmap-sys --nostop --disable `basename ${TARGET}` 2> /dev/null
  116. fi
  117. done
  118. }
  119. ###
  120. ### Setup Map files
  121. ###
  122. SetupMapFile() {
  123. CleanUp
  124. MAPFILE=otf-$1.map
  125. if [ -f ${MAPDIR}/${MAPFILE} ]; then
  126. touch ${STATEDIR}/otf-$1.map
  127. echo "Setting up ... $MAPFILE"
  128. ${PREFIX}/bin/updmap-sys --nostop --enable KanjiMap ${MAPFILE} 2> /dev/null
  129. else
  130. echo "NOT EXIST $MAPFILE"
  131. return -1
  132. fi
  133. }
  134. ###
  135. ### MAIN
  136. ###
  137. main() {
  138. ${PREFIX}/bin/texhash 2> /dev/null
  139. CheckInstallFont
  140. if [ $# != 1 ] ; then
  141. eval Usage ${0##*/}
  142. return -1
  143. fi
  144. case "$1" in
  145. hiragino)
  146. if [ "$HIRAGINO" = "installed" ]; then
  147. SetupMapFile hiraginox
  148. else
  149. main auto
  150. fi
  151. ;;
  152. morisawa)
  153. if [ "$MORISAWA" = "installed" ]; then
  154. SetupMapFile morisawax
  155. else
  156. main auto
  157. fi
  158. ;;
  159. kozuka)
  160. if [ "$KOZUKA" = "installed" ]; then
  161. SetupMapFile kozukax
  162. else
  163. main auto
  164. fi
  165. ;;
  166. nofont)
  167. SetupMapFile noEmbed
  168. ;;
  169. auto)
  170. GetStatus
  171. MAPFILE=${MAPDIR}/otf-$STATUS.map
  172. if [ -f $MAPFILE ] && [ "$STATUS" != "noEmbeddedFont" ]; then
  173. SetupMapFile $STATUS
  174. elif [ "$STATUS" = "morisawa" ] && [ "$MORISAWA" = "installed" ]; then
  175. SetupMapFile morisawax
  176. elif [ "$STATUS" = "kozuka" ] && [ "$KOZUKA" = "installed" ]; then
  177. SetupMapFile kozukax
  178. elif [ "$STATUS" = "noEmbed" ] && [ "$HIRAGINO" = "installed" ]; then
  179. SetupMapFile hiraginox
  180. elif [ "$HIRAGINO" = "installed" ]; then
  181. SetupMapFile hiraginox
  182. elif [ "$MORISAWA" = "installed" ]; then
  183. SetupMapFile morisawax
  184. elif [ "$KOZUKA" = "installed" ]; then
  185. SetupMapFile kozukax
  186. else
  187. SetupMapFile noEmbed
  188. fi
  189. ;;
  190. status)
  191. GetStatus
  192. return 0
  193. ;;
  194. *)
  195. if [ -f ${MAPDIR}/otf-$1.map ]; then
  196. SetupMapFile $1
  197. else
  198. eval Usage ${0##*/}
  199. return -1
  200. fi
  201. ;;
  202. esac
  203. }
  204. main $@