Monday, March 05, 2007

Compile your emacs 23 (unicode-2 branch) with XFT support

The current stable version of emacs is 21. Although Emacs 21 presents upstanding, more or less boring problems still exist in chinese charactors and input support. Fortunately, we have another better choice, that is emacs 23, typically named emacs-unicode-2, which is a unicode branch of the currently developping version 23. Emacs23 commendably supports chinese display and input methods.

Fristly, we should get the lastest sources from cvs depository:

$ set CVS_RSH="ssh"
$ cvs -z3 -d:pserver:anonymous@cvs.savannah.gnu.org:/sources/emacs co -r emacs-unicode-2 emacs

Emacs23 support xft fonts, which maybe is the most exciting feature. To support xft, you should add compile condition --enable-font-backend, such as:

$ ./configure --enable-font-backend
$ make bootstrap
$ sudo make install

If you use debian or ubuntu, maybe you should get some header files used for compiler. If gentoo, maybe all is ready for you.

$ sudo apt-get install xserver-xorg-dev xorg-dev libfontconfig-dev libfreetype-dev libxft-dev

After emacs installed, configure ~/.emacs:

;;{{{ XFT Fonts Setting
(set-default-font "Consolas-16")
(set-fontset-font (frame-parameter nil 'font)
                      'han '("Vera Sans YuanTi" . "unicode-bmp"))
;;}}}

Use the command blew to get xft support for emacs:

$ emacs --enable-font-backend

2 comments:

darren said...

yours works for me!

but
(set-fontset-font "fontset-default"
'gb18030 '("SimSun" . "unicode-bmp"))

won't work

Julian said...

try this script?

(set-fontset-font (frame-parameter nil 'font)
'han '("Vera Sans YuanTi" . "unicode-bmp"))