GNU Emacs有一个假设,即一个汉字字符的宽度是一个ASCII的两倍。如果这个假设不满足,就会有些功能看起来不正常,比如auto-fill-mode
、org-mode table
。很遗憾,缺省情况下,这个假设并不成立。
查看字体使用C-u C-x =,注意其中xft
的值,通常来说,ASCII和中文的字体大小是一样的。以下是我的缺省字体设置:
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(default ((t (:inherit nil :stipple nil :background "#ffffff"
:foreground "#000000" :inverse-video nil :box nil
:strike-through nil :overline nil :underline nil
:slant normal :weight normal :height 170
:width normal :foundry "Ascender Corp."
:family "Liberation Mono")))))
使用如下方法可以将汉字宽度设置为ASCII的两倍,具体数值需要参考相应的缺省配置。
(set-fontset-font "fontset-default" 'chinese-gbk "AR PL UKai CN 20")
如果是Emacs daemon,则需要写成:
(if (and (fboundp 'daemonp) (daemonp))
(add-hook 'after-make-frame-functions
(lambda (frame)
(with-selected-frame frame
(set-fontset-font "fontset-default"
'chinese-gbk "AR PL UKai CN 20"))))
(set-fontset-font "fontset-default" 'chinese-gbk "AR PL UKai CN 20"))
这种方法的缺点是汉字很大、英文较小。