I'm trying out doom emacs for the first time (previously was using spacemacs). I've run into an issue where chinese characters are not aligned in org mode tables. For example:

| Character | Pingyin     | Meaning                  |
| 好        | hao         | good                     |
| 早上      | zaoshang    | morning                  |
| 晚上      | wanshang    | evning                   |
| 对不起    | dui bu qi   | to be sorry              |
| 没关系    | mei guan xi | that's ok/doesn't matter |
| 不        | bu          | no                       |
| 不客气    | bu ke qi    | you're welcome           |
| 在见      | zaijian     | see you around           |
|           |             |                          |

I've read online that this can be resolved by setting the width of chinese characters to double the width of asci characters, but I'm not sure how to do this. In spacemacs the issue is fixed with the following line in config:

(spacemacs//set-monospaced-font  "Source Code Pro" "Hiragino Sans GB" 15 18)

I'm trying to do something similar in doom:

(setq doom-font (font-spec :family "Source Code Pro" :size 15 :weight 'normal :width 'normal)
      doom-big-font (font-spec :family "Source Code Pro" :size 26))

(dolist (charset '(kana han cjk-misc bopomofo))
  (set-fontset-font (frame-parameter nil 'font)
    charset (font-spec :family "Source Code Pro" :size 18)))

But, it's not working. Would appreciate any help!

  • It has nothing to do with doom, spacemacs or anything else other than the font: in general, you need a fixed-width font for tables to be aligned: Org mode does not consider the width of each glyph in a variable-width font.
    – NickD
    Mar 11 at 16:35

Just use Hiragino Sans GB font!

(setq doom-font (font-spec :family "Source Code Pro" :size 15 :weight 'normal :width 'normal)
      doom-variable-pitch-font (font-spec :family "Source Code Pro" :size 15 :weight 'normal :width 'normal)
      doom-big-font (font-spec :family "Source Code Pro" :size 26))

;; Set font for chinese characters
;; Font should be twice the width of asci chars so that org tables align
;; This will break if run in terminal mode, so use conditional to only run for GUI.
(if (display-graphic-p)
    (dolist (charset '(kana han cjk-misc bopomofo))
      (set-fontset-font (frame-parameter nil 'font)
                        charset (font-spec :family "Hiragino Sans GB" :size 18))))

Note - reload your config.el after doom starts to activate these changes.


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.