(dolist (face '((org-level-1 . 1.2)
                (org-level-2 . 1.1)
                (org-level-3 . 1.05)
                (org-level-4 . 1.0)
                (org-level-5 . 1.1)
                (org-level-6 . 1.1)
                (org-level-7 . 1.1)
                (org-level-8 . 1.1)))
  (set-face-attribute (car face) nil :font "Cantarell" :weight 'regular :height (cdr face)))

when I evaluate this code, emacs doesn't complain but when I load a new instance of emacs it gives me an error of: error: Invalid face, org-level-1.

emacs: v27.1, org: v9.3

  • Have you tried wrapping that in an (with-eval-after-load 'org-faces ...)?
    – lawlist
    Jan 24, 2021 at 21:11
  • yeah that worked. Thanks man! I should start learn elisp. May you explain why this happened in the answer? I copied this code from a tutorial in youtube (system crafters), probably a few other people may encountered this problem and this will be helpful for them. I created an issue in the corresponding repository. I will share this answer there.
    – ali b
    Jan 24, 2021 at 22:04
  • @lawlist: Please look for a duplicate... OP or lawlist: if this is not a duplicate, please provide the answer as an answer, not just as a comment. Comments can be deleted at any time. Thx.
    – Drew
    Jan 24, 2021 at 22:15
  • please feel free to edit the title and the question because I 'feel' this answer is not specific to the question and the title. thank you again lawlist for explanation!
    – ali b
    Jan 25, 2021 at 0:35

1 Answer 1


The error message Invalid face comes from an internal C function lface_from_face_name_no_resolve within xfaces.c A face must be defined before an attribute thereof may be changed with set-face-attribute. The library that defines the org-level-... faces is named org-faces, with the Lisp version being org-faces.el and the byte-compiled version being org-faces.elc. The main library of org-mode is org.el, and it expressly calls the org-faces library with the line (require 'org-faces). The function with-eval-after-load (see the doc string of the function with C-h f with-eval-after-load and the Elisp Manual for more details) can be used to ensure the org-faces library is loaded before attributes of faces defined therein are changed:

(with-eval-after-load 'org-faces ...)

The dolist statement proposed by the O.P. can be inserted/replaced in lieu of the ... hereinabove. The second argument to with-eval-after-load is looking for BODY, which is interpreted to mean just one form ... Where more than one statement is required, consider using (progn ...) to wrap one or more statements; e.g., (progn [SOMETHING] [SOMETHING ELSE])

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.