emacs.d

My emacs configuration, done in a literate programming fashion using org-mode

git clone git://git.shimmy1996.com/emacs.d.git
commit e7461ada04bf5aef9a2e69b54416d533b50b54c8
parent 6813bd610e0a6e6a612a92399b041e2d5973e472
Author: Shimmy Xu <shimmy.xu@shimmy1996.com>
Date:   Fri, 22 Jun 2018 09:24:54 -0500

Add unicode font fallback.

Diffstat:
MREADME.org | 43++++++++++++++++++++++++++++---------------
1 file changed, 28 insertions(+), 15 deletions(-)
diff --git a/README.org b/README.org
@@ -102,23 +102,35 @@ It would also help to change the default command for =emacs= into:
 
 ** Font Settings
 *** Default Fonts
-Specify both Latin font and CJK font.
+Specify font settings.
 #+BEGIN_SRC emacs-lisp
+  (defvar user/cjk-font "Noto Sans CJK SC"
+    "Default font for CJK characters.")
+
   (defvar user/latin-font "Iosevka Term"
     "Default font for Latin characters.")
 
-  (defvar user/cjk-font "Noto Sans CJK SC"
-    "Default font for CJK characters.")
+  (defvar user/unicode-font "Symbola"
+    "Default font for Unicode characters, including emojis.")
 
   (defvar user/font-size 17
     "Default font size in px.")
+
+  (defvar user/standard-fontset
+    (create-fontset-from-fontset-spec standard-fontset-spec)
+    "Standard fontset for user.")
 #+END_SRC
 
-*** CJK Font Fallback Logic
-Fallback logic for CJK fonts, ensures correct font and size gets used for CJK.
+*** CJK Font Scaling
+Ensure CJK fonts scales correctly to twice the width of mono-space half-width
+characters. I tried to add something similar for Unicode fonts, but found that
+they don't have uniform width anyways (not to mention that not all of them are
+full-width), rendering this method useless.
+
+I think CJK fonts has less granular sizing controls, i.e. the actual glyph size
+of size 16 and size 17 are in fact the same and only starts actually increasing
+after we hit size 18.
 
-**** CJK Font Scaling.
-Ensure CJK fonts scales correctly to twice the width of half-width characters.
 #+BEGIN_SRC emacs-lisp
   (defvar user/cjk-font-scale
     '((16 . 1.0)
@@ -132,24 +144,25 @@ Ensure CJK fonts scales correctly to twice the width of half-width characters.
                     (cdr (assoc user/font-size user/cjk-font-scale)))))
 #+END_SRC
 
-**** CJK Enabled Fontset
+*** Fontset with CJK and Unicode Fallback
 To ensure fontset gets correctly configured, I simply created one from
 scratch. This is because =emacsclient= seems to have a different dynamic when
 creating =startup-fontset= and no other method guarantees consistent behavior
 between =emacs= and =emacsclient=.
 
 #+BEGIN_SRC emacs-lisp
-  (defvar user/standard-fontset
-    (create-fontset-from-fontset-spec standard-fontset-spec)
-    "User fontset with cjk font fallback.")
-
-  ;; Enable font customization for charset symbols.
-  ;; This charset contains puncuation marks, emoji, and etc..
+  ;; Enable font customization for charset symbols.  This charset contains
+  ;; puncuation marks, emoji, etc.
   (setq use-default-font-for-symbols nil)
 
   (defun user/set-font ()
-    "Set Latin and CJK font for user/standard-fontset."
+    "Set Unicode, Latin and CJK font for user/standard-fontset."
+    ;; Unicode font.
+    (set-fontset-font user/standard-fontset 'unicode
+                      (font-spec :family user/unicode-font)
+                      nil 'prepend)
     ;; Latin font.
+    ;; Only specify size here to allow text-scale-adjust work on other fonts.
     (set-fontset-font user/standard-fontset 'latin
                       (font-spec :family user/latin-font :size user/font-size)
                       nil 'prepend)