简体   繁体   English

Emacs:“设置默认字体”和 init.el

[英]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 :这写在我的 ~/.emacs.d/init.el 文件的末尾:

 (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.再次启动 emacs 时,未加载所选字体。 And there is no problem with the init.d file, as reported in *Messages* or by --debug-init. init.d 文件没有问题,如*Messages*或 --debug-init 中所述。 It seems the mechanism by which "set default font" finds fonts and init.d finds fonts are different ...似乎“设置默认字体”查找字体和 init.d 查找字体的机制不同......

What do I do wrong ?我做错了什么?
Running on Ubuntu 14.04LTS, Emacs 24在 Ubuntu 14.04LTS、Emacs 24 上运行

You can set it in your init.el file the following:您可以在 init.el 文件中设置以下内容:

(set-default-font "Inconsolata 12") (设置默认字体“Inconsolata 12”)

or monaco font或摩纳哥字体

(set-default-font "Monaco 12") (设置默认字体“摩纳哥 12”)

This works for me (Emacs 27.1)这对我有用(Emacs 27.1)

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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