Wikia

Vim Tips Wiki

The perfect programming font

Talk0
1,612pages on
this wiki
Revision as of 22:07, July 19, 2013 by UweW (Talk | contribs)

Tip 914 Printable Monobook Previous Next

created 2005 · complexity basic · author Bernhard Leiner · version 6.0


Here are some recommendations for fonts to use in gvim, particularly for writing programs.

 TO DO 

  • Should probably have separate tips for Linux and Windows font recommendations, or at least make it clearer what works where.
  • Every font should have a screenshot and note if it is free or commercial.

Proggy

Proggy Clean font from http://www.proggyfonts.com/

Proggyclean szbp

ProggyClean (slashed zero, bold brackets)

Using gvim with gtk2, I had a problem installing Proggy Clean. I couldn't get the pcf font registered by freetype/fontconfig. The result was that I could select Proggy Clean via "xfontsel", but not with the gtk2 font selector. A gtk build probably would have worked.

Anyway, the ttf font works fine. Just copy ProggyCleanTT.ttf to ~/.fonts and run "fc-cache" once. This should work on every Unix system with fontconfig installed.

Then start gvim and and choose the font, or insert this in your .gvimrc:

set guifont=ProggyCleanTT\ 12

The 12pt size is necessary for a good look. On OS X, you need to set 16pt.

If you use ProggyCleanTT in gvim and the top of the font looks like garbage, with missing pieces, it is because you have the new freetype hinting turned on. Proggy is not hinted properly.

Neep

I prefer the Neep programming font created by Jim Knoble. Get the jmk-x11-fonts package from http://www.jmknoble.net/fonts/

It differentiates between a zero and the letter "O" and looks really nice. I use it for programming on a 1600x1200 screen.

  • On Debian/Ubuntu: apt-get install xfonts-jmk
  • On Gentoo: emerge x11fonts-jmk

Once you have installed the font you should put a line like this in your .gvimrc file:

set guifont=Neep\ 18

You may also need to enable bitmap fonts and rebuild the font cache. On Ubuntu:

rm /etc/fonts/conf.d/70-no-bitmaps.conf
fc-cache -f -v

zevv-peep

I've been using Neep, but the characters are too small on a new laptop with a high resolution screen (1920x1200 at 15.4"). Zevv-peep is a variation on Neep for hires screens. X11 (Linux) and Windows variants are available at http://zevv.nl/play/code/zevv-neep/

Design considerations

  • Clean, avoid clutter.
  • Very clear distinction between similar characters like 0 O o and i I l 1 |.
  • Suitable for light text on a dark background.
  • Not too densely packed to allow a good separation between characters.

Neepfont

Bitstream Vera (True Type)

Free from http://www.gnome.org/fonts/

The sans serif mono spaced version of this font is clean and legible down to 6 points on Mac OS X with a 110 dpi display.

Nearly all of my programming is via vim through an iTerm (Mac) or konsole (FreeBSD/Linux) terminal window. In the rare instances I use gvim the font has performed as expected.

Sans serif and serif fonts with variable spacing are also included.

Bitstream Vera Sans Mono at 11 point (Mac OS X): Bitstreamverasans11

DejaVu Sans Mono looks identical to Bitstream Vera Sans Mono, and has more international characters. See the comments section for links.

Gohu

Gohu is a free (under WTFPL) pixmap font available in PCF and BDF. It is extremely legible and unambiguous in both 11 and 14 px sizes.

Gohu-sample

Website: http://font.gohu.eu/

Mirror: http://demus.co/files/gohufont-2.0p0.tgz

UW ttyp0

UW ttyp0 is a free bitmap font family with about 3000 Unicode characters, including a number of stylistic variants that can be selected at installation time (plain, dotted or slashed zeroes, straight or curly quotes, visible or invisble NBSP, etc.). Sizes range from 6x11 to 11x22 px in regular and bold; for some sizes there is also an italic version. Currently only BDF/PCF (the X11 bitmap format) is supported; if you need another format, you'll have to convert it yourself. (I won't comment on the quality; as the author I'm obviously biased :-)

Update: Starting with version 1.1, UW ttyp0 also supports Powerline.

Ttyp0-mixed

Website: http://www.mpi-inf.mpg.de/~uwe/misc/uw-ttyp0/

Adobe Source Code Pro

Source Sans is a set of monospaced OpenType fonts that have been designed to work well coding environments. This family of fonts is a complementary design to the Source Sans family. Open Font License 1.1 (OFL 1.1)

http://sourceforge.net/projects/sourcecodepro.adobe/

Other

See also

Comments

I don't like any of these fonts on hires screens. They are too small on a 1600x1200 panel. Normally I use Lucida Console 12 pt.


On Windows, I use the Terminal font at 6 pts. However, it's a DOS font and that makes non English letters display all wrong. But I use it anyway because it maximizes my screen usage.


How about the common 7x14-ISO8859-1 font? The only thing I'd change is to replace the zero with a slashed one (using FontForge). http://www.ank.com.ar/fonts/


My favorite fonts are 10x20/X and fixedsys/Windows, always clear and crisp.


As has been noted, sometimes font size 16 is better for Proggy Clean.

On a Linux system, it can be useful to tell fontconfig to turn off antialiasing for specific fonts. Just create a file named .fonts.conf in your home directory with the following content:

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
  <match target="font">
    <test qual="any" name="family">
      <string>ProggyCleanTT</string>
    </test>
    <edit name="antialias" mode="assign">
      <bool>false</bool>
    </edit>
  </match>
</fontconfig>

The proggy ttf didn't work well for me on FC3. Characters weren't scaled smoothly and looked jagged.

I instead prefer these Microsoft TrueType fonts: http://www.mjmwired.net/resources/mjm-fedora-fc3.html#ttf

Install the rpm and then use andale mono. They look lovely and are scaled and smoothed perfectly.

set guifont=Andale\ Mono\ 9

I've been using a monospace font (not necessarily programming-oriented though) called Inconsolata, available here.


Here are a couple link to discussion about suitable fonts: http://www.codeproject.com/KB/work/FontSurvey.aspx — with screenshots http://stackoverflow.com/questions/4689/recommended-fonts-for-programming


Envy Code R is the most awesome font in the world... I've been using it for years. http://damieng.com/blog/2008/05/26/envy-code-r-preview-7-coding-font-released


Around Wikia's network

Random Wiki