Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I set fonts on Emacs for Mac?

Tags:

emacs

macos

fonts

I downloaded Carbon emacs 23.3.1 (x86_64-apple-darwin, NS apple-appkit-1038.35) from http://emacsformacosx.com/. It defaults to using Monaco, and I would like to change it to use Inconsolata-dz. So I added:

(set-default-font "-apple-Inconsolata-dz-medium-normal-normal-*-10-*-*-*-m-0-iso10646-1")

to my ~/.emacs file. However, after I restart, it is still Monaco. It discovered that Option-T (or maybe Command-T) brings up a font dialog, and if I select Inconsolata-dz from that, it works great. But if I restart, it is back to Monaco. So I tried setting the font from the menu, and then going to Customize Faces and saving it, but still it does not work. The interesting thing is that if I do M-x describe-font after changing the font from the Option-T dialog, it says -apple-Inconsolata-dz-medium-normal-normal--10--*-*-m-0-iso10646-1.

So it looks like Emacs is simply ignoring this font for some reason. Why is that, and what can I do to get it to use this font?

Update: I tried Donkopotamus and Joost Diepenaat's recommendations and they also did not work, although I ended up getting Times as my font, instead of Monaco. However, they work great if I just use the Inconsolata (not Inconsolata-dz). So I'm wondering if there is some problem with fonts with a dash in their name?

Update2: Why is this off-topic? The close message says "questions [should ...] relate to programming or software development in some way"; many developers use emacs, and getting settings right is important. The top two entries on a search for "programming fonts" have a combined 150; so font configs seem to be important to programmers. Anyway, if it is off-topic, where is the appropriate place to post it?

like image 377
prewett Avatar asked Nov 15 '11 06:11

prewett


People also ask

How do I change the font in Emacs?

You can use the menu bar. Go to Options -> Set Default Font... . After you choose a font, don't forget to press Options -> Save Options —otherwise your new font will not be saved after you close Emacs.

How do I find my Emacs font?

For a given character, you can find out which font was used by moving point to that character than then doing C-u C-x = which will give you all kinds of information about that position in the buffer, including which font was used for it. What command is "C-u C-x =" a shortcut to?

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


2 Answers

I use plain Inconsolata. From my emacs.d/init.el:

(set-face-attribute 'default nil
                    :family "Inconsolata" :height (case system-type
                                                    ('gnu/linux 130)
                                                    ('darwin 145)) :weight 'normal)

If you're only running on OSX, you can simplify that to

(set-face-attribute 'default nil
                    :family "Inconsolata" :height 145 :weight 'normal)
like image 159
Joost Diepenmaat Avatar answered Nov 01 '22 23:11

Joost Diepenmaat


I use Inconsolata. In my .emacs I simply set the default font to Inconsolata using

; check if we're on OSX
(when (featurep 'ns-win)
  (custom-set-faces
   '(default ((t (:height 140 :width normal :family "Inconsolata")))))
  )
like image 41
donkopotamus Avatar answered Nov 01 '22 23:11

donkopotamus