69 lines
2.9 KiB
EmacsLisp
69 lines
2.9 KiB
EmacsLisp
;; init-font.el --- Fonts settings -*- lexical-binding: t -*-
|
|
|
|
;;; Commentary:
|
|
|
|
;;; Code:
|
|
|
|
(defun font-installed-p (font-name)
|
|
"Check if font with FONT-NAME is available."
|
|
(find-font (font-spec :name font-name)))
|
|
|
|
(defconst sys/macp
|
|
(eq system-type 'darwin)
|
|
"Are we running on a Mac system?")
|
|
|
|
(defconst sys/win32p
|
|
(eq system-type 'windows-nt)
|
|
"Are we running on a WinTel system?")
|
|
|
|
(defun centaur-setup-fonts ()
|
|
"Setup fonts."
|
|
(when (display-graphic-p)
|
|
;; Set default font
|
|
(cl-loop for font in '("Sarasa Term SC Nerd" "Cascadia Code" "Fira Code" "Jetbrains Mono"
|
|
"SF Mono" "Hack" "Source Code Pro" "Menlo"
|
|
"Monaco" "DejaVu Sans Mono" "Consolas"
|
|
)
|
|
when (font-installed-p font)
|
|
return (set-face-attribute 'default nil
|
|
:family font
|
|
:height (cond (sys/macp 160)
|
|
(sys/win32p 110)
|
|
(t 100))))
|
|
|
|
;; Set mode-line font
|
|
;; (cl-loop for font in '("Menlo" "SF Pro Display" "Helvetica")
|
|
;; when (font-installed-p font)
|
|
;; return (progn
|
|
;; (set-face-attribute 'mode-line nil :family font :height 120)
|
|
;; (when (facep 'mode-line-active)
|
|
;; (set-face-attribute 'mode-line-active nil :family font :height 120))
|
|
;; (set-face-attribute 'mode-line-inactive nil :family font :height 120)))
|
|
|
|
;; Specify font for all unicode characters
|
|
(cl-loop for font in '("Apple Symbols" "Segoe UI Symbol" "Symbola" "Symbol")
|
|
when (font-installed-p font)
|
|
return (set-fontset-font t 'symbol (font-spec :family font) nil 'prepend))
|
|
|
|
;; Emoji
|
|
(cl-loop for font in '("Noto Color Emoji" "Apple Color Emoji" "Segoe UI Emoji")
|
|
when (font-installed-p font)
|
|
return (set-fontset-font t
|
|
(if (< emacs-major-version 28)'symbol 'emoji)
|
|
(font-spec :family font) nil 'prepend))
|
|
|
|
;; Specify font for Chinese characters
|
|
(cl-loop for font in '("TsangerJinKai03-6763 W05" "LXGW Neo Xihei" "WenQuanYi Micro Hei Mono" "LXGW WenKai Screen"
|
|
"LXGW WenKai Mono" "PingFang SC" "Microsoft Yahei UI" "Simhei")
|
|
when (font-installed-p font)
|
|
return (progn
|
|
(setq face-font-rescale-alist `((,font . 1.3)))
|
|
(set-fontset-font t 'han (font-spec :family font))))))
|
|
(centaur-setup-fonts)
|
|
(add-hook 'window-setup-hook #'centaur-setup-fonts)
|
|
(add-hook 'server-after-make-frame-hook #'centaur-setup-fonts)
|
|
|
|
(provide 'init-font)
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
;;; init-font.el ends here
|