From e39879eb57681dc16b48ea91584c82a6e59a0c8c Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Sun, 7 Jul 2024 14:10:21 +0100 Subject: Adds code to keep font the same when switching themes --- init.el | 41 ++++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-) (limited to 'init.el') diff --git a/init.el b/init.el index f80cb82..21644a2 100644 --- a/init.el +++ b/init.el @@ -224,16 +224,39 @@ Restart works only on graphic display." (setq visible-bell t) ;; font + ;; (cond - ;; ((string-equal (system-name) "schumann") - ;; (when (member "Iosevka Nerd Font" (font-family-list)) - ;; (add-to-list 'default-frame-alist '(font . "Iosevka Nerd Font")))) - ;; ((string-equal (system-name) "pop_os") - ;; (when (member "Hack" (font-family-list)) - ;; (add-to-list 'default-frame-alist '(font . "Hack-10")))) - -(add-to-list 'default-frame-alist - '(font . "Iosevka Nerd Font-14")) +;; ((string-equal (system-name) "schumann") +;; (when (member "Iosevka Nerd Font" (font-family-list)) +;; (add-to-list 'default-frame-alist '(font . "Iosevka Nerd Font")))) +;; ((string-equal (system-name) "pop_os") +;; (when (member "Hack" (font-family-list)) +;; (add-to-list 'default-frame-alist '(font . "Hack-10")))) + +;; (add-to-list 'default-frame-alist +;; '(font . "Iosevka Nerd Font-14")) + +(set-frame-font "Iosevka Nerd Font-14") +(defun my-set-default-font () + (set-frame-font "Iosevka Nerd Font-14" nil t)) + +;; Add the function to the `after-init-hook` so it's run after initialization +(add-hook 'after-init-hook 'my-set-default-font) + +;; Add the function to the `after-load-theme-hook` so it's run after loading a theme +(add-hook 'after-load-theme-hook 'my-set-default-font) + +(defun my-apply-font () + "Apply my preferred font settings." + (set-frame-font "Iosevka Nerd Font-14" nil t)) + +(add-hook 'after-make-frame-functions + (lambda (frame) + (with-selected-frame frame + (my-apply-font)))) + +;; Apply the font settings to the current frame +(my-apply-font) ;; (set-face-attribute 'default nil ;; :family "Iosevka Nerd Font" -- cgit v1.2.3