[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/show-font b951202b9b 29/54: Define commands to (i) prev
From: |
ELPA Syncer |
Subject: |
[elpa] externals/show-font b951202b9b 29/54: Define commands to (i) preview an installed font (ii) list+preview all installed fonts |
Date: |
Tue, 10 Sep 2024 03:58:58 -0400 (EDT) |
branch: externals/show-font
commit b951202b9bfa1bfd5187861b20848e71b63e09ed
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Define commands to (i) preview an installed font (ii) list+preview all
installed fonts
---
show-font.el | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 62 insertions(+)
diff --git a/show-font.el b/show-font.el
index d554d7358c..abc9ee19b6 100644
--- a/show-font.el
+++ b/show-font.el
@@ -126,6 +126,9 @@ x×X .,·°;:¡!¿?`'‘’ ÄAÃÀ TODO
"Face for smaller font preview title."
:group 'show-font-faces)
+(defface show-font-misc '((t :inherit shadow))
+ "Face for other, less important, elements in a preview.")
+
;;;; Helper functions
(defconst show-font-latin-alphabet
@@ -291,6 +294,65 @@ buffer."
(save-excursion
(insert (show-font--prepare-text)))))))
+(defmacro show-font-with-preview-buffer (name &rest body)
+ "Evaluate BODY inside NAME buffer."
+ (declare (indent 1))
+ `(let ((buffer (get-buffer-create ,name)))
+ (with-current-buffer buffer
+ (let ((inhibit-read-only t))
+ (erase-buffer)
+ ,@body)
+ (show-font-mode))
+ (display-buffer buffer)))
+
+;;;; Preview an installed font
+
+(defvar show-font-select-preview-history nil)
+
+(defun show-font--select-preview-prompt ()
+ "Prompt for a font among `show-font--get-installed-font-families'."
+ (let ((def (car show-font-select-preview-history)))
+ (completing-read
+ (format-prompt "Select font to preview" def)
+ (show-font--get-installed-font-families))))
+
+;;;###autoload
+(defun show-font-select-preview (family)
+ "Prepare a preview for font FAMILY.
+When called interactively, prompt for FAMILY. When called from Lisp,
+FAMILY is a string that satisfies `show-font-installed-p'."
+ (interactive
+ (list
+ (show-font--select-preview-prompt)))
+ (when (show-font-installed-p family)
+ (show-font-with-preview-buffer (format "*show-font preview of `%s'*"
family)
+ (save-excursion
+ (insert (show-font--prepare-text family))))))
+
+;;;; Preview fonts in a list
+
+(defun show-font-list ()
+ "Produce a list of installed fonts with their preview.
+The preview text is that of `show-font-pangram'."
+ (declare (interactive-only t))
+ (interactive)
+ (show-font-with-preview-buffer "*show-font preview of all installed fonts*"
+ (save-excursion
+ (let* ((counter 0)
+ (counter-string (lambda () (concat (number-to-string counter) ".
"))))
+ (dolist (family (show-font--get-installed-font-families))
+ (insert (concat
+ (propertize (funcall counter-string) 'face 'show-font-misc)
+ (propertize family 'face (list 'show-font-title-small
:family family))
+ "\n"
+ (make-string (length (funcall counter-string)) ?\s)
+ (propertize (show-font--get-pangram) 'face (list
'show-font-regular :family family))))
+ (insert "\n\n")
+ (setq counter (+ counter 1)))))
+ (setq-local revert-buffer-function
+ (lambda (_ignore-auto _noconfirm)
+ (show-font-list)))))
+
;;;; Major mode to preview the font of the current TTF or OTF file
;;;###autoload
- [elpa] externals/show-font b572bacf0c 26/54: Make the major mode disable line numbers locally, (continued)
- [elpa] externals/show-font b572bacf0c 26/54: Make the major mode disable line numbers locally, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font 5cf734e21a 35/54: Define a button and use it to help the user install current file, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font c5d7fd6e34 01/54: Add initial version of show-font, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font 460da112ed 08/54: Add TODO about other operating systems, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font a1ffe8afdf 05/54: Autoload show-font-extensions-regexp to make the package install correctly, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font 1ab166f5df 14/54: Remove done to-do items, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font 791416d748 16/54: Rework how we expand the pangrams for the defcustom :type, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font d3a51209eb 09/54: Use setq-local consistency in the major mode definition, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font 97b3301dd3 12/54: Add error checking in show-font--prepare-text, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font 9a40c37d54 04/54: Add link to demo in the README, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font b951202b9b 29/54: Define commands to (i) preview an installed font (ii) list+preview all installed fonts,
ELPA Syncer <=
- [elpa] externals/show-font 36d3197e13 43/54: Autoload `show-font-handler`, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font a38c7ba286 53/54: Fix a couple of typos, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font 0d5978f07b 52/54: Add link with sample pictures, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font da30bb5554 06/54: Add FIXME for how the file handler is added (also see commit a1ffe8a), ELPA Syncer, 2024/09/10
- [elpa] externals/show-font c41443f03a 03/54: Tweak how the font is propertized, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font 6ca36f382e 23/54: Add some outline headings, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font b1bf2837f9 36/54: Rename helper function that check FILE font attributes, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font 8ed7c66c63 44/54: Merge pull request #3 from swapnilsm/main, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font e8bb71badc 45/54: Add .elpaignore file for GNU ELPA, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font 7dd09cd87e 48/54: Update the package Commentary, ELPA Syncer, 2024/09/10