Search code examples
emacselispspacemacs

How to change Spacemacs' default font upon startup based on screen's resolution?


The title is pretty self-explanatory. I don't really know ELisp so this question may be trivial. Anyway I have the code below in my .spacemacs however it doesn't work:

(defun dotspacemacs/user-init ()
  (when (eql x-display-pixel-width 2560)
    (setq-default dotspacemacs-default-font '("Source Code Pro"
                                              :size 13
                                              :weight normal
                                              :width normal
                                              :powerline-scale 1.1)))
 )

Any help as to how can I achieve such a behavior would be appreciated.


Solution

  • So the problem was apparently quite trivial ELisp mistake. A working answer is:

    (defun dotspacemacs/user-init ()
      (when (eql (x-display-pixel-width) 2560)
        (setq-default dotspacemacs-default-font '("Source Code Pro"
                                                  :size 13
                                                  :weight normal
                                                  :width normal
                                                  :powerline-scale 1.1)))
     )
    

    Not sure if above is the idiomatic answer though.