Add dotspacemacs-default-font
variable and spacemacs-fonts-support.el
Resolves #482
This commit is contained in:
parent
4e14012625
commit
b7ee5e7ea4
|
@ -41,6 +41,14 @@ with 2 themes variants, one dark and one light")
|
||||||
"Major mode leader key is a shortcut key which is the equivalent of
|
"Major mode leader key is a shortcut key which is the equivalent of
|
||||||
pressing `<leader> m`")
|
pressing `<leader> m`")
|
||||||
|
|
||||||
|
(defvar dotspacemacs-default-font '("Source Code Pro"
|
||||||
|
:size 13
|
||||||
|
:weight normal
|
||||||
|
:width normal
|
||||||
|
:powerline-offset 2)
|
||||||
|
"Default font. The powerline-offset allows to quickly tweak the mode-line
|
||||||
|
size to make separators look not too crappy.")
|
||||||
|
|
||||||
(defvar dotspacemacs-command-key ":"
|
(defvar dotspacemacs-command-key ":"
|
||||||
"The key used for Evil commands (ex-commands) and Emacs commands (M-x).
|
"The key used for Evil commands (ex-commands) and Emacs commands (M-x).
|
||||||
By default the command key is `:' so ex-commands are executed like in Vim
|
By default the command key is `:' so ex-commands are executed like in Vim
|
||||||
|
|
58
core/spacemacs-fonts-support.el
Normal file
58
core/spacemacs-fonts-support.el
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
;;; fonts-support.el --- Spacemacs Core File
|
||||||
|
;;
|
||||||
|
;; Copyright (c) 2012-2014 Sylvain Benner
|
||||||
|
;; Copyright (c) 2014-2015 Sylvain Benner & Contributors
|
||||||
|
;;
|
||||||
|
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
|
||||||
|
;; URL: https://github.com/syl20bnr/spacemacs
|
||||||
|
;;
|
||||||
|
;; This file is not part of GNU Emacs.
|
||||||
|
;;
|
||||||
|
;;; License: GPLv3
|
||||||
|
(require 'spacemacs-funcs)
|
||||||
|
|
||||||
|
(defun spacemacs/set-font (plist)
|
||||||
|
"Set the font given the passed PLIST.
|
||||||
|
|
||||||
|
PLIST has the form (\"fontname\" :prop1 val1 :prop2 val2 ...)"
|
||||||
|
(let* ((font (car plist))
|
||||||
|
(props (cdr plist))
|
||||||
|
(powerline-offset (plist-get props :powerline-offset))
|
||||||
|
(font-props (spacemacs/mplist-remove props :powerline-offset))
|
||||||
|
(fontspec (apply 'font-spec :family font font-props)))
|
||||||
|
(set-default-font fontspec nil t)
|
||||||
|
(setq-default powerline-height (+ powerline-offset (frame-char-height)))
|
||||||
|
;; fallback font for unicode characters used in spacemacs
|
||||||
|
(pcase system-type
|
||||||
|
("gnu/linux"
|
||||||
|
(setq fallback-font-name "NanumGothic")
|
||||||
|
(setq fallback-font-name2 "NanumGothic"))
|
||||||
|
("darwin"
|
||||||
|
(setq fallback-font-name "Arial Unicode MS")
|
||||||
|
(setq fallback-font-name2 "Arial Unicode MS"))
|
||||||
|
("windows-nt"
|
||||||
|
(setq fallback-font-name "MS Gothic")
|
||||||
|
(setq fallback-font-name2 "Lucida Sans Unicode"))
|
||||||
|
(other
|
||||||
|
(setq fallback-font-name nil)
|
||||||
|
(setq fallback-font-name2 nil)))
|
||||||
|
(when (and fallback-font-name fallback-font-name2)
|
||||||
|
(let ((fallback-spec (apply 'font-spec
|
||||||
|
:family fallback-font-name font-props))
|
||||||
|
(fallback-spec2 (apply 'font-spec
|
||||||
|
:family fallback-font-name2 font-props)))
|
||||||
|
;; 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)
|
||||||
|
;; mode-line additional characters (i.e. golden ratio)
|
||||||
|
(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)))
|
||||||
|
))
|
||||||
|
|
||||||
|
(provide 'spacemacs-fonts-support)
|
|
@ -15,6 +15,7 @@
|
||||||
(require 'subr-x nil 'noerror)
|
(require 'subr-x nil 'noerror)
|
||||||
(require 'emacs-backports)
|
(require 'emacs-backports)
|
||||||
(require 'themes-support)
|
(require 'themes-support)
|
||||||
|
(require 'spacemacs-fonts-support)
|
||||||
(require 'spacemacs-buffer)
|
(require 'spacemacs-buffer)
|
||||||
|
|
||||||
(defconst spacemacs-repository "spacemacs"
|
(defconst spacemacs-repository "spacemacs"
|
||||||
|
@ -89,15 +90,7 @@
|
||||||
"able to launch a graphical instance of Emacs"
|
"able to launch a graphical instance of Emacs"
|
||||||
"with this build.")))
|
"with this build.")))
|
||||||
;; font
|
;; font
|
||||||
;; Dynamic font size depending on the system
|
(spacemacs/set-font dotspacemacs-default-font)
|
||||||
(let ((font "Source Code Pro"))
|
|
||||||
(when (member font (font-family-list))
|
|
||||||
(pcase window-system
|
|
||||||
(`x (spacemacs/set-font font 10))
|
|
||||||
(`mac (spacemacs/set-font font 12))
|
|
||||||
(`w32 (spacemacs/set-font font 13))
|
|
||||||
(other (spacemacs/set-font font 10)))))
|
|
||||||
|
|
||||||
;; banner
|
;; banner
|
||||||
(spacemacs//insert-banner)
|
(spacemacs//insert-banner)
|
||||||
;; bind-key is required by use-package
|
;; bind-key is required by use-package
|
||||||
|
@ -310,46 +303,4 @@ version and the NEW version."
|
||||||
((< diff 5000) 'spacemacs-mode-line-new-version-lighter-warning-face)
|
((< diff 5000) 'spacemacs-mode-line-new-version-lighter-warning-face)
|
||||||
(t 'spacemacs-mode-line-new-version-lighter-error-face))))
|
(t 'spacemacs-mode-line-new-version-lighter-error-face))))
|
||||||
|
|
||||||
(defun spacemacs/set-font (font size &optional options)
|
|
||||||
(let* ((fontstr (if options
|
|
||||||
(format "%s-%s:%s" font size options)
|
|
||||||
(format "%s-%s" font size))))
|
|
||||||
(spacemacs/message (format "Set default font: %s" fontstr))
|
|
||||||
;; (add-to-list 'default-frame-alist `(font . ,fontstr) `(height . ,(* 10 size)))
|
|
||||||
(set-default-font (font-spec :family font
|
|
||||||
:size size
|
|
||||||
:weight 'normal
|
|
||||||
:width 'normal))
|
|
||||||
(setq-default powerline-height (+ size 4))
|
|
||||||
(pcase window-system
|
|
||||||
(`x (setq fallback-font-name nil)
|
|
||||||
(setq fallback-font-name2 nil))
|
|
||||||
(`mac (setq fallback-font-name nil)
|
|
||||||
(setq fallback-font-name2 nil))
|
|
||||||
(`w32 (setq fallback-font-name "MS Gothic")
|
|
||||||
(setq fallback-font-name2 "Lucida Sans Unicode"))
|
|
||||||
(other (setq fallback-font-name nil)
|
|
||||||
(setq fallback-font-name2 nil)))
|
|
||||||
(when (and fallback-font-name fallback-font-name2)
|
|
||||||
(let ((fallback-font (font-spec :family fallback-font-name
|
|
||||||
:size size
|
|
||||||
:weight 'normal
|
|
||||||
:width 'normal))
|
|
||||||
(fallback-font2 (font-spec :family fallback-font-name2
|
|
||||||
:size size
|
|
||||||
:weight 'normal
|
|
||||||
:width 'normal)))
|
|
||||||
;; window numbers
|
|
||||||
(set-fontset-font "fontset-default"
|
|
||||||
'(#x2776 . #x2793) fallback-font nil 'prepend)
|
|
||||||
;; mode-line circled letters
|
|
||||||
(set-fontset-font "fontset-default"
|
|
||||||
'(#x24b6 . #x24fe) fallback-font nil 'prepend)
|
|
||||||
;; mode-line additional characters (i.e. golden ratio)
|
|
||||||
(set-fontset-font "fontset-default"
|
|
||||||
'(#x2295 . #x22a1) fallback-font nil 'prepend)
|
|
||||||
;; new version lighter
|
|
||||||
(set-fontset-font "fontset-default"
|
|
||||||
'(#x2190 . #x2200) fallback-font2 nil 'prepend)))))
|
|
||||||
|
|
||||||
(provide 'spacemacs-mode)
|
(provide 'spacemacs-mode)
|
||||||
|
|
|
@ -28,6 +28,13 @@
|
||||||
;; Press <SPC> T n to cycle to the next theme in the list (works great
|
;; Press <SPC> T n to cycle to the next theme in the list (works great
|
||||||
;; with 2 themes variants, one dark and one light)
|
;; with 2 themes variants, one dark and one light)
|
||||||
dotspacemacs-themes '(solarized-light solarized-dark)
|
dotspacemacs-themes '(solarized-light solarized-dark)
|
||||||
|
;; Default font. The powerline-offset allows to quickly tweak the mode-line
|
||||||
|
;; size to make separators look not too crappy.
|
||||||
|
dotspacemacs-default-font '("Source Code Pro"
|
||||||
|
:size 13
|
||||||
|
:weight normal
|
||||||
|
:width normal
|
||||||
|
:powerline-offset 2)
|
||||||
;; The leader key
|
;; The leader key
|
||||||
dotspacemacs-leader-key "SPC"
|
dotspacemacs-leader-key "SPC"
|
||||||
;; Major mode leader key is a shortcut key which is the equivalent of
|
;; Major mode leader key is a shortcut key which is the equivalent of
|
||||||
|
|
|
@ -1662,12 +1662,6 @@ which require an initialization must be listed explicitly in the list.")
|
||||||
(setq spacemacs-mode-line-new-version-lighterp t)))
|
(setq spacemacs-mode-line-new-version-lighterp t)))
|
||||||
(evil-leader/set-key "tmv" 'spacemacs/mode-line-new-version-lighter-toggle)
|
(evil-leader/set-key "tmv" 'spacemacs/mode-line-new-version-lighter-toggle)
|
||||||
|
|
||||||
;; disable this hack for now to see if we can fix it differently
|
|
||||||
;; for now we hardcode the height value of powerline depending on the
|
|
||||||
;; window system, a better solution would be to compute it correctly
|
|
||||||
;; in powerline package.
|
|
||||||
;; (let ((height (if (eq 'w32 window-system) 18 17)))
|
|
||||||
;; (setq-default powerline-height height))
|
|
||||||
(setq-default powerline-default-separator 'wave)
|
(setq-default powerline-default-separator 'wave)
|
||||||
|
|
||||||
(defun spacemacs/mode-line-prepare-left ()
|
(defun spacemacs/mode-line-prepare-left ()
|
||||||
|
|
Loading…
Reference in a new issue