summaryrefslogtreecommitdiff
path: root/print/latex-cjk/scripts/post-install
blob: 00544833c30913942f50c66d4992d87d6e00726b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#!/bin/sh
PATH=/bin:/usr/bin:/usr/local/bin

# Some mktexpk incorrectly calls ttf2pk with -p option, delete it.
cp ${PREFIX}/bin/mktexpk ${PREFIX}/bin/mktexpk.CJK
sed -e "s/ttf2pk -p/ttf2pk/" ${PREFIX}/bin/mktexpk.CJK > ${PREFIX}/bin/mktexpk
rm ${PREFIX}/bin/mktexpk.CJK

# Install ttf2pk binary in ${PORTSDIR}/print/freetype, data in ${TEXMF}/ttf2pk
(cd ${PORTSDIR}/print/freetype/work/freetype-1.2/contrib/ttf2pk;
 ./configure --prefix=${PREFIX} --with-kpathsea-dir=${PREFIX};
 make depend all install;
 cp -R data ${PREFIX}/share/texmf/ttf2pk;
 cd ${PREFIX}/share/texmf; ln -s ttf2pk ttf2tfm; )

# We have no way telling where generated fonts are, but ask the user.
echo
echo "Please input where generated fonts are placed."
echo "It's specified as VARTEXFONTS in your texmf.cnf."
echo "->(Default: /var/tmp/texfonts)"
read VARTEXFONTS
if [ -z ${VARTEXFONTS} ]
then
  VARTEXFONTS=/var/tmp/texfonts
fi

# teTeX no longer makes VARTEXFONTS.
mkdir -p ${VARTEXFONTS}/pk
mkdir -p ${VARTEXFONTS}/tfm

# Chmod 1777 ${VARTEXFONTS}.
if [ -z "${NOCHMOD}" ]
then
  chmod -R 1777 ${VARTEXFONTS}
fi

# Install moe_* TTF fonts
echo ===
echo If you want to install other TTF fonts, you have to manually edit:
echo ${PREFIX}/share/texmf/fontname/special.map
echo ${PREFIX}/share/texmf/ttf2pk/ttfonts.map
echo ${PREFIX}/share/texmf/web2c/texmf.cnf
echo ${PREFIX}/share/texmf/tex/latex/CJK/Bg5/c00kai.fd, for Kai family fonts.
echo ${PREFIX}/share/texmf/tex/latex/CJK/Bg5/c00song.fd, for Song family fonts.
echo ${PREFIX}/share/texmf/tex/latex/CJK/Bg5/c00lishu.fd, for LiShu family fonts.
echo ===
mkdir -p ${PREFIX}/share/texmf/fonts/truetype/moe
ln -s ${X11BASE}/lib/X11/fonts/TrueType/moe_*.ttf ${PREFIX}/share/texmf/fonts/truetype/moe

# fontname/special.map
if [ -n "`grep moekai ${PREFIX}/share/texmf/fontname/special.map`" ]
then
  echo Seems moekai already in special.map, file untouched.
else
  echo "@c BIG5 MOE TTF fonts" >> ${PREFIX}/share/texmf/fontname/special.map
  echo "moekai		big5		moekai" >> ${PREFIX}/share/texmf/fontname/special.map
fi
if [ -n "`grep moesung ${PREFIX}/share/texmf/fontname/special.map`" ]
then
  echo Seems moesung already in special.map, file untouched.
else
  echo "@c BIG5 MOE TTF fonts" >> ${PREFIX}/share/texmf/fontname/special.map
  echo "moesung		big5		moesung" >> ${PREFIX}/share/texmf/fontname/special.map
fi
if [ -n "`grep moelishu ${PREFIX}/share/texmf/fontname/special.map`" ]
then
  echo Seems moelishu already in special.map, file untouched.
else
  echo "@c BIG5 MOE TTF fonts" >> ${PREFIX}/share/texmf/fontname/special.map
  echo "moelishu	big5		moelishu" >> ${PREFIX}/share/texmf/fontname/special.map
fi

# ttf2pk/ttfonts.map
if [ -n "`grep moekai ${PREFIX}/share/texmf/ttf2pk/ttfonts.map`" ]
then
  echo Seems moekai already in ttfonts.map, file untouched.
else
  echo "moekai@Big5.sfd@   moe_kai Pid=3 Eid=4" >> ${PREFIX}/share/texmf/ttf2pk/ttfonts.map
fi
if [ -n "`grep moesung ${PREFIX}/share/texmf/ttf2pk/ttfonts.map`" ]
then
  echo Seems moesung already in ttfonts.map, file untouched.
else
  echo "moesung@Big5.sfd@   moe_sung Pid=3 Eid=4" >> ${PREFIX}/share/texmf/ttf2pk/ttfonts.map
