Live data from Hacker News

Monospaced Programming Fonts with Ligatures

hanselman.com

231–240 of 246 posts

Re: Monospaced Programming Fonts with Ligatures

#231
I think Scott updated the sample used for the screenshots after putting it in the post.

The code is listed as:

  // FIRA CODE
  object o; 
  if (o is int i || (o is string s && 
      int.TryParse(s, out i)) { /* use i */ }
  var x = 0xABCDEF;
  -> --> ==> != === !== && || http://www.hanselman.com 
  
  i++; #### ***
I think what was actually used is:

  // FIRA CODE
  ABCDEFGHIJKLMNOPQRSTUVWXYZ
  0123456789!@#$%^&*()_+={}[]/?'";:~`
  object o; 
  if (o is int i || (o is string s && 
      int.TryParse(s, out i)) { /* use i */ }
  var x = 0xAB_DE_F;
  -> --> ==> != === !== && || http://www.hanselman.com 
  
  i++; #### ***
The underscores in the hex literal are not part of the font, which looks like it is confusing some people.

A couple of those lines are new C# 7 features (patterns and literals) that appear to have been partially lifted from this blog post: https://blogs.msdn.microsoft.com/dotnet/2017/03/09/new-featu...

I wrote a section on C# 7 for a new chapter in the upcoming second edition of my book from last year. There are loads of useful new features in C# 7 (and 6 if you're still on 5) and I thought I recognised those snippets.

Re: Monospaced Programming Fonts with Ligatures

#232

Earlier quoted context omitted.

Why did you format the code snippets in your comment in a monospace font? Also, I'm curious. I want to see how the code looks like. I want to know what are the downsides of monospace and the benefits of proportional. The one you cited isn't too much of a deal, since it is just a habit you can create using monospace still.

> Why did you format the code snippets in your comment in a monospace font? Because I don't know of a way to get HN to format text in a proportional font without losing the line breaks. Believe me, I've tried. :-) > Also, I'm curious. I want to see how the code looks like. I am glad you are curious about it! > I want to know what are the downsides of monospace and the benefits of proportional. The one you cited isn't…

Well at least for yourself you could adjust code blocks with Stylish [1] and some custom css.

[1]: https://userstyles.org/

Re: Monospaced Programming Fonts with Ligatures

#233
post #227

Earlier quoted context omitted.

What about code that naturally represents tables, like this? rotationMatrix = [[ cos(x), -sin(x), 0], [ sin(x), cos(x), 0], [ 0, 0, 1]]

Yup, that's a great example of where a monospaced font helps. I don't claim that proportional fonts are ideal for every kind of code, only that it's an educational experience to try them out, even if just for a while. Your example is interesting because it combines two different kinds of alignment. One of them I find unhelpful - pushing everything to the right to match the length of the variable name. The other is th…

This is such a nice display of art and it is what I mostly judge a coders ability by.

Re: Monospaced Programming Fonts with Ligatures

#234

I'm mystified how any one finds these more readable. Form over function if you ask me.

Use them for a bit before judging it, don't forget that you've trained yourself to read some character combinations as meaningful. After using Fira Code for a while, I can say code looks weird without it. Especially plain === and => look really jarring now. The ligatures also help me spot typos! Regardless of the ligatures, one of the cooler things about Monoid is how it tries to fix kerning problems inherent to mono…

I'd like to use it, but they turn custom operators such as "|>|" into an illegible jumble of characters (in this case, "▷|"). If I'd wanted my operator to be "▷|", I'd have defined it that way.

Now, if they can come up with a way to selectively turn the ligatures off and on, I'll give it another go. Until then, I'm perfectly happy to see the occasional "Also, that "www" ligature is the stuff of nightmares. Never, ever, with I use that on my computer.

Re: Monospaced Programming Fonts with Ligatures

#235
post #53

It's $CURRENT_YEAR. Just let people write ≠ for ≠ already.

The problem with Unicode operators is good, consistent input methods.

Yeah. The thing that blows my mind is that the guy who runs Input Club (they make/design keyboards with open-source firmwares) sent the USB consortium an email a year or so ago asking if there were any plans to update the USB HID spec for unicode, and the response indicated that he was the first person to ask! Really?!? Unicode was out for a few years before USB even existed, and nobody'd even thought about it before? You'd think at least the word processor industry (which wasn't nearly as homogenous back then) would've jumped on it.

Re: Monospaced Programming Fonts with Ligatures

#236

Earlier quoted context omitted.

Sublime-text-style multiple cursor text manipulation would break here. And your code would look different than everyone else's machine. How would you display a guideline to make sure you were under a characters-per-line style? What advantages are there? I could never see it working for me. I want a program to format my code with resonable defaults and be done with it.

> your code would look different than everyone else's machine. Not if you use an indentation-only style like my second example. One of the great things about that style is that it looks the same on anyone's machine, whatever kind of font you use. If you read some of my code, you'll never know that I wrote it in a proportional font. It looks the same if you view it in a monospaced font. > How would you display a guide…

What proportional font do you use? I'd like to give coding in a proportional font a try but would like something designed for programming instead of just experimenting with Verdana.

Re: Monospaced Programming Fonts with Ligatures

#237
post #236

Earlier quoted context omitted.

> your code would look different than everyone else's machine. Not if you use an indentation-only style like my second example. One of the great things about that style is that it looks the same on anyone's machine, whatever kind of font you use. If you read some of my code, you'll never know that I wrote it in a proportional font. It looks the same if you view it in a monospaced font. > How would you display a guide…

What proportional font do you use? I'd like to give coding in a proportional font a try but would like something designed for programming instead of just experimenting with Verdana.

Yeah, Verdana is not great. I used to use Georgia, but when I started doing more on OSX I found that it didn't render well in all apps - the character strokes were too skinny. It looked great in Windows though.

For the last couple of years have been using Trebuchet MS. It's not designed specifically for programming, but it has many of the attributes of a good coding font, in particular all of the easily confused characters like 0Oo and 1Il are easily distinguished.

The one thing I don't like about Trebuchet is that it has a really terrible tilde (~). Sometime I will sit down with a font editor and swap in a better tilde.

I tend to use largish fonts on a high-DPI display, and Trebuchet really looks nice with that setup, both on Windows and macOS.

Someone else recommended Input, which is designed for programming and comes in both proportional and monospaced variants. When I tried Input it didn't look as nice as Trebuchet MS to my eyes though.

That will give you a few to try out!

Re: Monospaced Programming Fonts with Ligatures

#238

> Picking a programming font is like picking a religion. No matter what you pick someone will say you're wrong. Most people will agree at least that monospaced fonts are ideal for reading code and that both of you who use proportionally spaces fonts are destined for hell, or at the very least, purgatory. I guess I'm destined for hell or purgatory then. Hanselman is not alone. I had the CEO of one company look over my…

I never used a proportional font while coding in my life and I always used the second way of indenting. If this is the only advantage of the proportional fonts I guess that the mis-alignment disadvantage far, far outweighs it.

Re: Monospaced Programming Fonts with Ligatures

#239
post #15

I like switching fonts every couple of years just to keep it fresh. My font right now is Iosevka: https://be5invis.github.io/Iosevka/ A font generated from its source code. You can build your own variant. It has ligatures as well. I like that it’s not as wide as many other monospace fonts.

My problem with Iosevka (and Input and others like them) is that the [x-height][0] is too large, ie the bottom-half parts are too tall compared to the top-half and uppercase letters. Especially in less-wide weights, it feels muddy and hard to distinguish. [0]: https://en.wikipedia.org/wiki/X-height

That is exactly the kind of problem this font wants to solve. Just change the x-height to your taste: https://github.com/be5invis/Iosevka/blob/master/parameters.t...

Re: Monospaced Programming Fonts with Ligatures

#240

> I frankly can't understand how tiny font people can function. It gives me a headache to even consider programming at anything less than 14 to 16pt and I am usually around 20pt. What? I can't understand how such large font people can function. I mean, how large (or dense) are your screens? Is that a Macbook thing? I'm at... something small. Hard to tell exactly, because on my laptop screen, all following fonts look…

I have a 1080p 15" screen. I've configured my browser with a minimum font size of 18px as smaller text is hard enough to read, especially in the web pages suffering from the war on contrast. Because I sync my configs, also use them on my 21" 1080p displays on my desktop, but I could probably go smaller there.

That said, I turned off the OS scaling on Windows because apps that didn't support it got scaled by image scaling which resulted in unpleasant blurry messes. As for Linux, I don't think XFCE supports it at all.

On my work rMBP I also use 16px min, even with the OS scaling turned on.

When I was a teenager I used to use 10px fonts, but I tend to use displays at more ergonomic distances these days.

Post reply on HN