reddit / emacs

Default face not available?

graduale · 2022-10-06 00:54
So, I tried running `M-x dictionary` and ran into a puzzling error message: set-face-attribute: Font not available: #<font-spec nil nil default nil nil nil nil nil nil nil nil nil ((:name . "default") (:user-spec . "default"))> The backtrace doesn't help me very much: Debugger entered--Lisp error: (error "Font not available" #<font-spec nil nil default nil nil nil nil nil nil nil nil nil ((:name . "default") (:user-spec . "default"))>) internal-set-lisp-face-attribute(dictionary-word-definition-face :font "default" #<frame 0x7fe5d0847030>) set-face-attribute(dictionary-word-definition-face #<frame 0x7fe5d0847030> :font "default") apply(set-face-attribute dictionary-word-definition-face #<frame 0x7fe5d0847030> (:font "default")) face-spec-set-2(dictionary-word-definition-face #<frame 0x7fe5d0847030> (:font "default")) face-spec-recalc(dictionary-word-definition-face #<frame 0x7fe5d0847030>) face-spec-set(dictionary-word-definition-face ((((supports (:family "DejaVu Serif"))) (:family "DejaVu Serif")) (((type x)) (:font "Sans Serif")) (t (:font "default"))) face-defface-spec) custom-declare-face(dictionary-word-definition-face ((((supports (:family "DejaVu Serif"))) (:family "DejaVu Serif")) (((type x)) (:font "Sans Serif")) (t (:font "default"))) "The face that is used for displaying the definitio..." :group dictionary :version "28.1") byte-code("\300\301\302\303\304\305%\210\300\306\302\307\304\301%\210\310\311\312\313\314DD\315\304\301\316\317\320\321\322\323&\13\210\310\324\312\313\325DD\326\304\301\316\317\320\327\322..." [custom-declare-group dictionary nil "Client for accessing the dictd server based dictio..." :group hypermedia dictionary-proxy "Proxy configuration options for the dictionary cli..." custom-declare-variable dictionary-server funcall function #f(compiled-function () #<bytecode 0x1f400016fe914>) "This server is contacted for searching the diction..." :set dictionary-set-server-var :type (choice (const :tag "Automatic" nil) (const :tag "localhost" "localhost") (const :tag "dict.org" "dict.org") (string :tag "User-defined")) :version "28.1" dictionary-port #f(compiled-function () #<bytecode 0x1f4000164e954>) "The port of the dictionary server.\nThis port is pr..." number dictionary-identification #f(compiled-function () #<bytecode 0x146b32ea6ce40a76>) "This is the identification string that will be sen..." string dictionary-default-dictionary #f(compiled-function () #<bytecode 0x1f400016f1854>) "The dictionary which is used for searching definit..." dictionary-default-strategy #f(compiled-function () #<bytecode 0x1f400016f1d54>) "The default strategy for listing matching words." dictionary-default-popup-strategy #f(compiled-function () #<bytecode 0x1f40096442094>) "The default strategy for listing matching words wi..." (choice (const :tag "Exact match" "exact") (const :tag "Similar sounding" "soundex") (const :tag "Levenshtein distance one" "lev") (string :tag "User choice")) dictionary-create-buttons #f(compiled-function () #<bytecode 0x1f400016fe5d4>) "Create some clickable buttons on top of the window..." boolean dictionary-link-dictionary #f(compiled-function () #<bytecode 0x1f400016f1854>) "The dictionary which is used in links.\n* means to ..." (choice (const :tag "Link to all dictionaries" "*") (const :tag "Link only to the same dictionary" nil) (string :tag "User choice")) dictionary-mode-hook #f(compiled-function () #<bytecode 0x1f400016fe914>) "Hook run in dictionary mode buffers." hook ...] 20) autoload-do-load((autoload "dictionary" 1071170 t nil) dictionary) command-execute(dictionary record) execute-extended-command(nil "dictionary" nil) funcall-interactively(execute-extended-command nil "dictionary" nil) call-interactively(execute-extended-command nil nil) command-execute(execute-extended-command) Calling `M-x describe-face RET default RET` doesn't yield any surprises: Face: default (sample) (customize this face) Documentation: Basic default face. Defined in ‘faces.el’. Family: Input Foundry: nil Width: semi-condensed Height: 180 Weight: normal Slant: normal Foreground: #1A1A1A DistantForeground: unspecified Background: #FAFAFA Underline: nil Overline: nil Strike-through: nil Box: nil Inverse: nil Stipple: nil Font: #<font-object -*-Input-normal-normal-semicondensed-*-18-*-*-*-m-0-iso10646-1> Fontset: -*-Input-normal-normal-semicondensed-*-18-*-*-*-m-0-fontset-auto2 Extend: nil Inherit: nil [back] Any ideas?
eli-zaretskii · 2022-10-06 08:40
Please report this as a bug.
graduale · 2022-10-06 13:03
done
ForkInBrain · 2022-10-06 15:57
The `default` face and the font named "default" are different things. In your case your `default` face is using the "Input" font. Something in Emacs Lisp land somewhere has constructed a request for a font named "default", probably by mistake. The code probably intended to use the `default` face instead. From your backtrace it seems to be coming from `dictionary-word-definition-face`: > custom-declare-face(dictionary-word-definition-face ((((supports (:family "DejaVu Serif"))) (:family "DejaVu Serif")) (((type x)) (:font "Sans Serif")) (t (:font "default"))) "The face that is used for displaying the definitio..." :group dictionary :version "28.1") Which in Emacs 28 is: ``` (defface dictionary-word-definition-face '((((supports (:family "DejaVu Serif"))) (:family "DejaVu Serif")) (((type x)) (:font "Sans Serif")) (t (:font "default"))) "The face that is used for displaying the definition of the word." :group 'dictionary :version "28.1") ``` In the code above the `(t (:font "default"))` should be `(t (:inherit default))`. ...but really this face should probably just inherit from the `variable-pitch` face, rather than hard code a preference for "DejaVu Serif".
graduale · 2022-10-06 17:15
Oh, interesting observation. Hadn't noticed. What's weird, though, is that the issue doesn't arise if I set any other font as default. So, having just this in my init file (set-face-attribute 'default nil :family "Monaco" :height 180) doesn't result in the behavior I described above. If instead I use (set-face-attribute 'default nil :family "Input" :height 180) it does.