Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setup custom font in emacs?

Tags:

emacs

fonts

I would like to use Proggy font for my programming in Emacs. How can I set it up?

Please note it is a bitmap font.

like image 955
Łukasz Lew Avatar asked Mar 01 '10 12:03

Łukasz Lew


2 Answers

you can use:

(set-default-font "ProggyClean")

which is deprecated and should be

(set-frame-font "ProggyClean")

from Emacs 23.1 on in you .emacs or you can do M-x: customize-face: default and set ProggyClean as "Font Family".

like image 144
danielpoe Avatar answered Nov 15 '22 02:11

danielpoe


Just sticking set-default-font in your .emacs won't work across multiple frames - each new frame will go back to the old default. Customize does work with multiple frames, but I've never managed to get it to work properly across different platforms (and different platforms have different font settings even for the same font).

So! This is what I've got in my .emacs. It works in linux, win32 and cygwin, and works with multiple frames (and hence emacs client).

(defconst win32p    (eq system-type 'windows-nt)  "Are we running on a Windows system?")
(defconst cygwinp   (eq system-type 'cygwin)  "Are we running on Cygwin?")
(defconst linuxp    (or (eq system-type 'gnu/linux)  (eq system-type 'linux))  "Are we running on Linux?")

;;font setups
(defvar vsc-little-font "" "*My lovely little font")

(when linuxp
  (setq vsc-little-font "ProggyTinyTT-8"))

(when cygwinp
  (setq vsc-little-font "ProggyTinyTT-16"))

(when win32p
  (setq vsc-little-font "-outline-ProggyTinyTT-normal-r-normal-normal-16-120-96-96-c-*-iso8859-1"))

(add-to-list 'default-frame-alist (cons 'font vsc-little-font))
(add-to-list 'initial-frame-alist (cons 'font vsc-little-font))
like image 37
bbbscarter Avatar answered Nov 15 '22 02:11

bbbscarter