.emacs.d/elisp/init-fonts.el

85 lines
3.0 KiB
EmacsLisp

;;; init-fonts.el --- -*- lexical-binding: t -*-
;;
;; Filename: init-fonts.el
;; Description: Initialize Fonts
;; Author: Mingde (Matthew) Zeng
;; Copyright (C) 2019 Mingde (Matthew) Zeng
;; Created: Thu Mar 14 17:32:54 2019 (-0400)
;; Version: 2.0.0
;; Last-Updated: lun. janv. 13 10:50:18 2020 (+0100)
;; By: Mikaël Capelle
;; URL: https://github.com/MatthewZMD/.emacs.d
;; Keywords: M-EMACS .emacs.d fonts
;; Compatibility: emacs-version >= 26.1
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Commentary:
;;
;; This initializes fonts
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or (at
;; your option) any later version.
;;
;; This program is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Code:
(eval-when-compile
(require 'init-const))
;; FontsList
;; Input Mono, Monaco Style, Line Height 1.3 download
;; from http://input.fontbureau.com/
(defvar font-list '(
("Fira Mono for Powerline" . 11)
("Fira Mono" . 11)
("Input" . 11)
("SF Mono" . 12)
("Consolas" . 12) ("Love LetterTW" . 12.5))
"List of fonts and sizes. The first one available will be used.")
;; -FontsList
;; FontFun
(defun change-font ()
"Documentation."
(interactive)
(let* (available-fonts font-name font-size font-setting)
(dolist (font font-list (setq available-fonts (nreverse available-fonts)))
(when (member (car font) (font-family-list))
(push font available-fonts)))
(if (not available-fonts)
(message "No fonts from the chosen set are available")
(if (called-interactively-p 'interactive)
(let* ((chosen
(assoc-string
(completing-read "What font to use? " available-fonts nil t)
available-fonts)))
(setq font-name (car chosen)
font-size (read-number "Font size: " (cdr chosen))))
(setq font-name (caar available-fonts)
font-size (cdar available-fonts)))
(setq font-setting (format "%s-%d" font-name font-size))
(set-frame-font font-setting nil t)
(add-to-list 'default-frame-alist (cons 'font font-setting)))))
(when *sys/gui*
(change-font))
;; -FontFun
(provide 'init-fonts)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; init-fonts.el ends here