Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emres/917ffc60f4fe209a6a1bad6b3abd4fa1 to your computer and use it in GitHub Desktop.
Save emres/917ffc60f4fe209a6a1bad6b3abd4fa1 to your computer and use it in GitHub Desktop.
Print the same string of text in all the available fixed width (mono spaced) fonts in a new Emacs buffer
;; See the following for more details
;; https://emacs.stackexchange.com/a/50215/8887
;; and also see the following on a recent GNU/Linux or similar system:
;; /usr/share/doc/fontconfig/fontconfig-user.html
;; for the explanation of spacing=100
;; also see the following UNIX StackExchange answer:
;; https://unix.stackexchange.com/a/363368/13105
(defun compare-monospace-font-families ()
"Display a list of all monospace font faces. Tested on GNU/Linux."
(interactive)
(pop-to-buffer "*Monospace Fonts*")
(erase-buffer)
(dolist (font-name (seq-filter (lambda (font)
(when-let ((info (font-info font)))
(string-match-p "spacing=100" (aref info 1))))
(font-family-list)))
(insert
(propertize
(concat "1 l; 0 O o [ < = > ] " font-name ")\n")
'font-lock-face `((:family
,(format "%s" (font-get (font-spec :name font-name) :family))))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment