4

For a long long time, my Emacs font definition in X Resources has always been:

! -------------------------------------------------------------- &ss ---
! ............................................................ fonts ...
!Emacs.font:                            6x13
Emacs.Font:                             fixed

Emacs.Font: fontset-gbsimsun
Emacs.Fontset-0: -*-*-medium-r-normal--12-*-*-*-*-*-fontset-gbsimsun,\
ascii:-misc-fixed-medium-r-semicondensed--13-120-75-75-*-60-iso8859-1, \
chinese-gb2312:-*-simsun-medium-r-normal--12-*-*-*-*-*-gb2312.1980-*

That was set more than 15 years ago, and had never changed.

Now, Emacs has modernized dramatically since, and X is using fontconfig to define fonts, and Chinese encoding has changed from gb2312 to UTF8 as default as well. So, I'm wondering what's the modern fontsets setting for Emacs is to work with Chinese properly?

More details,

  • when give the example, please try not generalize but as specific as possible, assuming that I'm having all the MS default fonts in the system. I.e., please don't give example as <your_font_here>, but real thing like Microsoft YaHei etc.
  • the Fontsets from ergoemacs is still giving gb2312 as the example.
  • yet I can't get much from GNU fontset docs either

PS. I'm currently configuring my new Ubuntu 16.04 LTS Xenial environment, and for the first time, I've come to the point to be satisfied with my Ubuntu 中文设置. My Emacs is the last problem to conquer.

Dan
  • 32,584
  • 6
  • 98
  • 168
xpt
  • 447
  • 3
  • 16
  • Here the issue isn't the character encoding but the font rendering mechanism. These resources configure traditional server-side rendering, but you want to use fontconfig client-side rendering, which has generally better quality (it has anti-aliasing) and has far more fonts available nowadays. – Gilles 'SO- stop being evil' Jul 25 '16 at 07:41
  • Thanks for the reply, @Gilles. So to translate this general concept into concrete Emacs fontsets setting, what exactly should I do? – xpt Jul 25 '16 at 19:29
  • Sorry, I don't know, that's why I posted a comment with a hint rather than an answer. – Gilles 'SO- stop being evil' Jul 25 '16 at 19:34
  • 1
    I think that this emacs package may give you some insights. https://github.com/tumashu/chinese-fonts-setup – lurdan Jul 26 '16 at 02:56

1 Answers1

3

https://github.com/tumashu/chinese-fonts-setup

If you google Chinese font emacs, this is the first result.

Basic setup:

(require 'chinese-fonts-setup)
(chinese-fonts-setup-enable) ; enable setup
(cfs-set-spacemacs-fallback-fonts) ; fix unicode icon display in spacemacs mode-line

By default, there are three profiles setup in cfs-profiles,

(setq cfs-profiles
    '("program" "org-mode" "read-book"))

You can switch the profile by M-x cfs-switch-profile or M-x cfs-next-profile

Surely your OS should have Chinese fonts installed at first.

chen bin
  • 4,781
  • 18
  • 36