2015-01-27 03:51:47 +00:00
|
|
|
;;; core-fonts-support.el --- Spacemacs Core File
|
2015-01-27 03:40:02 +00:00
|
|
|
;;
|
2016-01-12 02:40:54 +00:00
|
|
|
;; Copyright (c) 2012-2016 Sylvain Benner & Contributors
|
2015-01-27 03:40:02 +00:00
|
|
|
;;
|
|
|
|
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
|
|
|
|
;; URL: https://github.com/syl20bnr/spacemacs
|
|
|
|
;;
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
;;
|
|
|
|
;;; License: GPLv3
|
2015-01-27 03:51:47 +00:00
|
|
|
(require 'core-funcs)
|
2015-01-27 09:49:19 +00:00
|
|
|
(require 'core-spacemacs-buffer)
|
2015-01-27 03:40:02 +00:00
|
|
|
|
2015-08-14 16:25:54 +00:00
|
|
|
(defvar spacemacs--diminished-minor-modes nil
|
|
|
|
"List of diminished modes to unicode or ascii values.")
|
|
|
|
|
2015-01-27 09:49:19 +00:00
|
|
|
(defun spacemacs/set-default-font (plist)
|
2015-01-27 03:40:02 +00:00
|
|
|
"Set the font given the passed PLIST.
|
|
|
|
|
|
|
|
PLIST has the form (\"fontname\" :prop1 val1 :prop2 val2 ...)"
|
|
|
|
(let* ((font (car plist))
|
|
|
|
(props (cdr plist))
|
2015-01-28 02:46:37 +00:00
|
|
|
(scale (plist-get props :powerline-scale))
|
|
|
|
(font-props (spacemacs/mplist-remove
|
|
|
|
(spacemacs/mplist-remove props :powerline-scale)
|
|
|
|
:powerline-offset))
|
2015-01-30 02:42:35 +00:00
|
|
|
(fontspec (apply 'font-spec :name font font-props)))
|
2015-04-12 04:24:03 +00:00
|
|
|
(spacemacs-buffer/message "Setting font \"%s\"..." font)
|
2015-12-16 14:45:08 +00:00
|
|
|
(set-frame-font fontspec nil t)
|
2015-01-28 02:46:37 +00:00
|
|
|
(setq-default powerline-scale scale)
|
|
|
|
(setq-default powerline-height (spacemacs/compute-powerline-height))
|
2015-01-27 03:40:02 +00:00
|
|
|
;; fallback font for unicode characters used in spacemacs
|
|
|
|
(pcase system-type
|
2015-01-27 10:17:49 +00:00
|
|
|
(`gnu/linux
|
2015-01-27 03:40:02 +00:00
|
|
|
(setq fallback-font-name "NanumGothic")
|
|
|
|
(setq fallback-font-name2 "NanumGothic"))
|
2015-01-27 10:17:49 +00:00
|
|
|
(`darwin
|
2015-01-27 03:40:02 +00:00
|
|
|
(setq fallback-font-name "Arial Unicode MS")
|
|
|
|
(setq fallback-font-name2 "Arial Unicode MS"))
|
2015-01-27 10:17:49 +00:00
|
|
|
(`windows-nt
|
2015-01-27 03:40:02 +00:00
|
|
|
(setq fallback-font-name "MS Gothic")
|
|
|
|
(setq fallback-font-name2 "Lucida Sans Unicode"))
|
2015-01-30 14:01:04 +00:00
|
|
|
(`cygwin
|
|
|
|
(setq fallback-font-name "MS Gothic")
|
|
|
|
(setq fallback-font-name2 "Lucida Sans Unicode"))
|
2015-01-27 03:40:02 +00:00
|
|
|
(other
|
|
|
|
(setq fallback-font-name nil)
|
|
|
|
(setq fallback-font-name2 nil)))
|
|
|
|
(when (and fallback-font-name fallback-font-name2)
|
2015-01-28 02:47:25 +00:00
|
|
|
;; remove any size or height properties in order to be able to
|
|
|
|
;; scale the fallback fonts with the default one (for zoom-in/out
|
|
|
|
;; for instance)
|
|
|
|
(let* ((fallback-props (spacemacs/mplist-remove
|
|
|
|
(spacemacs/mplist-remove font-props :size)
|
|
|
|
:height))
|
|
|
|
(fallback-spec (apply 'font-spec
|
2015-01-30 02:42:35 +00:00
|
|
|
:name fallback-font-name
|
2015-01-28 02:47:25 +00:00
|
|
|
fallback-props))
|
|
|
|
(fallback-spec2 (apply 'font-spec
|
2015-01-30 02:42:35 +00:00
|
|
|
:name fallback-font-name2
|
2015-01-28 02:47:25 +00:00
|
|
|
fallback-props)))
|
2015-01-27 03:40:02 +00:00
|
|
|
;; window numbers
|
|
|
|
(set-fontset-font "fontset-default"
|
|
|
|
'(#x2776 . #x2793) fallback-spec nil 'prepend)
|
|
|
|
;; mode-line circled letters
|
|
|
|
(set-fontset-font "fontset-default"
|
|
|
|
'(#x24b6 . #x24fe) fallback-spec nil 'prepend)
|
2015-04-06 16:05:15 +00:00
|
|
|
;; mode-line additional characters
|
2015-01-27 03:40:02 +00:00
|
|
|
(set-fontset-font "fontset-default"
|
|
|
|
'(#x2295 . #x22a1) fallback-spec nil 'prepend)
|
|
|
|
;; new version lighter
|
|
|
|
(set-fontset-font "fontset-default"
|
|
|
|
'(#x2190 . #x2200) fallback-spec2 nil 'prepend)))
|
|
|
|
))
|
|
|
|
|
2015-01-28 02:46:37 +00:00
|
|
|
(defun spacemacs/compute-powerline-height ()
|
|
|
|
"Return an adjusted powerline height."
|
|
|
|
(let ((scale (if (and (boundp 'powerline-scale) powerline-scale)
|
|
|
|
powerline-scale 1)))
|
|
|
|
(truncate (* scale (frame-char-height)))))
|
|
|
|
|
2015-01-27 09:49:19 +00:00
|
|
|
(defun spacemacs/set-font (&rest args)
|
|
|
|
"Deprecated function, display a warning message."
|
2015-04-12 16:25:53 +00:00
|
|
|
(spacemacs-buffer/warning (concat "spacemacs/set-font is deprecated. "
|
2015-01-27 09:49:19 +00:00
|
|
|
"Use the variable `dotspacemacs-default-font' "
|
|
|
|
"instead (see Font section in "
|
2015-07-04 11:46:15 +00:00
|
|
|
"~/.emacs.d/doc/DOCUMENTATION.org for more "
|
2015-01-27 09:49:19 +00:00
|
|
|
"info).")))
|
|
|
|
|
2016-01-19 21:35:42 +00:00
|
|
|
(defmacro spacemacs|diminish (mode &optional unicode ascii)
|
2015-08-14 16:25:54 +00:00
|
|
|
"Diminish MODE name in mode line to UNICODE or ASCII depending on the value
|
|
|
|
`dotspacemacs-mode-line-unicode-symbols'.
|
2016-01-19 21:35:42 +00:00
|
|
|
If ASCII is not provided then UNICODE is used instead. If neither are provided,
|
|
|
|
the mode will not show in the mode line."
|
|
|
|
`(let ((cell (assq ',mode spacemacs--diminished-minor-modes)))
|
|
|
|
(if cell
|
|
|
|
(setcdr cell '(,unicode ,ascii))
|
|
|
|
(push '(,mode ,unicode ,ascii) spacemacs--diminished-minor-modes))))
|
2015-08-14 16:25:54 +00:00
|
|
|
|
|
|
|
(defmacro spacemacs|hide-lighter (mode)
|
|
|
|
"Diminish MODE name in mode line to LIGHTER."
|
|
|
|
`(eval-after-load 'diminish '(diminish ',mode)))
|
|
|
|
|
2015-01-27 03:51:47 +00:00
|
|
|
(provide 'core-fonts-support)
|