Check if a Font is Available with Emacs Lisp
In Emacs Lisp, find-font
function return a font-entity matching with FONT-SPEC. So we can make a helper function.
(defun font-available-p (font-name) (find-font (font-spec :name font-name)))
Before setting a font, we can check with this helper function.
(when (font-available-p "Fira Code") (set-face-attribute 'default nil :font (font-spec :family "Fira Code" :size 17)))