References

2024-12-26 이맥스 폰트 스케일 특히 이모지 유니코드 수학 기호 등

[2024-12-25 Wed 05:56]

이모지 - 꼭 뭐는 스케일링

https://whhone.com/emacs-config/

Appearance Font and Font Size Scaling

My default font is “Hack” or “Meslo”. I also use “WenQuanYi Micro Hei” for Chinese, Japanese, and Korean characters (CJK) and “Noto Color Emoji” for emojis.

Different fonts can have different widths and heights, even when they are the same size. For example, size 10 of font A might be bigger than size 10 of font B. This can make things look uneven. I rescale the font with face-font-rescale-alist so that they have the same width (I might get the same height if I am lucky). This makes things look better, especially in tables in org mode.

;; https://whhone.com/emacs-config/
(defun my/set-fonts (default-font-name
                     default-font-height
                     cjk-font-name
                     cjk-font-scale
                     unicode-font-name
                     unicode-font-scale
                     emoji-font-name
                     emoji-font-scale
                     )
  "Helper function to set the default, CJK and Emoji fonts."
  ;; Set the default font
  (when (member default-font-name (font-family-list))
    (set-face-attribute 'default nil
                        :family default-font-name
                        :height default-font-height)
    (set-frame-font default-font-name nil t))
 
  ;; Set the CJK font in the default fontset.
  (when (member cjk-font-name (font-family-list))
    (dolist (script (list 'han 'kana 'cjk-misc))
      (set-fontset-font t script cjk-font-name)))
 
  (when (member unicode-font-name (font-family-list))
    (set-fontset-font t 'unicode unicode-font-name nil 'prepend)
    (set-fontset-font t 'mathematical unicode-font-name nil 'prepend)
    (set-fontset-font t 'symbol unicode-font-name nil 'prepend))
 
  ;; Set the Emoji font in the default fontset.
  (when (member emoji-font-name (font-family-list))
    (set-fontset-font t 'emoji emoji-font-name nil 'prepend))
 
  ;; Rescale the CJK and emoji fonts.
  (setq face-font-rescale-alist
        `((,(format ".*%s.*" cjk-font-name) . ,cjk-font-scale)
          (,(format ".*%s.*" unicode-font-name) . ,unicode-font-scale)
          (,(format ".*%s.*" emoji-font-name) . ,emoji-font-scale)
          )))
 
;; Different computers might need different scaling factors with the same fonts.
(cond
 ;; MacOS, HiDPI
 ((eq system-type 'darwin)
  (my/set-fonts
   "Menlo" 140
   "Hiragino Sans CNS" 1.2
   "Symbola" 1.2
   "Apple Color Emoji" 0.9))
 ;; Default Linux
 (t
  (my/set-fonts
   "Monoplex KR Nerd" 140
   "Monoplex KR Nerd" 1.0
   "Symbola" 0.9 ; unicode
   "Noto Emoji" 0.9
   )))