星期四, 十二月 04, 2008

Revised configure CJK on Fedora 10

Prepare:


Create a script file pre.sh:
#!/usr/bin/env bash
yum install texlive-afm texlive-texmf-afm fontforge -y
cd /usr/share/texmf/fonts/truetype/
wget http://cjk.ffii.org/cjk-4.8.1.tar.gz
wget http://cjk.ffii.org/cjk-4.8.1-doc.tar.gz
tar zxvf cjk-4.8.1.tar.gz
tar zxvf cjk-4.8.1-doc.tar.gz
mv cjk-4.8.1 /usr/share/texmf/tex/latex/cjk
rm *gz

$ chmod +x pre.sh

$ su -c ./pre.sh

Get fonts:

Copy all the ttf/ttc file to /usr/share/texmf/fonts/truetype/

Rename them all in lower cased file names

Install fonts:

Content of the script file icjk.sh:
#!/usr/bin/env bash
############################################################
# This bash script install windows or whatever ttf fonts
# on to Fedora 10 or alike.
#
# Useage
# 1) Use script pre.sh (refer relative descriptions)
#
# 2) Copy all ttf and this script files to directory,
# for example, /tmp/ttf/
# Then in that directory, run the following
# su -c ./icjk.sh
#
# ----------------------------------------------------------
# Don't know how to install ttc file
#
# ----------------------------------------------------------
# Don't forget to run
# updmap
# in your own right, i.e. not with root privilege
#
# ----------------------------------------------------------
# Write by Xijiang Yu
# Dec. 5. 2008
############################################################

############################################################
# Necessary path/file names
# you can name the path 'winfonts' to whatever you want
############################################################
texmf=/usr/share/texmf
fonts=${texmf}/fonts
pname=winfonts

pfb=${fonts}/type1/${pname}
afm=${fonts}/afm/${pname}
tfm=${fonts}/tfm/${pname}
enc=${fonts}/enc/${pname}

psd=${fonts}/map/dvips/${pname}
map=${fonts}/map/${pname}
cid=${fonts}/map/dvipdfm/cid-x.map
utf=${texmf}/tex/latex/cjk/utf8

if ! [ -a $map ]
then
mkdir -p $map
fi

if ! [ -a $psd ]
then
mkdir -p $psd
fi

if ! [ -a $psd ]
then
mkdir -p $utf
fi

wget http://delloye.free.fr/Unicode.sfd
cp /usr/share/texmf/tex/latex/cjk/utils/subfonts/subfonts.pe .

for i in *.ttf
do

fontforge -script subfonts.pe $i ${i%.*} Unicode.sfd

for j in *.tfm # Create *ps.map
do
echo ${j%.tfm} ${j%.tfm} \<${j%.tfm}.pfb >> ${i%.*}ps.map
done

for j in *.enc # Create *.map
do
echo ${j%.enc} \<$i \<$j >>${i%.*}.map
done

mkdir -p ${fonts}/{type1,afm,tfm,enc}/${pname}/${i%.*}

# move the fontforge created files to proper places
mv *.pfb ${pfb}/${i%.*}
mv *.afm ${afm}/${i%.*}
mv *.tfm ${tfm}/${i%.*}
mv *.enc ${enc}/${i%.*}

mv ${i%.*}ps.map $psd
mv ${i%.*}.map $map

echo ${i%.*}@Unicode@ Identity-H :0:${i} >>${cid}
echo Map ${i%.*}.map >>${texmf}/web2c/updmap.cfg
echo f ${i%.*}.map >>${texmf}/dvipdfm/config/config
echo p +${i%.*}ps.map >>${texmf}/dvips/config/config.ps

# Create c70*.fd file
echo \\ProvidesFile{c70${i%.*}.fd} >>${utf}/c70${i%.*}.fd
echo \\DeclareFontFamily{C70}{${i%.*}}{\\hyphenchar \\font\\m@ne} >>${utf}/c70${i%.*}.fd
echo "\\DeclareFontShape{C70}{${i%.*}}{m}{n}{<-> CJK * ${i%.*}}{}" >>${utf}/c70${i%.*}.fd
echo "\\DeclareFontShape{C70}{${i%.*}}{bx}{n}{<-> CJKb * ${i%.*}}{\CJKbold}" >>${utf}/c70${i%.*}.fd
echo \\endinput >>${utf}/c70${i%.*}.fd

cp $i ${fonts}/truetype
done

mktexlsr

$ su -c ./icjk.sh

$ updmap

Enjoy!

没有评论: