Created
April 17, 2017 07:54
-
-
Save IS-Kuan/a6782c3e88402c6585767c5c643b0cd1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; ============================================ | |
;; Coldnew's Font Size Conf for Org-Table | |
;; ============================================ | |
;; 特殊字型設定 | |
(when (window-system) | |
(if (eq system-type 'windows-nt) | |
(set-face-attribute 'default nil :font "Consolas-9")) | |
(defvar emacs-english-font "DejaVu Sans Mono" "The font name of English.") | |
(defvar emacs-cjk-font "文泉驛等寬微米黑" "The font name for CJK.") | |
(if (eq system-type 'windows-nt) | |
(setq emacs-cjk-font "Consolas" | |
emacs-english-font "Consolas") | |
(setq emacs-cjk-font "WenQuanYi Micro Hei Mono")) | |
(defvar emacs-font-size-pair '(12 . 14) | |
"Default font size pair for (english . chinese)") | |
(defvar emacs-font-size-pair-list | |
'(( 5 . 6) (9 . 10) (10 . 12)(12 . 14) | |
(13 . 16) (15 . 18) (17 . 20) (19 . 22) | |
(20 . 24) (21 . 26) (24 . 28) (26 . 32) | |
(28 . 34) (30 . 36) (34 . 40) (36 . 44)) | |
"This list is used to store matching (englis . chinese) font-size.") | |
(defun font-exist-p (fontname) | |
"Test if this font is exist or not." | |
(if (or (not fontname) (string= fontname "")) | |
nil | |
(if (not (x-list-fonts fontname)) nil t))) | |
(defun set-font (english chinese size-pair) | |
"Setup emacs English and Chinese font on x window-system." | |
(if (font-exist-p english) | |
(set-frame-font (format "%s:pixelsize=%d" english (car size-pair)) t)) | |
(if (font-exist-p chinese) | |
(dolist (charset '(kana han symbol cjk-misc bopomofo)) | |
(set-fontset-font (frame-parameter nil 'font) charset | |
(font-spec :family chinese :size (cdr size-pair)))))) | |
;; Setup font size based on emacs-font-size-pair | |
(set-font emacs-english-font emacs-cjk-font emacs-font-size-pair) | |
(defun emacs-step-font-size (step) | |
"Increase/Decrease emacs's font size." | |
(let ((scale-steps emacs-font-size-pair-list)) | |
(if (< step 0) (setq scale-steps (reverse scale-steps))) | |
(setq emacs-font-size-pair | |
(or (cadr (member emacs-font-size-pair scale-steps)) | |
emacs-font-size-pair)) | |
(when emacs-font-size-pair | |
(message "emacs font size set to %.1f" (car emacs-font-size-pair)) | |
(set-font emacs-english-font emacs-cjk-font emacs-font-size-pair)))) | |
(defun increase-emacs-font-size () | |
"Decrease emacs's font-size acording emacs-font-size-pair-list." | |
(interactive) (emacs-step-font-size 1)) | |
(defun decrease-emacs-font-size () | |
"Increase emacs's font-size acording emacs-font-size-pair-list." | |
(interactive) (emacs-step-font-size -1)) | |
(global-set-key (kbd "C-=") 'increase-emacs-font-size) | |
(global-set-key (kbd "C--") 'decrease-emacs-font-size) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment