我还希望将字体大小保存在我的.emacs
文件中。
(set-face-attribute 'default nil :height 100)
数值以1/10pt为单位,因此100表示10pt等等。
set-face-attribute
确实不在M-x
(execute-extended-command
)中,但它出现在M-:
(eval-expression
)和C-h f
(describe-function
)中。如果你不想将这个命令放到你的.emacs
文件中,那么M-:
可能是你想要的。 - Rory O'KaneM-x
运行?我知道这是一个新手问题,但我不太了解 Emacs 在低级别上是如何运作的。 - DavidS来自Emacswiki,GNU Emacs 23内置按键组合:
C-xC-+ 和 C-xC-- 可以增加或减小缓冲区文本大小
face-remap.el
中的text-scale-adjust
、text-scale-increase
和text-scale-mode
函数。 - Dave X按下Shift键和鼠标左键。你可以通过以下方式改变字体大小:此网站有更详细的信息。
M-x customize-face RET default允许您设置default
面,其他所有面都基于该面。在那里,您可以设置字体大小。
以下是我的.emacs文件中的内容。实际上,color-theme将设置基础样式,然后我的自定义面板设置将覆盖一些内容。custom-set-faces是由emacs的customize-face机制编写的:
;; 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")))))
这是另一个简单的解决方案。在24小时内同样有效。
(set-default-font "Monaco 14")
快捷方式:
`C-+` increases font size
`C--` Decreases font size
set-default-font
is now deprecated. Use either (set-frame-font "Monaco 14")
or (set-face-attribute 'default nil :height 130)
- kotchwaneset-frame-font
和 :height
中的大小之间有什么关系吗?在我的 Emacs 中,将后者设置为 93、94 或 95 具有完全相同的效果。 - pglpm在X11中打开emacs,转到选项菜单,选择“设置默认字体...”,更改字体大小。 在同一菜单中选择“保存选项”。完成。
我在我的.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
并查看 tab 键自动完成将给您一些想法。在我的系统上,使用 Emacs 23 和抗锯齿功能启用,可以按名称选择系统字体,例如Monospace
,Sans Serif
等。
zoom.cfg和global-zoom.cfg提供了改变字体大小的快捷键绑定(来自EmacsWiki)
这里有一个交互式的选项,可以逐个点地调整字体高度:
;; 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)))))
当您希望调整 所有 缓冲区中的文本大小时,这是更可取的。我不喜欢使用 text-scale-increase
和 text-scale-decrease
的解决方案,因为接下来可能会出现在装订线处截断。
Firefox和其他程序允许你使用C-+和C--来增加和减小字体大小。我设置了我的.emacs文件,通过添加以下代码,使我也能够拥有这种功能:
(global-set-key [C-kp-add] 'text-scale-increase)
(global-set-key [C-kp-subtract] 'text-scale-decrease)
.emacs.d/init.el
,它更好(更干净、更易于版本控制)。 - XY Li