Big Chinese Small ASCII

GNU Emacs有一个假设,即一个汉字字符的宽度是一个ASCII的两倍。如果这个假设不满足,就会有些功能看起来不正常,比如auto-fill-modeorg-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"))

这种方法的缺点是汉字很大、英文较小。

3 thoughts on “Big Chinese Small ASCII

  1. 是的。文泉驿从某个版本开始自带了一套英文等宽字体。我的 .emacs 里面关于字体所有的配置就这些:

    (set-fontset-font "fontset-default"
    'unicode '("WenQuanYi Zen Hei"))

    至于 wqy 自带的英文等宽是否美观,就见仁见智了,我觉得还可以,也懒得折腾。

回复 lyman 取消回复

您的电子邮箱地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据