fi
if [ -n "`grep moelishu ${PREFIX}/share/texmf/ttf2pk/ttfonts.map`" ]
then
  echo Seems moelishu already in ttfonts.map, file untouched.
else
  echo "moelishu@Big5.sfd@   moe_lishu Pid=3 Eid=4" >> ${PREFIX}/share/texmf/ttf2pk/ttfonts.map
fi

# web2c/texmf.cnf
if [ -n "`grep TTF2PKINPUTS ${PREFIX}/share/texmf/web2c/texmf.cnf`" ]
then
  echo Seems TTF2PKINPUTS already set in texmf.cnf, file untouched.
else
  echo "% ttf2pk data directory" >> ${PREFIX}/share/texmf/web2c/texmf.cnf
  echo "TTF2PKINPUTS = \$TEXMF/ttf2pk//" >> ${PREFIX}/share/texmf/web2c/texmf.cnf
fi
if [ -n "`grep TTF2TFMINPUTS ${PREFIX}/share/texmf/web2c/texmf.cnf`" ]
then
  echo Seems TTF2TFMINPUTS already set in texmf.cnf, file untouched.
else
  echo "% ttf2tfm data directory" >> ${PREFIX}/share/texmf/web2c/texmf.cnf
  echo "TTF2TFMINPUTS = \$TEXMF/ttf2tfm//" >> ${PREFIX}/share/texmf/web2c/texmf.cnf
fi

# tex/latex/CJK/Bg5/c00kai.fd
if [ -n "`grep moekai ${PREFIX}/share/texmf/tex/latex/CJK/Bg5/c00kai.fd`" ]
then
  echo Seems moekai already in c00kai.fd, file untouched.
else
  (cd ${PREFIX}/share/texmf/tex/latex/CJK/Bg5;
   cp c00kai.fd c00kai.fd.orig;
   sed -e "s/b5ka12/moekai/" c00kai.fd.orig > c00kai.fd;
  )
fi

# tex/latex/CJK/Bg5/c00song.fd
if [ -n "`grep moesung ${PREFIX}/share/texmf/tex/latex/CJK/Bg5/c00song.fd`" ]
then
  echo Seems moesung already in c00song.fd, file untouched.
else
  (cd ${PREFIX}/share/texmf/tex/latex/CJK/Bg5;
   cp c00song.fd c00song.fd.orig;
   sed -e "s/CJKsub \* kai\/m\/n/CJK \* moesung/" c00song.fd.orig > c00song.fd;
   mv c00song.fd c00song.fd.tmp;
   sed -e "s/CJKsub \* kai\/bx\/n/CJKb \* moesung/" c00song.fd.tmp > c00song.fd;
   rm c00song.fd.tmp;
  )
fi

rm ${PREFIX}/share/texmf/tex/latex/CJK/Bg5/c00lishu.fd.orig

# Generate tfm fonts for moekai/moesung/moelishu.
texconfig rehash  # Update ls-R
mkdir -p ${VARTEXFONTS}/tfm/moe/moekai ${VARTEXFONTS}/tfm/moe/moesung ${VARTEXFONTS}/tfm/moe/moelishu
(cd ${VARTEXFONTS}/tfm/moe/moekai; ttf2tfm moe_kai -P 3 -E 4 moekai@Big5@)
(cd ${VARTEXFONTS}/tfm/moe/moesung; ttf2tfm moe_sung -P 3 -E 4 moesung@Big5@)
(cd ${VARTEXFONTS}/tfm/moe/moelishu; ttf2tfm moe_lishu -P 3 -E 4 moelishu@Big5@)

# Update ${TEXMF} tree
texconfig rehash

# Messages to the user
echo "----------------------------------------------------------------------"
echo "CJK is now installed. Here are final notes for BIG5 users:"
echo
echo "Use 'bg5latex' instead of 'latex'. You may run 'bg5latex Big5.tex'"
echo "to check its output. CJK.doc & commands.doc are good starting"
echo "points."
echo
echo "FYI, moe_kai.ttf has some characters lost. These includes:"
echo "   0xb9a6 0xbcb5 0xd974 0xdb57 0xdd7c 0xe0b5 0xe2e9 0xe351"
echo "   0xe3c4 0xe5bf 0xe5c1 0xe7ec 0xec52 0xf374 0xf6dd"
echo
echo "Numerous characters are not available in moe_lishu.ttf. It's"
echo "included only for reference."
echo
echo "But moe_sung.ttf has these all. :)"
echo
echo "Thanks to Clem Chuang <b5506056@csie.ntu.edu.tw> for this info."
echo
echo "Happy CJKing!"
echo "----------------------------------------------------------------------"