Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change the font of current buffer in Emacs?

In emacs, I can change the font-size of current buffer by text-scale-adjust. However, to change the font, I only find functions like set-face-font or set-frame-font, which will change the font globally in emacs (or change all buffers' font within current frame).

Is there a function in emacs that only changes the font (default font) of current buffer, while not modifying the fonts in any other buffers?

like image 360
Hanfei Sun Avatar asked Jan 01 '14 06:01

Hanfei Sun


People also ask

How do you change the font in Spacemacs?

Note: this paragraph may be outdated :- After finishing the first startup process, press ESC -> SPACE -> f -> f -> . spacemacs . The font can be changed under dotspacemacs-default-font and layers can be enabled or disabled under dotspacemacs-configuration-layers among many other options.

What is the default Emacs font?

By default, Emacs displays text on graphical displays using a 10-point monospace font, and the font size can be changed interactively (see Text Scale).


1 Answers

I found a way, though it has some side effects as it changes the global variable buffer-face-mode-face

For example, I want to set current buffer, I can eval this function definition and run it

 (defun my-buffer-face-mode-serif ()
   "Sets a fixed width (monospace) font in current buffer"
   (interactive)
   (setq buffer-face-mode-face '(:family "Times New Roman"))
   (buffer-face-mode))
like image 156
Hanfei Sun Avatar answered Sep 26 '22 19:09

Hanfei Sun