문제

First of all, please look at this screenshot GUI vs iTerm

I have GUI Emacs installed via Homebrew on the left and another one running inside iTerm2 with -nw option on the right. Both of them are using Droid Sans Mono font.

But, as you can see, the right one can perfectly handle all unicode characters. I think iTerm2 helps here:

  • on the left display says that there is no font available
  • on the right display is equal to terminal code #xF0 #x9F #x8D #xBA

How can I achieve the same result in GUI Emacs as I can have in iTerm2?

도움이 되었습니까?

해결책

OK, I finally managed this issue with these lines in my emacs config:

;; set proper language (fixes cyrillic letters in ansi-term)
(setenv "LANG" "ru_RU.UTF-8")

;; default font
(set-face-attribute 'default nil :family "Droid Sans Mono")

;; font for all unicode characters
(set-fontset-font t 'unicode "Symbola" nil 'prepend)

;; override font for cyrillic characters
(set-fontset-font t 'cyrillic "Droid Sans Mono")

The first line can be ignored, as it only for fixing cyrillic letters in ansi-term.

The steps are:

  • set your default font with set-face-attribute
  • then set different font for the specific character-sets via set-fontset-font

Of course, I'll need to set specific range of characters for Symbola font, but it works for me now.

P.S. but I still can't get colored emoji in Emacs as I have in iTerm2

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top