all gone

all gone

2006年8月11日 #

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 阅读(1114) | 评论 (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 阅读(8459) | 评论 (8)编辑 收藏

Ubuntu下NVIDIA驱动的问题

前几天按照Ubuntu How-To上的NVIDIA驱动安装说明安装了8672版的驱动,结果发现只要退出X-Window,系统就会没有反应,网上搜了搜,发现有人也有一样的情况,按照说明重新安装、重新配置Xorg,问题依然没有解决,X-Window也起不来了。

到NVIDIA网站上下了最新的8774版驱动后,赶紧找找看怎么自己装,有人已经写好了
在恢复模式下:
需要gcc支持,如果没有安装则:
apt-get install build-essential gcc
删除已经安装的NVIDIA驱动:
apt-get --purge remove linux-restricted-modules-`uname -r` linux-restricted-modules-common nvidia-glx nvidia-settings nvidia-kernel-common
安装内核headers
apt-get install linux-headers-`uname -r`
将下载下来的NVIDIA-Linux-x86-1.0-8774-pkg1.run解压缩:
sh ./NVIDIA-Linux-x86-1.0-8774-pkg1.run --extract-only
进入解压后的NVIDIA-Linux-x86-1.0-8774-pkg1文件夹,执行安装:
./nvidia-installer -n --x-prefix=/usr/lib/xorg/
最后由于默认安装到了/usr/lib/xorg/lig/xorg,需要将文件拷到对应的目录下:
cp --no-dereference /usr/lib/xorg/lib/xorg/libX* /usr/lib/xorg/modules/

cp /usr/lib/xorg/lib/xorg/modules/drivers/* /usr/lib/xorg/modules/drivers/

cp --no-dereference /usr/lib/xorg/lib/xorg/modules/extensions/* /usr/lib/xorg/modules/extensions/

posted @ 2006-09-22 15:42 all gone 阅读(1043) | 评论 (0)编辑 收藏

Qt 4下连接MySQL数据库

前天刚装了个Qt4for windows,发现安装的时候MySQL等数据库插件都没有安装,像Qt X11版一样,都需要自己安装这些插件。

在Qt的安装目录C:\Qt4.1.2\下,有个src目录,进入plugins\sqldrivers\mysql,可以看到两个文件,main.cpp和mysql.pro,很显然要用qmake来完成编译、生成目标。

编译前,首先保证依赖的MySQL头文件和库文件正确。首先MySQL安装目录下的include中的所有文件拷到qmake时能找到的目录下,接着从lib/opt目录下拷出libmysql.a,其实lib/opt下只有libmysql.lib和libmysql.dll,从网上搜了一下找到一个方法从libmysql.dll生成libmysql.a:

1 、安装好MySQL (如果不愿意安装,找个libmySQL.dll文件也可以)

2、下载Pexports工具

3、转换操作: pexports libmysql.dll > libmysql.def

4、使用MinGW的 dlltool转换成为libmysql.a文件。dlltool --input-def libmysql.def --dllname libmysql.dll --output-lib libmysql.a -k

5、尝试是否成功:
将生成的libmysql.a 拷到qmake的lib搜索路径下后在plugins\sqldrivers\mysql目录下做:
qmake -project
qmake
make

如果再出现象mysql_connect@xx (xx是数字)的错误提示。就执行第6步。

6、修改libmysql.def文件,给mysql_connect加上@xx,即mysql_connect@xx

7、重做第4步

8、然后尝试第5步,如果还是出现错误提示。就作第6步。一直到没有错误为止。

最后C:\Qt4.1.2\plugins\sqldrivers下将会生成需要的libqsqlmysql.a和qsqlmysql.dll。

找了一个测试文件,通过。
#include <QtSql> 
#include <QtGui> 


bool createConnection(){ 
QSqlDatabase db 
= QSqlDatabase::addDatabase("QMYSQL"); 
db.setHostName("localhost"); 
db.setDatabaseName("test"); 
db.setUserName("test"); 
db.setPassword(""); 

if(!db.open()){ 
QMessageBox::critical(
0, QObject::tr("Database Error"), 
                              db.lastError().text())
; 

return false
; 


QSqlQuery query
; 
//query.exec("insert into book values( 3, 'title', 'author') "); 
query.exec("select title , author from book "); 

while (query.next()) { 


    QString title 
= query.value(0).toString(); 
    QString author = query.value(1).toString(); 

QMessageBox::critical(
0, title,author); 
    



return true
; 




int main(int argc
,char** argv){ 

QApplication app(argc
, argv); 
    if (!createConnection()){ 

return 
1; 

        

    return app.exec()
; 




posted @ 2006-08-28 20:57 all gone 阅读(2726) | 评论 (0)编辑 收藏

EJB3.0 + Struts小试

     摘要: 一直想做一个 EJB3.0 结合 Struts 的例子,前天刚好从网上找到了一个相关的 Tutorial ,于是小试了一把,虽然只是完成了 Tutorial 上的一小点功能,但是感觉还是有必要写下来,免得以后还要再去看别人的Tutorial 。 开发环境:       Eclipse3.2 + WTP1.5 , JBoss 4.0.3SP1 , jboss-EJB-3.0_RC...  阅读全文

posted @ 2006-08-11 13:52 all gone 阅读(3060) | 评论 (0)编辑 收藏