Choosing a font for codes in a book

What font or fonts should you use when writing lines of code inside a book?

I am especially good at C code, but I would also like to know what fonts are used for codes of popular programming languages ​​in books.

+2


a source to share


3 answers


Any good font with a clear width. Courier discovers many people use it in their desktop IDE and is generally the default standard for tag <code>

in HTML.

I try to use Console in the IDE whenever I can, and it might be a good choice for a book as well.

If you have a specific book then it is worth checking out the nearest colophon back cover that can detail the fonts.



I happen to have a POSIX Programmer's Guide and the colophon says it uses ITC Garamond for body text and Courier for example code .

Connected . You can also read Recommended Fonts for Programming?

+2


a source


I think if you can read it, it should be a good font. Perhaps you have a combination of fonts such as new novel or arial for general explanations, but displaying the actual code puts a sans serif font with code, indented or separated from the rest. If it's a different font from the rest of it, it should be easy to see. Also I would not suggest anything too highlighted or italicized. just think about what you like to read and what it looks like,

EDIT



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

+1


a source


Use the same font as most on screen and IDE

Usually this one is monospaced, sans serif, with clear 1 / l / I and O / 0.

Plus dots for nice bold (keywords), italics (comments), inline bitmaps, and a scalable version that looks like small sizes.

If it's a printed book, you want a font that scales, not a bitmap.

If it's online in html you want browsers to have it already.

Please do not use anything fancy and never loop!

0


a source







All Articles