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


当前回答

这是另一个简单的解决方案。《24小时》也适用

(set-default-font "Monaco 14")

捷径:

`C-+` increases font size
`C--` Decreases font size

其他回答

我有以下在我的。emacs:

(defun fontify-frame (frame)
  (set-frame-parameter frame 'font "Monospace-11"))

;; Fontify current frame
(fontify-frame nil)
;; Fontify any future frames
(push 'fontify-frame after-make-frame-functions) 

你可以用你选择的任何字体来代替“Monospace-11”。可用选项集高度依赖于系统。使用M-x set-default-font并查看制表符补全会给您一些启发。在我的系统上,在启用了Emacs 23和抗锯齿的情况下,可以根据名称选择系统字体,例如Monospace、Sans Serif等。

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

;; 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)))))

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

(set-face-attribute 'default nil :height 100)

这个值的单位是1/10pt,所以100会给你10pt,以此类推。

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

(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部分提供了最好和最完整的信息。它区分了各种情况(文本缩放,框架字体,缓冲区/框架等):改变字体大小。