This commit is contained in:
parent
c2e63a1fa6
commit
08cc760f1c
8 changed files with 97 additions and 103 deletions
|
|
@ -26,13 +26,15 @@
|
|||
;; (defconst icejam-font "Iosevka Term" "Default font.")
|
||||
|
||||
(defconst icejam-default-font-family "Iosevka Term" "Default font.")
|
||||
(defconst icejam-variable-font-family "Lexica Ultralegible" "Variable pitch font.")
|
||||
(defconst icejam-variable-font-family "Lexica Ultralegible"
|
||||
"Variable pitch font.")
|
||||
(defconst icejam-markdown-font-family "Iosevka Comfy Motion"
|
||||
"Font used to render code blocks in markdown.
|
||||
It is different than default font to keep it visually distinct.")
|
||||
|
||||
;; Require dash functions to be included:
|
||||
(declare-function -> "dash.el")
|
||||
(eval-when-compile
|
||||
(declare-function -> "dash.el"))
|
||||
|
||||
(defconst icejam-font-height 14
|
||||
"Default height of then font.
|
||||
|
|
@ -61,20 +63,6 @@ in `icejam-set-font-to-screen`.")
|
|||
:group 'icejam)
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;; Font configuration ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; First, let's silence a warning about free variables
|
||||
(defvar lsp-ui-doc-frame-hook)
|
||||
|
||||
(defun icejam-set-lsp-ui-font-hook ()
|
||||
"Reset LSP IO font to specified `icejam-font` and `icejam-font-height`."
|
||||
(setopt lsp-ui-doc-frame-hook nil)
|
||||
(add-hook 'lsp-ui-doc-frame-hook
|
||||
(lambda (frame _w)
|
||||
(set-face-attribute 'default frame
|
||||
:family icejam-mut-default-font-family
|
||||
:height (-> icejam-mut-font-height
|
||||
(- 2)
|
||||
(* 10))))))
|
||||
|
||||
(defun icejam-set-font (family height)
|
||||
"Set font to FAMILY and its HEIGHT to X.
|
||||
|
||||
|
|
@ -89,52 +77,44 @@ two points smaller."
|
|||
(setopt icejam-mut-variable-font-family icejam-variable-font-family)
|
||||
|
||||
;; Set default font.
|
||||
(set-face-attribute 'default nil
|
||||
:family family
|
||||
:height (-> height
|
||||
(* 10)))
|
||||
(dolist (face '(default))
|
||||
(set-face-attribute face nil
|
||||
:family family
|
||||
:height (-> height (* 10))))
|
||||
|
||||
;; Set variable-pitch font
|
||||
(set-face-attribute 'variable-pitch nil
|
||||
:family icejam-mut-variable-font-family
|
||||
:height (-> height
|
||||
(* 10)))
|
||||
(dolist (face '(variable-pitch))
|
||||
(set-face-attribute face nil
|
||||
:family icejam-mut-variable-font-family
|
||||
:height (-> height (* 10))))
|
||||
|
||||
;; Some font faces look better when they are 1 point smaller.
|
||||
;; Tooltips look better when they are 1 point smaller.
|
||||
(dolist (face '(tooltip))
|
||||
(set-face-attribute face nil :height (-> height
|
||||
(- 1)
|
||||
(* 10))))
|
||||
|
||||
;; And some, mainly in modeline with 2 points.
|
||||
;; Modeline looks better when it is 2 points smaller.
|
||||
(dolist (face '(mode-line
|
||||
mode-line-inactive))
|
||||
(set-face-attribute face nil :height (-> height
|
||||
(- 2)
|
||||
(* 10))))
|
||||
|
||||
;; Call LSP-UI hook
|
||||
(icejam-set-lsp-ui-font-hook))
|
||||
(* 10)))))
|
||||
|
||||
(defun icejam-set-font-to-screen ()
|
||||
"Automatically set font height to suit the monitor."
|
||||
(interactive)
|
||||
|
||||
;; Only do anything if there's a display at all.
|
||||
(if (x-display-list)
|
||||
(let ((pixel-height (x-display-pixel-height)))
|
||||
(cond
|
||||
;; MacBook 14" built-in screen.
|
||||
((>= 1080 pixel-height)
|
||||
(icejam-set-font icejam-default-font-family icejam-font-height))
|
||||
|
||||
;; 27" screen connected to a MacBook.
|
||||
((>= 1440 pixel-height)
|
||||
(icejam-set-font icejam-default-font-family (+ icejam-font-height 3)))
|
||||
|
||||
;; 4K screen on Windows or Linux
|
||||
((>= 2160 pixel-height)
|
||||
(icejam-set-font icejam-default-font-family (- icejam-font-height 3)))))))
|
||||
(when (x-display-list)
|
||||
(let* ((pixel-height (x-display-pixel-height))
|
||||
(adjustment (cond
|
||||
((>= 1080 pixel-height) 0) ;; Built-in 14" Macbook screen
|
||||
((>= 1440 pixel-height) 3) ;; 27" screen connected to a Macbook
|
||||
((>= 2160 pixel-height) -3)))) ;; 4K screen (i.e Linux)
|
||||
(when adjustment
|
||||
(icejam-set-font icejam-default-font-family
|
||||
(+ icejam-font-height adjustment))))))
|
||||
|
||||
;; Run the above function once, after elpaca finishes all downloads.
|
||||
(add-hook 'elpaca-after-init-hook 'icejam-set-font-to-screen)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue