top | item 44648085

(no title)

evertheylen | 7 months ago

Why don't we embrace proportional (i.e. not monospace) fonts more for coding? IMHO, they are a big step up when it comes to legibility. I personally switched after I noticed reading stuff in the sidebar (which is usually in a proportional font) felt more comfortable than reading code.

You can't use it for a terminal of course, and occasionally I find comments relying on monospace alignment. Other than that I see no downside to proportional fonts.

I use Input, which gives more room to special characters and is pretty nice overall: https://input.djr.com/

discuss

order

fainpul|7 months ago

I fully agree that proportional fonts are nicer to read, even for code. When I tried to use it, I got annoyed by Go, which autoformats code with spaces to align stuff and that looks very ugly with a proportional font. The solution would be elastic tabstops [1], but that seems just to be a concept without actual support in any editor.

[1] https://nick-gravgaard.com/elastic-tabstops/

NoGravitas|7 months ago

If you use a true proportional font, you give up aligning code elements other than basic indentation. For most people, that's too much to give up.

I do like quasi-proportional fonts like Iosevka Aile, where very wide or very narrow characters are allowed something more like their natural widths. I think, though I'm not sure, that the widths are worked out so that "Wl" (wide + narrow) is the same length as "xx" (2 x normal), for example. My experience using Iosevka Aile in Emacs is that things usually-but-not-always align like they're supposed to, which is a better trade-off than fully proportional fonts.

WorldMaker|7 months ago

> If you use a true proportional font, you give up aligning code elements other than basic indentation.

Have you ever gotten deep into how tab stops work in Word?

The deeper you go the more you realize fun things like Tables are as much "Tab Stops with Borders" as they are a separate concept to Word. The UI/UX of both reflect each other.

WYSIWYG word processors and design tools have lots of ways to align proportional fonts.

The big thing is that to do it well they need a ton of metadata: this "paragraph" has tab stops at 1", 2", 4", and 5.5", two of the stops are right-justified and one is centered. Word makes it surprisingly easy to edit all of that metadata easily and visually in the Ruler up top.

If you are sticking to plain text documents that are easy to source control, where and how do you store that metadata? How do you keep it from being a distraction from the code you want to write?

It's not an insurmountable problem, we could do some really cool things if we tried. One half-baked thought off the top of my head here is that I bet you could do something rather cool with easily embedded CSS Grid descriptions in nearby comments and Tab/Newline-delimited sequences auto-populating cells in the grid. Given how much of our code is HTML rendered anyway and how ubiquitous HTML renderers are in our digital lives, CSS Grid isn't the worst model to reuse for something like this, and might be something someone could build a prototype with relatively quickly.

DASD|7 months ago

You might also like monospace fonts with "smart kerning" as available with Commit Mono font. https://commitmono.com

bjourne|7 months ago

Typos feel way harder to spot in proportional fonts. Maybe because proportional fonts are easier to read so your brain subconsciously ignores them. And typos, like a misplaced or forgotten comma, can cause some of the most annoying bugs. Also, most editors still mostly operate on individual characters. With a fixed width font I can immediately see how many cursor up and cursor left commands I need to send to move the cursor to a specific position in the text.

CRConrad|7 months ago

> Why don't we embrace proportional (i.e. not monospace) fonts more for coding? IMHO, they are a big step up when it comes to legibility.

No, according to what seems to be the common definitions in this thread (dunno if that's the "official" one, or if such a thing even exists), they're better for readability, not legibility. And I agree with user bjourne's comment[1], "Typos feel way harder to spot in proportional fonts." What we need for coding is mainly legibility, not readability.

Well, at least usually, while writing and editing. For getting an overview of a large codebase, the increased readability of a proportional font might be better. (So what we really need may be a quick way to switch our editor or IDE between proportional and non-proportional fonts.)

[1]: https://news.ycombinator.com/item?id=44654792

maybebyte|7 months ago

You know, I've heard this idea about proportional fonts before and have been intrigued by the idea. I use Neovim running inside Alacritty as my code editor, though, so unsure if it'll work for me or not.

Going to check that font out - thank you for the suggestion. :)

CalChris|7 months ago

> You can't use it for a terminal of course

That is the problem, though. I edit with neovim inside of wezterm. The few times I've seen proportional used for code, I've thought that it looked interesting but realistically, I live in a vt100 universe and all things considered, it's really not that bad.

I'm interested in Atkinson Hyperlegible Mono as a programming font. I think monospaced is a defining characteristic of programming fonts. Basically, legibility is just different for programming and text (although I clearly read too much Verdana).

giraffe_lady|7 months ago

Well, the alignment is a pretty significant downside.

There are now some excellent mono faces that have broken from a lot of the traditional monospace design elements and that look and feel very much like proportional fonts. Quadraat sans mono, cartograph cf, triplicate, I've seen a good homebrew alegreya sans mono variant too. I don't know of any free ones, though inconsolata-g is well in that direction. But I expect more of this trend over the next few years.

hollerith|7 months ago

Which IDE or editor are you viewing this proportional font in?

A proportional font in Emacs doesn't look right to my eye. My guess is that there are subtleties in the spacing between letters when a browser or a book publisher renders the text that Emacs does not know about.

accelbred|7 months ago

Emacs should also be doing kerning. I use proportional fonts for non-prog-mode buffers and no issue here.

sureglymop|7 months ago

Maybe this is a silly idea, but what about a terminal emulator that could switch fonts on the fly?

For example, it could switch to a monospace font when a "fullscreen" program like vim switches to the other buffer.

Or maybe it could even render different fonts per line.

namibj|7 months ago

You sound like you want Emacs. The X11 frontend.

esafak|7 months ago

Isn't it the opposite; use proportional fonts in the terminal but not code, where alignment matters? I am giving it a try, and I like it on first impression.

babypuncher|7 months ago

Tons and tons of terminal apps are written assuming a monospace font. Alignment matters and you don't have much control over that.

In code, you can always choose a style that discourages spatial alignment.

Jaxan|7 months ago

Alignment in the terminal matters. Even something like ls uses columns.

fainpul|7 months ago

Terminals usually don't support proportional fonts.

bityard|7 months ago

Some people use proportional fonts in their IDEs, and have been for decades. It's just not exactly a mainstream practice. (I seem to recall that Microsoft used proportional fonts in their IDEs in the 90's. Or maybe I'm thinking of Visual Basic? Not sure.)

The main reason I have felt no inclination to use proportional fonts when coding is that proportional fonts tend to be _very_ bad at distinguishing homoglyphs and that is the _last_ thing you want when trying to find the syntax error or undefined variable. Although I will admit that I haven't look very hard for a proportional font that's actually meant for programming.

The other reason is that sometimes I read code where someone has created an ASCII diagram in the comments, or have other structures or whitespace where vertical alignment matters. (This used to be highly popular in C, although it's viewed as a bad practice in "modern" times.)

I find monospace code very easy to read, so I guess at the end of the day, proportional fonts have a few disadvantages with no real upside. For me at least.

CRConrad|7 months ago

> I seem to recall that Microsoft used proportional fonts in their IDEs in the 90's. Or maybe I'm thinking of Visual Basic? Not sure.

What's the distinction you're making here; are you saying Visual Basic isn't an IDE? Because AFAICS it very much is. (Or was, whatever. For its time, not even a bad IDE AFAICR.)

eviks|7 months ago

Because unfortunately the tools are too primitive and don't support it

antiframe|7 months ago

Emacs has been around for decades and supports proportional typefaces everywhere I tried to use them. Are modern tools more primitive than that?