Skip to main content
1 of 3
Toby Speight
  • 81.8k
  • 14
  • 101
  • 309

You'll want to guard the function so you don't try to call it on non-X displays (e.g. emacs -nw):

(when window-system
        ;; your code
      )

The test is very specific - you might want to add other, larger screens:

(and (>= (x-display-pixel-width) 3840)
     (>= (x-display-pixel-width) 2160))

Consider measuring the pixel pitch rather than the overall size:

(< (/ (* 1.0 (display-mm-height)) (x-display-pixel-width)) 0.1)

Reduce the duplication:

(setq-default dotspacemacs-default-font
              (list "Source Code Pro" :size
                    (if (and (eq 3840 (x-display-pixel-width))
                             (eq 2160 (x-display-pixel-height)))
                        34
                      18)))

Support more than two sizes:

(setq-default dotspacemacs-default-font
              (list "Source Code Pro" :size
                    (cond ((<= 3840 (x-display-pixel-width))
                           34)
                          ((<= 1920 (x-display-pixel-width))
                           18)
                          (t
                           12))))
Toby Speight
  • 81.8k
  • 14
  • 101
  • 309