LoginSignup
19
18

More than 5 years have passed since last update.

解像度に応じて設定を変える

Posted at

解像度に応じて設定を変えたいということがあります. フォントサイズや初期フレームのサイズ, 画面分割の閾値などの設定などです. 私のユースケースでは, 解像度が高い(大きなモニタを利用する)場合はフォントを大きく, そうでない場合はそれほどフォントを大きくしたくないというものがあります. 私が使っているその際の設定を示します.

ディスプレイサイズの取得

(GUI限定ですが)xdisplay-pixel-width, xdisplay-pixel-heightでそれぞれモニタの縦, 横のサイズを取得することができます.

コード例

横幅が 1900以上の場合はフォントサイズを 14px, そうでない場合は 10pxとしています.

(let ((size (if (>= (x-display-pixel-width) 1900) 14 10)))
  (condition-case err
      (let ((myfont (format "VL ゴシック-%d" size)))
    (set-frame-font myfont)
    (add-to-list 'default-frame-alist `(font . ,myfont)))
    (error (message "%s" err))))

おわりに

解像度の違いにより設定を変える方法を示しました.

19
18
2

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
19
18