all gone

all gone

2007年1月8日 #

Ubuntu UTF8环境下搭建中文LaTeX环境

  1. 基本包的安装
sudo apt-get install tetex-base tetex-bin tetex-extra
  1. CJK包安装
sudo apt-get install latex-cjk-chinese
  1. CJK UTF8字体生成
将下面的code复制到文件cvtfont.sh中:

#!/bin/sh
#
# Origin By Edward G.J. Lee
2001.11.25
# http:
//www.study-area.org/tips/latex/pdftex.html
# This code is Public Domain.
#
# Enhanced by intron@intron.ac,
2006.1.9
# Modified
for NetBSD by jungle@soforge.com, 2006.1.14
# Italic support added by robert.zhangle@gmail.com,
2006.5.19
#

if [ $# -ne 3 ]
then

cat
<< EOF
Usage: `basename $
0` font.ttf <TeX_Internal_Font_Name> <Tex_Font_Name>
<TeX_Internal_Font_Name>: Used to name *.enc, *.afm, *.pfb, *.tfm & *.map
<Tex_Font_Name>: Used in TeX source: \\CJKencfamily{UTF8}{Tex_Font_Name}

An example: `basename $
0` gbsn00lp.ttf gbsn00lp songpt1

EOF

exit
1
fi

if ! which ttf2pt1; then
echo
"Please install pkgsrc fonts/ttf2pt1 before you can run me."
exit
1
fi

if ! which t1asm; then
echo
"Please install pkgsrc fonts/t1utils before you can run me."
exit
1
fi

if ! which extconv; then
echo
"Please install pkgsrc chinese/CJK before you can run me."
exit
1
fi


cat
<<EOF
***************************************************************************
* Please confirm that current working directory is EMPTY except scripts *
* and HAS ENOUGH SPACE to contain so many intermediate files. *
* If it is not empty, this script may DAMAGE INNOCENT FILES!!! *
***************************************************************************
EOF

read
-p "Go ahead?[n]" a

if [ "$a" != "y" ] && [ "$a" != "Y" ]; then
exit
0
fi

FONTFILENAME
="$1"
FONTNAME
="$2"
FONTTEXNAME
="$3"

#TEXMFHOME
=`kpsexpand '$TEXMFHOME'`
TEXMFMAIN
=`kpsexpand '$TEXMFMAIN'`
TEXMFHOME
='/usr/share/texmf-tetex/'
TTFONTFILEDIR
=${TEXMFHOME}/fonts/truetype/chinese/
ENCDIR
=${TEXMFHOME}/fonts/enc/dvips/chinese/${FONTNAME}
AFMDIR
=${TEXMFHOME}/fonts/afm/chinese/${FONTNAME}
TFMDIR
=${TEXMFHOME}/fonts/tfm/chinese/${FONTNAME}
PFBDIR
=${TEXMFHOME}/fonts/type1/chinese/${FONTNAME}
MAPDIR
=${TEXMFHOME}/fonts/map/dvips/chinese

UPDMAPCFG
=${TEXMFHOME}/web2c/updmap.cfg

if [ ! -f $UPDMAPCFG ]
then
SYSUPDMAPCFG
=`kpsewhich -format 'web2c files' updmap.cfg`
cp $SYSUPDMAPCFG $UPDMAPCFG
fi

CIDXMAP
=${TEXMFHOME}/dvipdfm/config/cid-x.map

if [ ! -f $CIDXMAP ]
then
touch $CIDXMAP
fi

CJKDIR
=${TEXMFMAIN}/tex/latex/CJK/UTF8

INSTALLDIRMODE
="-m 0755"
INSTALLMODE
="-m 0644"

FONTFILEBASENAME
=`basename "$FONTFILENAME"`
FDNAME
=c70${FONTTEXNAME}.fd

#MAPFILE
=/usr/local/share/ttf2pt1/maps/cugb.map
PLANENUM
=255

# Initialize ${FONTNAME}.map
echo
-n "" > ${FONTNAME}.map


n
=0

echo
"Generating subfonts from plane $n to plane $PLANENUM ..."

while [ $n -le $PLANENUM ]
do
m
=`printf %02x $n`

echo
-n "[$n]"

SUBFONTNAME
=${FONTNAME}${m}

# Generate
*.t1a *.afm *.enc
ttf2pt1
-GAE -pft -OHUBs -W0 -l plane+pid=3,eid=1,0x$m \\
"$FONTFILENAME" ${SUBFONTNAME}

# avoid dvips(k)(before v5.
86) t1part module bug.
perl
-pi -e 's/_/Z/g' ${SUBFONTNAME}.t1a ${SUBFONTNAME}.afm

# Generate
*.pfb
t1asm
-b ${SUBFONTNAME}.t1a > ${SUBFONTNAME}.pfb 2>/dev/null

# Generate
*.tfm
afm2tfm ${FONTNAME}$m.afm ${FONTNAME}$m.tfm
>/dev/null
afm2tfm ${FONTNAME}$m.afm
-s .167 ${FONTNAME}sl$m.tfm >/dev/null

