我还想在.emacs文件中保存字体大小。


当前回答

下面是一个代码片段,可以让你直接使用交互函数指定全局字体大小:

(defun set-font-size ()
    "Set the font size."
  (interactive)
  (set-face-attribute
   'default nil :height
   (string-to-number
    (read-string "Font size: " (number-to-string (face-attribute 'default :height nil))))))

其他回答

这完全取决于你所说的改变字体大小。 EmacsWiki部分提供了最好和最完整的信息。它区分了各种情况(文本缩放,框架字体,缓冲区/框架等):改变字体大小。

按Shift和第一个鼠标按钮。您可以通过以下方式更改字体大小:此网站有更多详细信息。

M-x自定义脸RET默认将允许您设置脸的默认脸,所有其他脸的基础上。在这里你可以设置字体大小。

这是我的。emacs中的内容。实际上,color-theme会设置基础,然后我的自定义面部设置会覆盖一些东西。定制的set-faces是由emacs的定制面机制编写的:

;; my colour theme is whateveryouwant :)
(require 'color-theme)
(color-theme-initialize)
(color-theme-whateveryouwant)

(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 (:stipple nil :background "white" :foreground "black" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 98 :width normal :foundry "unknown" :family "DejaVu Sans Mono"))))
 '(font-lock-comment-face ((t (:foreground "darkorange4"))))
 '(font-lock-function-name-face ((t (:foreground "navy"))))
 '(font-lock-keyword-face ((t (:foreground "red4"))))
 '(font-lock-type-face ((t (:foreground "black"))))
 '(linum ((t (:inherit shadow :background "gray95"))))
 '(mode-line ((t (nil nil nil nil :background "grey90" (:line-width -1 :color nil :style released-button) "black" :box nil :width condensed :foundry "unknown" :family "DejaVu Sans Mono")))))

这里有一个交互调整字体高度的选项,一次一点:

;; font sizes
(global-set-key (kbd "s-=")
                (lambda ()
                  (interactive)
                  (let ((old-face-attribute (face-attribute 'default :height)))
                    (set-face-attribute 'default nil :height (+ old-face-attribute 10)))))

(global-set-key (kbd "s--")
                (lambda ()
                  (interactive)
                  (let ((old-face-attribute (face-attribute 'default :height)))
                    (set-face-attribute 'default nil :height (- old-face-attribute 10)))))

当您想要调整所有缓冲区中的文本大小时,这是可取的。我不喜欢使用文本比例增加和文本比例减少的解决方案,因为排水沟中的行号之后会被切断。

Firefox和其他程序允许您使用C-+和C——来增加和减少字体大小。我设置了我的.emacs,这样我就可以通过添加以下几行代码来拥有同样的能力:

(global-set-key [C-kp-add] 'text-scale-increase)

(global-set-key [C-kp-subtract] 'text-scale-decrease)