setting monospaced font on Emacs?

7,303

Solution 1

You could always use the monaco font:

  1. Create a new fonts directory

    sudo mkdir /usr/share/fonts/truetype/mine
    
  2. Get Monaco.ttf

    sudo wget http://usystem.googlecode.com/files/MONACO.TTF -O /usr/share/fonts/truetype/mine/MONACO.TTF
    
  3. Update your font cache

    fc-cache -f -v   
    
  4. Tell emacs to use the Monaco font. Add this line to your ~/.emacs:

    (set-default-font "monaco")
    

    Personally, I prefer it a little smaller than it appears with the default setting above, so I use

    (set-default-font "-apple-Monaco-normal-normal-normal-*-14-*-*-*-*-0-iso10646-1")
    

Solution 2

It's been over six months since you posted your question. It's not clear that you found the answer.

See this page on Emacs Wiki: SetFonts. It has everything you need to know about displaying installed fonts to choose from and choosing one for Emacs.

Share:
7,303
user46976
Author by

user46976

Updated on September 18, 2022

Comments

  • user46976
    user46976 over 1 year

    I used to use liberation mono font on emacs (on X11) on an Ubuntu system using the following command and it worked great:

    (custom-set-faces
      '(default ((t (:inherit nil :stipple nil :background "lightgrey" :foreground "gray20" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :width normal :height 120 :family "liberation mono"))))
      '(background "blue")
      '(font-lock-builtin-face ((((class color) (background dark)) (:foreground "Turquoise"))))
      '(font-lock-comment-face ((t (:foreground "darkred"))))
      '(font-lock-constant-face ((((class color) (background dark)) (:bold t :foreground "DarkOrchid"))))
      '(font-lock-doc-string-face ((t (:foreground "lightblue"))))
      '(font-lock-function-name-face ((t (:foreground "blue"))))
      '(font-lock-keyword-face ((t (:bold t :foreground "steelblue"))))
    ;  '(font-lock-keyword-face ((t (:bold t :foreground "CornflowerBlue"))))
      '(font-lock-preprocessor-face ((t (:italic nil :foreground "CornFlowerBlue"))))
      '(font-lock-reference-face ((t (:foreground "DodgerBlue"))))
      '(font-lock-string-face ((t (:foreground "Aquamarine4")))))
    

    It looked like this:

    enter image description here

    Our system admin upgraded to a new release of Ubuntu and now the font looks completely different in emacs. It doesn't look anti-aliased anymore, appears "less bold" and looks like this:

    enter image description here

    I'm trying to get it to look like it did before. Basically I want a font appearance that looks as close as possible to the Monaco fixed width font on Mac OS X, which on my terminal looks like this:

    enter image description here

    How can this be done? Ideas? Cannot figure it out. thanks.

  • user46976
    user46976 about 11 years
    thanks but on second thought I'm not sure the original font I am aiming to use was Liberation Mono. It could be that the system defaulted to monospace or whatever the default system font, which emacs does. I'm just trying to achieve the exact same font as the screen shot above. Do you know which font it is?
  • qmega
    qmega about 11 years
    I guess it could have been DejaVu Sans Mono; that's a pretty common default mono font for Linux distros. The screenshot you have up there really looks like Liberation Mono, though. If you have access to an environment where it works as before, you can use M-x describe-font to find out for sure. There are other problems it could be, though. Perhaps the font you had isn't installed by default anymore; there's a good chance this upgrade was from 10.04 LTS to 12.04 LTS, and the former is one release before the new Ubuntu fonts were added. (I don't use Ubuntu, so not entirely sure on this info.)
  • qmega
    qmega about 11 years
    If what you really want is Monaco, is there any reason you can't just copy that from your OS X box and install it user-local on this system?
  • user46976
    user46976 about 11 years
    on my mac box I see /System/Library/Fonts/Monaco.dfont - don't I need it in .ttf format to use on ubuntu? If so, how can I convert it to ttf or find the ttf version on my mac?
  • qmega
    qmega about 11 years
    dfont is actually a container for TrueType fonts, so you just need to extract them. Fondu will do that for you.