# Generate ${FONTNAME}.map
AFMNAME
=`grep -m 1 -i fontname ${SUBFONTNAME}.afm | cut -d ' ' -f 2`
echo
"${FONTNAME}$m ${AFMNAME} <${FONTNAME}$m.pfb" >> ${FONTNAME}.map
echo
"${FONTNAME}sl$m ${AFMNAME} \\" .167 SlantFont \\" <${FONTNAME}$m.pfb" \\
>> ${FONTNAME}.map

n
=`expr $n + 1`
done

echo

cat
> ${FDNAME} << EOF
% This file is automatically generated by `basename $0`
\\\\def\\\\fileversion{
0.0.1}
\\\\def\\\\filedate{`date
+%Y/%m/%d`}
\\\\ProvidesFile{${FDNAME}}[\\\\filedate\\\\space\\\\fileversion]

\\\\DeclareFontFamily{C70}{${FONTTEXNAME}}{\\\\hyphenchar \\\\font\\\\m@ne}

\\\\DeclareFontShape{C70}{${FONTTEXNAME}}{m}{n}{
<-> CJK * ${FONTNAME}}{}
\\\\DeclareFontShape{C70}{${FONTTEXNAME}}{bx}{n}{
<-> CJKb * ${FONTNAME}}{\\\\CJKbold}
\\\\DeclareFontShape{C70}{${FONTTEXNAME}}{m}{it}{
<-> CJK * ${FONTNAME}sl}{}
\\\\DeclareFontShape{C70}{${FONTTEXNAME}}{bx}{it}{
<-> CJKb * ${FONTNAME}sl}{\\\\CJKbold}
\\\\DeclareFontShape{C70}{${FONTTEXNAME}}{m}{sl}{
<-> CJK * ${FONTNAME}sl}{}
\\\\DeclareFontShape{C70}{${FONTTEXNAME}}{bx}{sl}{
<-> CJKb * ${FONTNAME}sl}{\\\\CJKbold}

\\\\endinput
EOF


#exit
0;

echo
echo
"Installing ..."

install
-d $INSTALLDIRMODE $TTFONTFILEDIR $ENCDIR $AFMDIR $TFMDIR $PFBDIR $MAPDIR $CJKDIR

install $INSTALLMODE $FONTFILENAME $TTFONTFILEDIR

n
=0
while [ $n -le $PLANENUM ]
do
m
=`printf %02x $n`
echo
-n "[$n]"

install $INSTALLMODE ${FONTNAME}${m}.enc $ENCDIR
install $INSTALLMODE ${FONTNAME}${m}.afm $AFMDIR
install $INSTALLMODE ${FONTNAME}${m}.tfm $TFMDIR
install $INSTALLMODE ${FONTNAME}sl${m}.tfm $TFMDIR
install $INSTALLMODE ${FONTNAME}${m}.pfb $PFBDIR

n
=`expr $n + 1`
done

echo

install $INSTALLMODE ${FONTNAME}.map $MAPDIR
install $INSTALLMODE $FDNAME $CJKDIR

echo
>> $UPDMAPCFG
echo
"Map ${FONTNAME}.map" >> $UPDMAPCFG

# update cid
-x.map

echo
"${FONTNAME}@Unicode@ unicode :0:${FONTFILENAME}" >> $CIDXMAP
echo
"${FONTNAME}sl@Unicode@ unicode :0:${FONTFILENAME}" >> $CIDXMAP

mktexlsr

#updmap
-sys
updmap

read
-p "Do you want remove all intermediate files?[n]" a
if [ "$a" = "y" ] || [ "$a" = "Y" ]; then

n
=0
while [ $n -le $PLANENUM ]
do
m
=`printf %02x $n`
echo
-n "[$n]"

rm
-f ${FONTNAME}${m}.enc ${FONTNAME}${m}.afm ${FONTNAME}${m}.t1a \\
${FONTNAME}${m}.pfb ${FONTNAME}sl${m}.tfm ${FONTNAME}${m}.tfm

n
=`expr $n + 1`
done

echo

rm
-fv $FDNAME ${FONTNAME}.map
fi

echo
echo
"OK, all done. :-)"
echo


根据自己的需要可以将TEXMFHOME目录设置成不同的地方,只要Latex能找到即可
我将该目录改为了/usr/share/texmf-tetex,如果相应的目录不存在,则需要自己新建。


将windows系统中的字体文件拷到脚本所在目录执行脚本即可生成Latex所需字体文件,以simhei.ttf为例:

sudo ./cvtfont.sh simhei.ttf simhei simhei







posted @ 2007-05-16 13:34 all gone 阅读(1116) | 评论 (0)编辑 收藏

Struts2 入门

     摘要: 很久没有看Java相关的东西了,这几天才发现Struts2 已经发布了,以前就听说Struts2就是以前的Webwork2,只是作了少许的改动而已,我以前也没看过Webwork,所以赶紧下来试了一把。Struts2的地址:http://struts.apache.org/2.x在Eclipse中新建了一个Tomcat工程(如果用WTP插件的话Dynamic Web工程)struts2Test,以下...  阅读全文

posted @ 2007-01-08 21:59 all gone 阅读(8461) | 评论 (8)编辑 收藏