bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#59347: 29.0.50; `:family` face setting ignored


From: Gregory Heytings
Subject: bug#59347: 29.0.50; `:family` face setting ignored
Date: Thu, 08 Dec 2022 16:27:58 +0000



And also note that, should a user really want a specific ultra-bold font for a certain face, that is already possible with the existing infrastructure, by making that choice explicit, e.g. (set-face-attribute 'bold nil :font "Desired Font" :weight 'ultra-bold). And it is also possible, with the existing infrastructure, to list the available fonts with given attribute values, e.g. with (list-fonts (font-spec :weight 'ultra-bold)), and to select the best one in that list with an appropriate fourth argument to list-fonts.


FWIW, here is a macro to do that:

(defmacro set-mandatory-face-attribute (face frame &rest args)
  "Set attributes of FACE on FRAME from ARGS.

This function behaves like `set-face-attribute', which see,
except that attributes must match exactly, and that all available
fonts are considered."
  `(let ((spec (font-spec ,@args)))
     (let ((candidates
            (list-fonts
             spec ,frame 1
             (font-spec :width (face-attribute 'default :width)
                        :size (face-attribute 'default :height)
                        :weight (face-attribute 'default :weight)
                        :slant (face-attribute 'default :slant)))))
       (if candidates
           (set-face-attribute
            ,face ,frame
            :font (format "%s" (font-get (car candidates) :family))
            ,@args)
      (error "No available font for the specified attributes")))))






reply via email to

[Prev in Thread] Current Thread [Next in Thread]