经验分享:emacs单独设置中文与英语的字体

我又更新了,因为看到rescale这个方法

;; setting fonts
(use-package faces
  :custom-face
  (variable-pitch
   ((t (:font ,(font-xlfd-name (font-spec :family "Iosevka"
                                          :foundry "Outline"
                                          ;; If we do not specify this, Emacs
                                          ;; selects ascii and we miss accents
                                          :registry "iso10646-1"))
              :slant normal :weight normal
              :height 138 :width normal))))
  (default
    ((t (:font ,(font-xlfd-name (font-spec :family "Comic Mono"
                                           :foundry "Outline"
                                           ;; If we do not specify this, Emacs
                                           ;; selects ascii and we miss accents
                                           :registry "iso10646-1"))
               :slant normal :weight normal
               :height 138 :width normal))))
  (fixed-pitch
   ((t (:inherit default))))

  :config
  (defun colawithsauce/set-unicode-fonts (frame)
    "Setting unicode-char fonts for emacs."
    ;; Use Noto for everything to get consistent view
    ;; Chinese, simplified
    (set-fontset-font t 'unicode (font-spec :family "Sarasa Mono Slab SC" :weight 'semi-bold) frame)
    ;; Symbols, including b/w emoji
    (set-fontset-font t 'symbol "Apple Color Emoji" frame 'prepend))
  (add-hook 'after-make-frame-functions #'colawithsauce/set-unicode-fonts)

  ;; Rescale to restrict font into same height.
  (add-to-list 'face-font-rescale-alist '("Apple Color Emoji" . 0.9))
  (add-to-list 'face-font-rescale-alist '("Sarasa Mono Slab SC" . 0.88))

  ;; Disable font rescale in variable-pitch mode
  (defun colawithsauce/disable-rescale-maybe ()
    "remove stuffs in `face-font-scale-alist' when in buffer-face-mode."
    (if buffer-face-mode
        (setq-local face-font-rescale-alist nil)
      (setq-local face-font-rescale-alist '(("Sarasa Mono Slab SC" . 0.88) ("Apple Color Emoji" . 0.9) ("-cdac$" . 1.3)))))
  (add-hook
   'buffer-face-mode-hook #'colawithsauce/disable-rescale-maybe))

然后打开了 variable-pitch 之后,关掉 rescale 的效果,可以见到 rescale 消失了,字体变大了

(P.S. 日语是因为我这段是抄了别人的配置)

1 个赞