updmap-otf.sh 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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. ### Usage
  28. ###
  29. Usage() {
  30. cat <<EOF
  31. Usage: updmap-otf {hiragino|morisawa|kozuka|nofont|"installed font name"|auto|status}
  32. hiragino: set Hiragino Fonts embedded in pdf files by otf package
  33. morisawa: set Morisawa Fonts embedded in pdf files by otf package
  34. kozuka: set kozuka Fonts embedded in pdf files by otf package
  35. nofont: set no fonts are embedded
  36. If your system does not have above 3 font families,
  37. this target is selected automatically.
  38. "installed font name":
  39. set fonts which are installed as
  40. TEXMF/fonts/map/dvipdfm/otf-"install font name".map
  41. auto: set fonts automatically
  42. status: get information about current environment and usable font map
  43. EOF
  44. }
  45. ###
  46. ### Check Installed Font
  47. ###
  48. CheckInstallFont() {
  49. if kpsewhich HiraMinPro-W3.otf >/dev/null ; then
  50. HIRAGINO=installed
  51. else
  52. HIRAGINO=""
  53. fi
  54. if kpsewhich A-OTF-RyuminPro-Light.otf >/dev/null ; then
  55. MORISAWA=installed
  56. else
  57. MORISAWA=""
  58. fi
  59. if kpsewhich KozMinPro-Regular.otf >/dev/null ; then
  60. KOZUKA=installed
  61. else
  62. KOZUKA=""
  63. fi
  64. }
  65. ###
  66. ### GetStatus
  67. ###
  68. GetStatus() {
  69. STATUS=$(grep ^kanjiEmbed $(kpsewhich updmap.cfg) | awk '{print$2}')
  70. if kpsewhich otf-$STATUS.map >/dev/null ; then
  71. echo "CURRENT map file : otf-$STATUS.map"
  72. else
  73. echo "WARNING: Currently selected map file cannot be found: otf-$STATUS.map"
  74. fi
  75. for MAPFILE in otf-hiragino.map otf-morisawa.map otf-kozuka.map
  76. do
  77. if [ "$MAPFILE" = "otf-$STATUS.map" ] ; then
  78. continue
  79. fi
  80. mffound=`kpsewhich $MAPFILE`
  81. if [ -n "$mffound" ] ; then
  82. case "$MAPFILE" in
  83. otf-hiragino.map)
  84. if [ "$HIRAGINO" = "installed" ]; then
  85. echo "Standby map file : $MAPFILE"
  86. fi
  87. ;;
  88. otf-morisawa.map)
  89. if [ "$MORISAWA" = "installed" ]; then
  90. echo "Standby map file : $MAPFILE"
  91. fi
  92. ;;
  93. otf-kozuka.map)
  94. if [ "$KOZUKA" = "installed" ]; then
  95. echo "Standby map file : $MAPFILE"
  96. fi
  97. ;;
  98. *)
  99. echo "Should not happen!"
  100. ;;
  101. esac
  102. fi
  103. done
  104. }
  105. ###
  106. ### Setup Map files
  107. ###
  108. SetupMapFile() {
  109. MAPFILE=otf-$1.map
  110. if kpsewhich $MAPFILE >/dev/null ; then
  111. echo "Setting up ... $MAPFILE"
  112. updmap-sys -setoption kanjiEmbed $1
  113. updmap-sys
  114. else
  115. echo "NOT EXIST $MAPFILE"
  116. return 1
  117. fi
  118. }
  119. ###
  120. ### MAIN
  121. ###
  122. main() {
  123. mktexlsr 2> /dev/null
  124. CheckInstallFont
  125. if [ $# != 1 ] ; then
  126. eval Usage ${0##*/}
  127. return -1
  128. fi
  129. case "$1" in
  130. hiragino)
  131. if [ "$HIRAGINO" = "installed" ]; then
  132. SetupMapFile hiragino
  133. else
  134. main auto
  135. fi
  136. ;;
  137. morisawa)
  138. if [ "$MORISAWA" = "installed" ]; then
  139. SetupMapFile morisawa
  140. else
  141. main auto
  142. fi
  143. ;;
  144. kozuka)
  145. if [ "$KOZUKA" = "installed" ]; then
  146. SetupMapFile kozuka
  147. else
  148. main auto
  149. fi
  150. ;;
  151. nofont)
  152. SetupMapFile noEmbed
  153. ;;
  154. auto)
  155. GetStatus
  156. if [ "$STATUS" = "morisawa" ] && [ "$MORISAWA" = "installed" ]; then
  157. SetupMapFile morisawa
  158. elif [ "$STATUS" = "kozuka" ] && [ "$KOZUKA" = "installed" ]; then
  159. SetupMapFile kozuka
  160. elif [ "$STATUS" = "noEmbed" ] && [ "$HIRAGINO" = "installed" ]; then
  161. SetupMapFile hiragino
  162. elif [ "$HIRAGINO" = "installed" ]; then
  163. SetupMapFile hiragino
  164. elif [ "$MORISAWA" = "installed" ]; then
  165. SetupMapFile morisawa
  166. elif [ "$KOZUKA" = "installed" ]; then
  167. SetupMapFile kozuka
  168. else
  169. SetupMapFile noEmbed
  170. fi
  171. ;;
  172. status)
  173. GetStatus
  174. return 0
  175. ;;
  176. *)
  177. SetupMapFile $1
  178. ;;
  179. esac
  180. }
  181. main $@