3

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.

  • 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 7: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. github.com/tumashu/chinese-fonts-setup – lurdan Jul 26 '16 at 2:56
2

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.

  • Can you translate that? My Chinese is not good enough to understand what is done there. The result looks great though. – Zelphir Kaltstahl Feb 27 '17 at 8:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.