Think before you monospace
Put your programming font to the ultimate test case.
I conducted a poll on Mastodon to see if what fonts are used in programming these days.
Despite the limited sample size, the poll seemed representative of package installation statistics. After going through the replies to the poll, I discovered a web application called programming-fonts where you can try out 98 monospace fonts with syntax highlighting on the fly. However, a good test case was missing.
It is unlikely that a font would meet all features, while being aesthetic. Features include how similar characters are distinguishable and eye-candy like ligatures (which can be useful or weird).
As they say,
“Beauty lies in the eyes of the beholder.”
Here is a test case with some pseudo-code to identify common pitfalls and features. See if it fits your needs and ensure no surprises.
Test case template
- Python
@test # INFO: How @ gets rendered def ultimate_monospace() -> bool: # INFO: Ligature for arrow assert 1nfo != lnfo != Info # WARN: 1, l, I should be distinguishable assert 0 != O # WARN: 0 and O should be distinguishable if find and ifnd: # WARN: Ligature for fi if this == 1 or that >= 2: # INFO: Ligature for ==, >= return True
- Octave
if (logic && oper || not ~= equals ) % INFO: Ligature for &&; WARN: for ~= ans = true end
- Javascript
() => { arrow_operator } // INFO: Ligatures for arrow operator
- HTML
<!-- INFO: Ligatures for HTML --> </> <empty> tag </empty>
- Perl / Ruby / PHP
1 <=> 1 # INFO: Ligatures for spaceship operator
- Haskell
-- INFO: Ligatures for Haskell operators: ++, >>=,<<=, >=>, <=< a ++ b -- instead of return x >>= f >>= g -- simply go with f x >>= g -- instead of \x -> return x >>= f >>= g -- simply go with f >=> g -- or g <=< f
Try it yourself
Here is how the above test case renders with Python syntax highlighting and Fira Code font:
About the author
Ashwin Vishnu Mohanan, Ph.D. in Fluid mechanics