3
0

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

ディスプレイの解像度によってEmacsのフォントを切り替える

Last updated at Posted at 2022-01-20

ディスプレイの解像度によってフォントとフレームサイズを切り替えるコード。

高さが2160以上の場合とそれ未満の場合の2つに場合分けして、それぞれ設定してみます。

(if (boundp 'window-system)
    (if (>= (x-display-pixel-height) 2160)
        (setq initial-frame-alist
              (append (list
                       '(font . "PlemolJP regular 13")
                       '(width . 120)
                       '(height . 80))
                      initial-frame-alist))
        (setq initial-frame-alist
              (append (list
                       '(font . "PlemolJP light 11")
                       '(width . 80)
                       '(height . 60))
                      initial-frame-alist))))

(setq default-frame-alist initial-frame-alist)

もっと洗練した書き方があると思いますが、このようにベタに書くほうが、別の環境に持って行ったときにすぐにちょこちょこっと書き換えて対応できるので、こうしています。

余談になりますが、上記で使用しているフォントは yuru7/PlemolJP: IBM Plex Mono と IBM Plex Sans JP を合成したプログラミングフォント PlemolJP (プレモル ジェイピー) です。数字のゼロとアルファベットのオーなどの紛らわしい文字が区別できるようになっているし、よく問題の原因となる全角スペースも可視化されるし、コーディングにはお勧めです。ウェイトも豊富に用意されています。

3
0
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
3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?