Vim logo vim online Vim Book Ad

 Tip #158: Using Computer Modern TT as gvim font (Win32)

 tip karma   Rating 10/6, Viewed by 1593 

created:   November 8, 2001 12:59      complexity:   intermediate
author:   Vince Negri      as of Vim:   5.7

If you really like the Computer Modern typewriter font (as seen in most TeX distributions) you can use it as the font in gvim! (looks excellent with font smoothing turned on)

First, get hold of the free Blue Sky Type 1 PS versions of the CM fonts from your local CTAN mirror. Unpack to a suitable directory.

Next locate the cmtt8.pfb file and open it (in Vim, naturally ;) - find the line
saying
dup 32 /visiblespace put

and change it to
dup 32 /space        put

that is, inserting enough spaces to keep the file size exactly the same
(IMPORTANT!)

Save the file in Mac format (:set fileformat=mac).

Now install the cmtt.pfm file - in Win9x/NT4, you'll need Adobe Type Manager
(free download), but in Win2k, you can just drop the .pfm file into the Fonts folder.

Now in your _gvimrc:
set guifont=CMTT8:h11:cSYMBOL

(use whatever height you like instead of h11)

..and enjoy! It's the first scalable font I can bear to edit code in... %-)

 rate this tip  Life Changing Helpful Unfulfilling 

<<Incredible new functionality | Keystroke Saving Substituting and Searching >>

Additional Notes

Anonymous, November 8, 2001 13:00
grr typo!
"Now install the cmtt.pfm file" should of course be
"Now install the cmtt8.pfm file"
[email protected], November 9, 2001 8:43
I couldn't get the font to install on my win2k box.  What exactly should the name of the file be?  Should I change the cmtt8.pfb to cmtt8.pfm?  I tried making the modifications as per the instructions, and when I tried copying it to my fonts directory, windows told me that it was an invalid font.  I kept the right number of spaces, and I set fineformat=mac, but it didn't work.  Maybe somebody could post a version of the font that works OK?
Vince, November 9, 2001 12:42
If you have downloaded the full bluesky package, you will have *both* .pfb and .pfm files. Do not rename the .pfb file to .pfm! The .pfm file will appear with a red 'a' as its icon in Win2k.

(Thinking I should have marked this tip as advanced, as messing with Type 1 fonts even in Win2k is fairly non-intuitive....)
[email protected], November 11, 2001 8:57
One of the nicest mono spaced fonts that I have found has come from Microsoft.  

They have a nice selection of screen legible fonts located at http://www.microsoft.com/typography.

The monospaced font is called Andale Mono and can be downloaded as a self installing executable (ugh.) under Windows.

Take a look if you need a good font.

- Paul
[email protected], November 12, 2001 5:05
Agreed.  Andale Mono is what I use.  It's a fine computer type font.  In fact, I've set up my CMD prompt to use it and the IE Browser to use it for the monospaced fonts.  Looks better than Courier new.
[email protected], January 2, 2002 16:27
Nice tip!  Computer modern is a beautiful font - my source code is much more elegant now ;-)

One note - doing 'set ff=mac' and saving my edits to the .pfb file did not work (for me, using
Win98, Adobe Type Manager, and Vim 6.0).  Leaving the file format alone did work.
[email protected], June 4, 2002 19:13
Any chance the resultant file, usable under win32 can be put up somewhere for ftp/http ?

davidp.
[email protected], August 20, 2002 7:11
Ohhhhh!!!! Just orgasmic! BTW. If vim shows you the file as "unix" with a lot of "^M", there's no need to set filetype.
My, oh my!, September 19, 2002 16:37
I was convinced I'd never find a decent font.  I was using Fixedsys for want of something legible!  CTT8 is so pretty it makes my eyes water.  Or maybe my eyes are watering because I've been oggling it for too long.

*blink* *blink*

Mike
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to [email protected] after searching the archive. Help Bram help Uganda.
SourceForge Logo