16
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

emacs 26 のフォントの設定 M-x view-hello-file

Last updated at Posted at 2019-01-13

emacs 26では”emacsのフォントの設定 M-x view-hello-file - Qiita”のままではうまく動かなくなった。
バッファに中国語の文字が含まれているとemacsのプロセスが高負荷になる。たとえばWikipediaの中国語のページをewwやw3mで表示すると暫く固まり、カーソルを動かすたびに固まる。この現象はおそらくemacs 25から起きている。参考:(Reddit) Emacs not playing well with Chinese characters : emacs
このRedditのページではすべての文字のフォントを"Microsoft Yahei"にすることで解決しているが、このフォントで日本語を表示するとあまりきれいではない。
キャプチャ3.PNG
このため日本語の漢字や記号類は日本語のフォントで表示したい。
日本語は"MeiryoKe_Console"、その他の漢字は"Microsoft Yahei"で表示する。
デフォルトでは矢印(→)が半角になるので、全角で表示されるようにする。(Emacs 25.2以降でASCIIと日本語のフォントを別々に設定する(一部の記号のフォントが変更できない場合) | Misohena Blog)

試行錯誤した結果:
キャプチャ4.PNG

設定:

  (set-face-attribute 'default nil :family "Consolas" :height 120)
  (setq use-default-font-for-symbols nil) ; http://misohena.jp/blog/2017-09-26-symbol-font-settings-for-emacs25.html
  (setq inhibit-compacting-font-caches t)
  
  (set-fontset-font t 'arabic (font-spec :family "Courier New"))
  (set-fontset-font t 'sinhala (font-spec :family "Nirmala UI"))
  (set-fontset-font t 'devanagari (font-spec :family "Nirmala UI"))
  (set-fontset-font t 'bengali (font-spec :family "Nirmala UI"))
  (set-fontset-font t 'gujarati (font-spec :family "Nirmala UI"))
  (set-fontset-font t 'kannada (font-spec :family "Nirmala UI"))
  (set-fontset-font t 'malayalam (font-spec :family "Nirmala UI"))
  (set-fontset-font t 'oriya (font-spec :family "Nirmala UI"))
  (set-fontset-font t 'gurmukhi (font-spec :family "Nirmala UI"))
  (set-fontset-font t 'tamil (font-spec :family "Nirmala UI"))
  (set-fontset-font t 'telugu (font-spec :family "Nirmala UI"))
  (set-fontset-font t 'mongolian (font-spec :family "Mongolian Baiti"))
  (set-fontset-font t 'burmese (font-spec :family "Padauk"))
  (set-fontset-font t 'tibetan (font-spec :family "Microsoft Himalaya"))
  (set-fontset-font t 'thai (font-spec :family "Leelawadee UI"))
  (set-fontset-font t 'khmer (font-spec :family "Leelawadee UI"))
  (set-fontset-font t 'lao (font-spec :family "Leelawadee UI"))
  (set-fontset-font t 'yi (font-spec :family "Microsoft Yi Baiti"))
  (set-fontset-font t 'lisu (font-spec :family "Quivira"))
  (set-fontset-font t 'vai (font-spec :family "Quivira"))
  (set-fontset-font t 'tai-lue (font-spec :family "Microsoft New Tai Lue"))
  (set-fontset-font t 'tai-le (font-spec :family "Microsoft Tai Le"))
  (set-fontset-font
   t (cons (decode-char 'ucs #x10330) (decode-char 'ucs #x1034F))
   (font-spec :family "Segoe UI Historic")) ;ゴート文字
  (set-fontset-font
   t (cons (decode-char 'ucs #x10380) (decode-char 'ucs #x1039F))
   (font-spec :family "Segoe UI Historic")) ;ウガリット文字
  (set-fontset-font
   t (cons (decode-char 'ucs #x13000) (decode-char 'ucs #x1342F))
   (font-spec :family "Segoe UI Historic")) ;ヒエログリフ
  (set-fontset-font
   t (cons (decode-char 'ucs #x1F000) (decode-char 'ucs #x1F6FF))
   (font-spec :family "Segoe UI Symbol"))
  (set-fontset-font
   t (cons (decode-char 'ucs #x1F700) (decode-char 'ucs #x1FFFF))
   (font-spec :family "Symbola"))
  (set-fontset-font
   t (cons (decode-char 'ucs #x2000) (decode-char 'ucs #x206f))
   (font-spec :family "Symbola"))	;General Punctuation
  (set-fontset-font
   t (cons (decode-char 'ucs #x2400) (decode-char 'ucs #x243f))
   (font-spec :family "Symbola"))	;Control Pictures
  (set-fontset-font
   t (cons (decode-char 'ucs #x2900) (decode-char 'ucs #x297f))
   (font-spec :family "Segoe UI Symbol")) ;Supplemental Arrows-B
  (set-fontset-font
   t (cons (decode-char 'ucs #x20000) (decode-char 'ucs #x2B81F))
   (font-spec :family "MingLiU-ExtB")) ;CJK Unified Ideographs Extension B-D
  (set-fontset-font
   t (cons (decode-char 'ucs #x2B820) (decode-char 'ucs #x2CEAF))
   (font-spec :family "BabelStone Han")) ;CJK Unified Ideographs Extension E
  (set-fontset-font
   t (cons (decode-char 'ucs #x2F800) (decode-char 'ucs #x2FA1F))
   (font-spec :family "BabelStone Han")) ;CJK Compatibility Ideographs Supplement

  (set-fontset-font t 'big5 (font-spec :family "Microsoft Yahei"))
  (set-fontset-font t 'big5-hkscs (font-spec :family "Microsoft Yahei"))
  (set-fontset-font t 'chinese-cns11643-1 (font-spec :family "Microsoft Yahei"))
  (set-fontset-font t 'chinese-cns11643-15 (font-spec :family "Microsoft Yahei"))
  (set-fontset-font t 'chinese-cns11643-2 (font-spec :family "Microsoft Yahei"))
  (set-fontset-font t 'chinese-cns11643-3 (font-spec :family "Microsoft Yahei"))
  (set-fontset-font t 'chinese-cns11643-4 (font-spec :family "Microsoft Yahei"))
  (set-fontset-font t 'chinese-cns11643-5 (font-spec :family "Microsoft Yahei"))
  (set-fontset-font t 'chinese-cns11643-6 (font-spec :family "Microsoft Yahei"))
  (set-fontset-font t 'chinese-cns11643-7 (font-spec :family "Microsoft Yahei"))
  (set-fontset-font t 'chinese-gb2312 (font-spec :family "Microsoft Yahei"))
  (set-fontset-font t 'chinese-gbk (font-spec :family "Microsoft Yahei"))
  (set-fontset-font t 'kanbun (font-spec :family "Microsoft Yahei"))
  (set-fontset-font t 'bopomofo (font-spec :family "Microsoft Yahei"))
  (set-fontset-font t 'han (font-spec :family "Microsoft Yahei"))
  (set-fontset-font t 'han (font-spec :family "MeiryoKe_Console") nil 'add)

  (set-fontset-font t 'japanese-jisx0208 (font-spec :family "MeiryoKe_Console"))
  (set-fontset-font t 'japanese-jisx0208-1978 (font-spec :family "MeiryoKe_Console"))
  (set-fontset-font t 'japanese-jisx0212 (font-spec :family "MeiryoKe_Console"))
  (set-fontset-font t 'japanese-jisx0213-1 (font-spec :family "MeiryoKe_Console"))
  (set-fontset-font t 'japanese-jisx0213-2 (font-spec :family "MeiryoKe_Console"))
  (set-fontset-font t 'japanese-jisx0213.2004-1 (font-spec :family "MeiryoKe_Console"))
  (set-fontset-font t 'jisx0201 (font-spec :family "MeiryoKe_Console"))
  (set-fontset-font t 'kana (font-spec :family "MeiryoKe_Console"))
  (set-fontset-font t 'symbol (font-spec :family "MeiryoKe_Console") nil 'add)
  (add-to-list 'face-font-rescale-alist '("MeiryoKe_Console" . 1.09))
  (add-to-list 'face-font-rescale-alist '("Microsoft Yahei" . 1.13))

テスト方法:
C-h h (view-hello-file)
M-: (eww "http://yue.sakura.ne.jp/melody/ware/all-code-list.html")
M-: (eww "https://www.wikipedia.org/")

参考:

16
8
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
16
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?