Function: x-must-resolve-font-name

x-must-resolve-font-name is a byte-compiled function defined in fontset.el.gz.

Signature

(x-must-resolve-font-name XLFD-FIELDS)

Documentation

Like x-resolve-font-name, but always return a font name.

XLFD-FIELDS is a vector of XLFD (X Logical Font Description) fields. If no font matching XLFD-FIELDS is available, successively replace parts of the font name pattern with "*" until some font is found. Value is name of that font.

Source Code

;; Defined in /usr/src/emacs/lisp/international/fontset.el.gz
(defun x-must-resolve-font-name (xlfd-fields)
  "Like `x-resolve-font-name', but always return a font name.
XLFD-FIELDS is a vector of XLFD (X Logical Font Description) fields.
If no font matching XLFD-FIELDS is available, successively replace
parts of the font name pattern with \"*\" until some font is found.
Value is name of that font."
  (let ((ascii-font nil) (index 0))
    (while (and (null ascii-font) (<= index xlfd-regexp-registry-subnum))
      (let ((pattern (x-compose-font-name xlfd-fields)))
	(condition-case nil
	    (setq ascii-font (x-resolve-font-name pattern))
	  (error
	   (message "Warning: no fonts matching `%s' available" pattern)
	   (aset xlfd-fields index "*")
	   (setq index (1+ index))))))
    (unless ascii-font
      (error "No fonts found"))
    ascii-font))