views:

47

answers:

2

Which font or fonts should be used while writing code lines inside a book?

I'm especially dealing with C code, but I'd also like to know what fonts are used for the codes of popular programming languages in books.

+1  A: 

I think if you can read it, it should be a good font. Maybe have a mix of fonts like a times new roman or arial for general explanations but when showing actual code put a sans serif font with the code indented or separated from the rest. If it is a different font from the rest of the it should be easy to see. Also I would not suggest anything too italicized or cursive. just think about what you enjoy reading and how it looks,

EDIT

also you can look here for different programming fonts. or use a search engine to find good readable font. Normally anything with sans serif is a good choice because it doesn't detract the eyes too much from the code.

Justin Gregoire
+1  A: 

Any good fixed-width legible font will do. Courier shows up a lot as many people use it in IDEs on the desktop and tends to be the default style for the <code> tag in HTML.

I tend to use Consolas in IDEs when I can and that might also be a good choice for a book.

If you have a particular book in mind then it is worth checking the near the back cover for a colophon which may detail the fonts.

I happen to have "POSIX Programmer's Guide" in front of me and the colophon says that it uses ITC Garamond for the main text and Courier for the code examples.

Linked: You may also want to read http://stackoverflow.com/questions/4689/recommended-fonts-for-programming

GrahamS