13
11

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 5 years have passed since last update.

emacsでプロポーショナルフォントと等幅フォントを切り替える

Last updated at Posted at 2016-06-14

emacsで日本語も英語もプロポーショナルフォントで表示したい。
emacsでM-x variable-pitch-modeとすると、バッファごとにデフォルト(等幅)のフォントとプロポーショナルフォントを切り替えられる。しかしWindowsのNTemacsでは、デフォルトフォントの設定だけしかしていないと、asciiフォントしかプロポーショナルにならず、日本語フォントはデフォルトの等幅のままになる。

init.el
(set-face-attribute 'default nil :family "Consolas" :height 120)
(set-fontset-font t 'japanese-jisx0208 (font-spec :family "MeiryoKe_Console"))
(add-to-list 'face-font-rescale-alist '("MeiryoKe_Console" . 1.09))

文字aの上でM-x describe-char
uniscribe:-outline-Consolas-normal-normal-normal-mono-16----c--iso8859-1 (#x83)
文字の上でM-x describe-char
uniscribe:-outline-MeiryoKe_Console-normal-normal-normal-mono-17----c--iso8859-1 (#x901)

M-x variable-pitch-mode
文字aの上でM-x describe-char
uniscribe:-outline-Arial-normal-normal-normal-sans-16----p--iso8859-1 (#x44)
文字の上でM-x describe-char
uniscribe:-outline-MeiryoKe_Console-normal-normal-normal-mono-17----c--iso8859-1 (#x901)

試行錯誤してvariable-pitchfaceにfontsetを設定したら、日本語フォントもプロポーショナルフォントで表示された。

init.el
(add-to-list 'face-font-rescale-alist '("MeiryoKe_PGothic" . 1.09))
(create-fontset-from-ascii-font
 "Arial:weight=normal:slant=normal" nil "variable")
(set-fontset-font
 "fontset-variable" 'japanese-jisx0208 (font-spec :family "MeiryoKe_PGothic"))
(set-face-attribute 'variable-pitch nil :fontset "fontset-variable")

M-x variable-pitch-mode
文字aの上でM-x describe-char
uniscribe:-outline-Arial-normal-normal-normal-sans-16----p--iso8859-1 (#x44)
文字の上でM-x describe-char
uniscribe:-outline-MeiryoKe_PGothic-normal-normal-normal-mono-17----p--iso8859-1 (#x7251)

variable-pitch.png

13
11
0

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
13
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?