简体   繁体   中英

Emacs : "set default font" and init.el

I want to set up my starting default font. I choose a font in Options --> set Default Font. then I save it with Options --> Save Options.

This writes at the end of my ~/.emacs.d/init.el file :

 (custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(default ((t (:inherit nil :stipple nil :background "black" :foreground "white" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant italic :weight bold :height 241 :width normal :foundry "microsoft" :family "Trebuchet MS" "Courier New" :foundry "monotype" :slant normal :weight bold :height 240 :width normal "Courier New"))))

When starting emacs again, the selected font is not loaded. And there is no problem with the init.d file, as reported in *Messages* or by --debug-init. It seems the mechanism by which "set default font" finds fonts and init.d finds fonts are different ...

What do I do wrong ?
Running on Ubuntu 14.04LTS, Emacs 24

You can set it in your init.el file the following:

(set-default-font "Inconsolata 12")

or monaco font

(set-default-font "Monaco 12")

This works for me (Emacs 27.1)

;; Set default font
(set-face-attribute 'default nil
                    :family "Courier New"
                    :height 120
                    :weight 'normal
                    :width 'normal)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM