The magic of monospace fonts is that they allocated equal space for each character, meaning the letter 'l' is getting just as much horizontal space as 'w'. And while that might look and sound a little peculiar, it's absolutely perfect for coding.
Proportional: Benefits and Uses. The width is the only difference between monospaced and proportional fonts. This can greatly affect the legibility of body text. On the other hand, if you are using numerals, you'll benefit from using monospaced fonts because numbers work differently compared to letters.
Monospaced typefaces usually bring to mind typewriters and computer programming, however, they can be a perfect choice for designers looking for a sparse, minimal and “undesigned” feel.
Monospaced typefaces do reduce legibility, albeit by a margin. In Universal Principles of Design, the entry on legibility states: Proportionally spaced typefaces are preferred over monospaced.
In a monospace font:
Il 0O
I've never even considered coding in a proportional font before. So in the interests of science I just switched my editor over to give it a go.
Here are a few observations after fixing a couple of easy tickets:
!
operator in if (!foo)
. (if (!foo), see!){}[]()
vs {}[]())$@%
vs $@%)'"!;:,.
vs '"!;:,.)0Oo iIl
vs 0Oo iIl)There are some positive points, though. Admittedly I've only been using it for a little while, but there are certainly some aspects that work a little better with proportional fonts:
I'll update this answer again tomorrow (assuming I can make it through an entire day like this!)
I like to line up related conditionals, to try to make it more obvious that they are grouped. For example:
if ((var1 == FOO) && ((var2 == BAR) ||
(var2 == FOOBAR)))
Variable width fonts make this more difficult.
One thing I keep seeing in here is discussion of "lining up code" and indentation. I would like to point the following things out:
So drawing all of this together, if you start each line at the same place, and consistent spacing is the same width, and the identifiers don't spontaneously change width on each line, then your code actually WILL line up! ...until something is different.
for example:
identifier.Method().Property.ToString();
identifier.Method().OtherGuy.ToString(); //how lined up and pretty!
identifier.Method().Sumthing.YouGetThePoint;
The one point I'll concede is that non-alphanumeric characters are typically not very wide; these include )(][}{,:|";',`! and . This however could be fixed in a font editor...simply by making them wider. It's not a problem inherent with non-monospace; there just hasn't been a lot of demand for it, and so it hasn't been done yet.
In summary, personal preference is fine, but I think there's little practical reason to prefer monospace over non-monospace. You like the look of it? Sure, do monospace. You want more stuff to fit on your screen? Go non-mono. But the way people treat non-monospace like heresy is a little overblown.
I've become curious by this thread because many arguments for monospaced fonts can really be rebutted easily with some tweaking. So I switched my IDE to Calibri (because it has a nice, round face and is optimized for readability on screens for UI – perfect). Now I obviously have to use tabs instead spaces for indentation (ignoring all the problems) and 4 spaces width is clearly not enough so I switched to 10.
Looks quite good now. However, there are a few obvious problems that I could spot. More might surface later, after I've tested this settings for a while.
Symbols don't align well. As an example, consider the following C# code:
var expr = x => x + 1;
The arrow (=>
) looks like a unit in about any monospace font. It looks like two adjacent characters in other fonts. The same is true for operators like >>
etc.
Context-sensitive indentation is completely broken: in some contexts it's not enough to indentate a fixed number of tabs. Take LINQ expressions which might be indented in the following way:
var r = from c in "This, apparently, is a test!"
where !char.IsPunctuation(c)
select char.ToUpper(c);
You simply can't do this with a proportional font.
All in all, characters are too narrow. Again, an additional letter-spacing might help and it's definitely necessary in the case of punctiuation. However, I've got the feeling that all this tweaking to make proportional fonts more readable would just emulate what monospaced fonts to naturally. It's certainly true for all the points mentioned so far.
I use Comic Sans MS, which looks quite reasonable as small point sizes (it only starts looking "jokey" at headline sizes). It's easy on the eyes, yet still keep the text small enough to have a reasonable amount of code visible in the text window, with several of VS's docked panels open.
You can have the Solution Explorer panel out, and still have 100 columns of text readable without horizontal scrolling. Moveover, I can have the DXCore Documentor panel (displaying formatted XMLDOCs) open wide enough to read while still being able to see enough of the text to doc the XMLdocs.
If you work in a team then mono-spaced fonts ensure that code is clear and correctly layed out for everyone, whatever mono-spaced font they prefer to use.
Your code may look clear to you when using a variable width font but it's unlikely to look the same if a mono-spaced font user opens it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With