Skip to content

Commit

Permalink
Fix font and theme load
Browse files Browse the repository at this point in the history
  • Loading branch information
chuxubank committed Feb 22, 2024
1 parent 10c5ca7 commit dd641ad
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 28 deletions.
17 changes: 7 additions & 10 deletions cats/+autodark.el
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,15 @@
(defun cat-load-theme (&optional color)
(interactive)
(cat-benchmark 'beg "load theme.")
(when (or (daemonp)
(display-graphic-p))
(mapc 'disable-theme custom-enabled-themes)
(if (or (and color (eq color 'dark))
(cat-dark-mode-p))
(run-hooks 'cat-dark-mode-hook)
(run-hooks 'cat-light-mode-hook))
(run-hooks 'cat-theme-refresh-hook))
(mapc 'disable-theme custom-enabled-themes)
(if (or (and color (eq color 'dark))
(cat-dark-mode-p))
(run-hooks 'cat-dark-mode-hook)
(run-hooks 'cat-light-mode-hook))
(run-hooks 'cat-theme-refresh-hook)
(cat-benchmark 'end "load theme."))

(when (display-graphic-p)
(add-hook 'after-init-hook #'cat-load-theme))
(add-hook 'after-init-hook #'cat-load-theme)

(when IS-MACPORT
(add-hook 'mac-effective-appearance-change-hook #'cat-load-theme))
Expand Down
10 changes: 4 additions & 6 deletions cats/+daemon.el
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
;; -*- lexical-binding: t; -*-

(defvar cat-theme-loaded nil
(defvar cat-font-loaded nil
"Whether the font is loaded.")

(defun cat-client-frame-config ()
(cat-benchmark 'beg "configuring new frame.")
(unless cat-theme-loaded
(cat-load-theme)
(setq cat-theme-loaded t))
(if (display-graphic-p)
(progn
(message "In GUI.")
(select-frame-set-input-focus (selected-frame))
(add-hook 'eldoc-mode-hook #'eldoc-box-hover-at-point-mode)
(unless eldoc-box-hover-at-point-mode
(eldoc-box-hover-at-point-mode 1))
(cat! "+autodark")
(cat! "+font")
(unless cat-font-loaded
(cat-setup-fonts)
(setq cat-font-loaded t))
(when IS-MACPORT
(setq mac-system-move-file-to-trash-use-finder t)))
(message "In TUI.")
Expand Down
32 changes: 20 additions & 12 deletions cats/+font.el
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,27 @@ like `org-agenda' and `org-table', as well as make spatial efficient.")
(cl-return font))
(warn "Font %s not found" font)))))

(defun cat-setup-fonts ()
"Set fonts for Cat Emacs."
(when (display-graphic-p)
(cat-benchmark 'beg "setup fonts.")
(if IS-MACPORT
(set-face-attribute 'default nil :font cat-default-font :height cat-font-size)
(set-face-attribute 'default nil :font cat-default-font :height cat-font-size :weight 'light))
;; 猫,ねこ,고양이
(+safe-set-fontset-fonts t 'han cat-cjk-mono-fonts)
(+safe-set-fontset-fonts t 'kana cat-cjk-mono-fonts)
(+safe-set-fontset-fonts t 'hangul cat-cjk-mono-fonts)
(+safe-set-fontset-fonts t 'cjk-misc cat-cjk-mono-fonts)

;; 𝓒𝙖𝕥
(+safe-set-fontset-fonts t 'mathematical cat-math-fonts)

(nerd-icons-set-font)
(cat-benchmark 'end "setup fonts.")))

(when (display-graphic-p)
(if IS-MACPORT
(set-face-attribute 'default nil :font cat-default-font :height cat-font-size)
(set-face-attribute 'default nil :font cat-default-font :height cat-font-size :weight 'light)))
(add-hook 'after-init-hook #'cat-setup-fonts))

;; Ligature support
(if IS-MACPORT
Expand Down Expand Up @@ -144,15 +161,6 @@ like `org-agenda' and `org-table', as well as make spatial efficient.")
frame
'prepend))))))

;; 猫,ねこ,고양이
(+safe-set-fontset-fonts t 'han cat-cjk-mono-fonts)
(+safe-set-fontset-fonts t 'kana cat-cjk-mono-fonts)
(+safe-set-fontset-fonts t 'hangul cat-cjk-mono-fonts)
(+safe-set-fontset-fonts t 'cjk-misc cat-cjk-mono-fonts)

;; 𝓒𝙖𝕥
(+safe-set-fontset-fonts t 'mathematical cat-math-fonts)

(setq
face-font-rescale-alist
'(("Noto Serif Thai" . 0.4)
Expand Down

0 comments on commit dd641ad

Please sign in to comment.