Merge pull request #2029 from jsravn/download-iosevka
Add +pretty-code/install-iosevka-font
This commit is contained in:
commit
bbc3245cb3
5 changed files with 118 additions and 1 deletions
19
modules/ui/pretty-code/autoload/fira.el
Normal file
19
modules/ui/pretty-code/autoload/fira.el
Normal file
|
@ -0,0 +1,19 @@
|
|||
;;; ui/pretty-code/autoload/fira.el -*- lexical-binding: t; -*-
|
||||
|
||||
(defvar +pretty-code--fira-font-names
|
||||
'("FiraCode-Bold.ttf"
|
||||
"FiraCode-Light.ttf"
|
||||
"FiraCode-Medium.ttf"
|
||||
"FiraCode-Regular.ttf"
|
||||
"FiraCode-Retina.ttf"))
|
||||
|
||||
;;;###autoload
|
||||
(defun +pretty-code/install-fira-font (&optional prefix)
|
||||
"Download and install Fira Code font based on OS.
|
||||
When prefix is non-nil, ignore the prompt and just install."
|
||||
(interactive "P")
|
||||
(+pretty-code--install-font
|
||||
prefix
|
||||
"FiraCode"
|
||||
"https://github.com/tonsky/FiraCode/raw/13234c0/distr/ttf/%s"
|
||||
+pretty-code--fira-font-names))
|
28
modules/ui/pretty-code/autoload/hasklig.el
Normal file
28
modules/ui/pretty-code/autoload/hasklig.el
Normal file
|
@ -0,0 +1,28 @@
|
|||
;;; ui/pretty-code/autoload/hasklig.el -*- lexical-binding: t; -*-
|
||||
|
||||
(defvar +pretty-code--hasklig-font-names
|
||||
'("Hasklig-Black.otf"
|
||||
"Hasklig-BlackIt.otf"
|
||||
"Hasklig-Bold.otf"
|
||||
"Hasklig-BoldIt.otf"
|
||||
"Hasklig-ExtraLight.otf"
|
||||
"Hasklig-ExtraLightIt.otf"
|
||||
"Hasklig-It.otf"
|
||||
"Hasklig-Light.otf"
|
||||
"Hasklig-LightIt.otf"
|
||||
"Hasklig-Medium.otf"
|
||||
"Hasklig-MediumIt.otf"
|
||||
"Hasklig-Regular.otf"
|
||||
"Hasklig-Semibold.otf"
|
||||
"Hasklig-SemiboldIt.otf"))
|
||||
|
||||
;;;###autoload
|
||||
(defun +pretty-code/install-hasklig-font (&optional prefix)
|
||||
"Download and install Hasklig font based on OS.
|
||||
When prefix is non-nil, ignore the prompt and just install."
|
||||
(interactive "P")
|
||||
(+pretty-code--install-font
|
||||
prefix
|
||||
"Hasklig"
|
||||
"https://github.com/jsravn/hasklig-emacs/raw/33354a3/%s"
|
||||
+pretty-code--hasklig-font-names))
|
35
modules/ui/pretty-code/autoload/iosevka.el
Normal file
35
modules/ui/pretty-code/autoload/iosevka.el
Normal file
|
@ -0,0 +1,35 @@
|
|||
;;; ui/pretty-code/autoload/iosevka.el -*- lexical-binding: t; -*-
|
||||
|
||||
(defvar +pretty-code--iosevka-font-names
|
||||
'("iosevka-custom-lightoblique.ttf"
|
||||
"iosevka-custom-thinoblique.ttf"
|
||||
"iosevka-custom-mediumitalic.ttf"
|
||||
"iosevka-custom-light.ttf"
|
||||
"iosevka-custom-heavy.ttf"
|
||||
"iosevka-custom-bolditalic.ttf"
|
||||
"iosevka-custom-bold.ttf"
|
||||
"iosevka-custom-lightitalic.ttf"
|
||||
"iosevka-custom-thin.ttf"
|
||||
"iosevka-custom-extralight.ttf"
|
||||
"iosevka-custom-oblique.ttf"
|
||||
"iosevka-custom-italic.ttf"
|
||||
"iosevka-custom-heavyoblique.ttf"
|
||||
"iosevka-custom-heavyitalic.ttf"
|
||||
"iosevka-custom-extralightitalic.ttf"
|
||||
"iosevka-custom-thinitalic.ttf"
|
||||
"iosevka-custom-medium.ttf"
|
||||
"iosevka-custom-mediumoblique.ttf"
|
||||
"iosevka-custom-extralightoblique.ttf"
|
||||
"iosevka-custom-boldoblique.ttf"
|
||||
"iosevka-custom-regular.ttf"))
|
||||
|
||||
;;;###autoload
|
||||
(defun +pretty-code/install-iosevka-font (&optional prefix)
|
||||
"Download and install Iosevka font based on OS.
|
||||
When prefix is non-nil, ignore the prompt and just install."
|
||||
(interactive "P")
|
||||
(+pretty-code--install-font
|
||||
prefix
|
||||
"Iosevka"
|
||||
"https://github.com/jsravn/iosevka-emacs/raw/20fc2c4/%s"
|
||||
+pretty-code--iosevka-font-names))
|
|
@ -1,4 +1,4 @@
|
|||
;;; ui/pretty-code/settings.el -*- lexical-binding: t; -*-
|
||||
;;; ui/pretty-code/autoload/pretty-code.el -*- lexical-binding: t; -*-
|
||||
|
||||
;;;###autoload
|
||||
(defvar +pretty-code-symbols-alist '((t))
|
|
@ -95,3 +95,38 @@ Otherwise it builds `prettify-code-symbols-alist' according to
|
|||
(load! "+hasklig"))
|
||||
((featurep! +pragmata-pro)
|
||||
(load! "+pragmata-pro")))
|
||||
|
||||
(defun +pretty-code--install-font (prefix name url-format fonts-alist)
|
||||
"Install fonts to the local system.
|
||||
|
||||
If PREFIX is nil, will prompt whether or not to download. NAME is informational only.
|
||||
URL-FORMAT is a format string that should be a url and have a single %s, which is expanded
|
||||
for each font in FONTS-ALIST. FONTS-ALIST should be the filename of each font. It is used
|
||||
as the source and destination filename.
|
||||
"
|
||||
(when (or prefix (yes-or-no-p
|
||||
(format "This will download and install the %s fonts, are you sure you want to do this?" name)))
|
||||
(let* ((font-dest (cl-case window-system
|
||||
;; Linux
|
||||
(x (concat (or (getenv "XDG_DATA_HOME")
|
||||
(concat (getenv "HOME") "/.local/share"))
|
||||
"/fonts/"))
|
||||
;; MacOS
|
||||
(mac (concat (getenv "HOME") "/Library/Fonts/" ))
|
||||
(ns (concat (getenv "HOME") "/Library/Fonts/" ))))
|
||||
(known-dest? (stringp font-dest))
|
||||
(font-dest (or font-dest (read-directory-name "Font installation directory: " "~/"))))
|
||||
|
||||
(unless (file-directory-p font-dest) (mkdir font-dest t))
|
||||
|
||||
(dolist (font fonts-alist)
|
||||
(url-copy-file (format url-format font) (expand-file-name font font-dest) t))
|
||||
|
||||
(when known-dest?
|
||||
(message "Font downloaded, updating font cache... <fc-cache -f -v> ")
|
||||
(shell-command-to-string (format "fc-cache -f -v")))
|
||||
(message "Successfully %s `%s' fonts to `%s'!"
|
||||
(if known-dest? "installed" "downloaded")
|
||||
name
|
||||
font-dest)))
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue