Last active
February 19, 2023 18:45
-
-
Save haxney/3055728 to your computer and use it in GitHub Desktop.
List monospace fonts in Emacs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Display all the monospace fonts available to Emacs in a dedicated buffer | |
(defun font-is-mono-p (font-family) | |
;; with-selected-window | |
(let ((wind (selected-window)) | |
m-width l-width) | |
(with-temp-buffer | |
(set-window-buffer (selected-window) (current-buffer)) | |
(text-scale-set 4) | |
(insert (propertize "l l l l l" 'face `((:family ,font-family)))) | |
(goto-char (line-end-position)) | |
(setq l-width (car (posn-x-y (posn-at-point)))) | |
(newline) | |
(forward-line) | |
(insert (propertize "m m m m m" 'face `((:family ,font-family) italic))) | |
(goto-char (line-end-position)) | |
(setq m-width (car (posn-x-y (posn-at-point)))) | |
(eq l-width m-width)))) | |
(defun compare-monospace-fonts () | |
"Display a list of all monospace font faces." | |
(interactive) | |
(pop-to-buffer "*Monospace Fonts*") | |
(erase-buffer) | |
(dolist (font-family (font-family-list)) | |
(when (font-is-mono-p font-family) | |
(let ((str font-family)) | |
(newline) | |
(insert | |
(propertize (concat "The quick brown fox jumps over the lazy dog 1 l; 0 O o (" | |
font-family ")\n") 'face `((:family ,font-family))) | |
(propertize (concat "The quick brown fox jumps over the lazy dog 1 l; 0 O o (" | |
font-family ")\n") 'face `((:family ,font-family) italic))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That makes a lot more sense!