@@ -735,28 +735,52 @@ ref: https://github.com/manateelazycat/auto-save
735735** 字体和主题
736736
737737#+begin_src elisp
738- (use-package faces
739- :disabled
740- :ban minimal?
741- :custom-face
742- (variable-pitch
743- ((t (:font ,(font-xlfd-name (font-spec :family "Alegreya"))))))
744- (default
745- ((t (:font ,(font-xlfd-name (font-spec :family "CaskaydiaCove NFP"))
746- :height 120))))
747- (fixed-pitch
748- ((t (:inherit default))))
749- :config
750- (set-fontset-font t 'symbol (font-spec :family "Segoe UI Symbol"))
751-
752- (set-fontset-font t 'emoji (font-spec :family "Segoe UI Emoji"))
753-
754- (set-fontset-font t 'chinese-gbk (font-spec :family "微软雅黑"))
755-
756- )
738+ (defun my-font-installed-p (font-name)
739+ "Check if font with FONT-NAME is available."
740+ (find-font (font-spec :name font-name)))
741+
742+ (defun my-setup-fonts ()
743+ "Setup fonts."
744+ (when (display-graphic-p)
745+ ;; Set default font
746+ (cl-loop for font in '("CaskaydiaCove NFP" "Fira Code" "Jetbrains Mono"
747+ "SF Mono" "Hack" "Source Code Pro" "Menlo"
748+ "Monaco" "DejaVu Sans Mono" "Consolas")
749+ when (my-font-installed-p font)
750+ return (set-face-attribute 'default nil
751+ :family font
752+ :height 120))
753+
754+ ;; Specify font for all unicode characters
755+ (cl-loop for font in '("Segoe UI Emoji" "Apple Symbols" "Symbola" "Symbol")
756+ when (my-font-installed-p font)
757+ return (set-fontset-font t 'symbol (font-spec :family font) nil 'prepend))
758+
759+ ;; Emoji
760+ (cl-loop for font in '("Segoe UI Emoji" "Noto Color Emoji" "Apple Color Emoji")
761+ when (my-font-installed-p font)
762+ return (set-fontset-font t
763+ (if (< emacs-major-version 28)'symbol 'emoji)
764+ (font-spec :family font) nil 'prepend))
765+
766+ ;; Specify font for Chinese characters
767+ (cl-loop for font in '("微软雅黑" "WenQuanYi Micro Hei Mono")
768+ when (my-font-installed-p font)
769+ return (set-fontset-font t 'han (font-spec :family font)))))
770+
771+ (my-setup-fonts)
772+ (add-hook 'window-setup-hook #'my-setup-fonts)
773+ (add-hook 'server-after-make-frame-hook #'my-setup-fonts)
757774
775+ (ignore-errors
776+ (load-theme 'modus-operandi-tinted :no-confirm))
758777
759- ;;(load-theme 'modus-operandi-tinted :no-confirm)
778+ (use-package nerd-icons
779+ :straight t
780+ :init
781+ (cl-loop for font in '("CaskaydiaCove NFP" "Symbols Nerd Font Mono")
782+ when (my-font-installed-p font)
783+ return (setq nerd-icons-font-family font)))
760784#+end_src
761785
762786** ligature 连字体
@@ -2119,19 +2143,20 @@ ref:https://github.com/manateelazycat/toggle-one-window
21192143 (org-use-sub-superscripts '{})
21202144 :config
21212145
2122- (create-fontset-from-fontset-spec
2123- (font-xlfd-name
2124- (font-spec :family "等距更纱黑体 SC"
2125- :weight 'regular
2126- :slant 'normal
2127- :registry "fontset-orgtable")))
2146+ (when (my-font-installed-p "等距更纱黑体 SC")
2147+ (create-fontset-from-fontset-spec
2148+ (font-xlfd-name
2149+ (font-spec :family "等距更纱黑体 SC"
2150+ :weight 'regular
2151+ :slant 'normal
2152+ :registry "fontset-orgtable")))
21282153
2129- (set-fontset-font "fontset-orgtable" '(#x0 . #xffff)
2130- (font-spec :family "等距更纱黑体 SC"
2131- :weight 'regular
2132- :slant 'normal))
2154+ (set-fontset-font "fontset-orgtable" '(#x0 . #xffff)
2155+ (font-spec :family "等距更纱黑体 SC"
2156+ :weight 'regular
2157+ :slant 'normal))
21332158
2134- (set-face-attribute 'org-table nil :fontset "fontset-orgtable" :font "fontset-orgtable")
2159+ (set-face-attribute 'org-table nil :fontset "fontset-orgtable" :font "fontset-orgtable") )
21352160
21362161 (defun my--org-prettify-symbols ()
21372162 (setq prettify-symbols-alist
0 commit comments