Recommendation for a font with good Unicode support?

What are some good fonts for writing Julia code?

In particular, does anyone know a font with good support for combining characters on greek letters? The default fonts in Ubuntu perform poorly in this regard…

Here’s how DejaVu Sans Mono (default monospace font) renders \alpha\hat=0: image
Ubuntu Mono is better, but some greek letters are hard to distinguish from latin letters: image
And it fails on tall letters: image
There is a Thai font called Tlwg Mono that renders this correctly, but the weight of non-greek characters is too light: image

Any recommendation? (appart from “stay away from these characters, even if you get them working, it won’t work on other people’s computer” :slight_smile:)

6 Likes

Both Fira Code and JetBrains Mono render those fine for me. With those you get also code ligatures, for example displaying -> as a continuous arrow (which some people really like, while others really despise it).

2 Likes

I love writing in Unicode variable names (perhaps a bit more than I should), especially for my physics-based applications. I haven’t really had any trouble with the default font in Jupyter (not exactly sure what that is, should be the default monospace font), though the modifiers aren’t something I use often. I can get visually the right behavior by using \hat \alpha=0, but that line can’t be evaluated, I think because Julia doesn’t like the hat operator at the start of variable names? It does also overlap for beta.

I think Jupyter uses the default monospace font from the browser. On my system it looks like it’s the same font as in the terminal (I agree it works pretty well usually!).

Note that you need to write \alpha\hat: the hat is a combining character that goes over the preceding character. And this way you obtain a valid Julia identifier :slight_smile:

1 Like

Both Fira Code and JetBrains Mono render those fine for me.

These seem to work very well, thanks!

2 Likes

Google’s Noto Mono works pretty well for me.

Edit: Yes, sorry, I meant Noto Sans Mono. The Arch package installs fine.

2 Likes

Thanks for mentioning this. I had tried it and it had the same issue, but it turns out there’s a new version called Noto Sans Mono and it seems to work very well, at least in Jupyter. Unfortunately I cannot use it as terminal font due to bug in the metadata: Noto Sans Mono doesn't declare spacing property · Issue #196 · notofonts/latin-greek-cyrillic · GitHub

I did some tests on Ubuntu 20.04, in the Gnome terminal and in the browser (e.g. Jupyter in Chrome or Firefox) and Juno. It appears that

  • some fonts work well in the terminal but not in the browser
  • some work well in the browser but cannot be selected in the Gnome terminal

Here’s a summary, testing for support of combining hat character on greek letters, such as "θ̂ " (obtained with \theta\hat).

Font Version (head/name) Gnome Terminal Browser/Juno Open license
Bitstream Vera Sans Mono 2.000/1.10 :x: :x: :heavy_check_mark:
Cascadia Code 2005.150 :x: :x: :heavy_check_mark:
Consolas 1.000 :x: :x: :x:
Cousine 1.220 :x: :x: :heavy_check_mark:
DejaVu Sans Mono 2.370 :x: :x: :heavy_check_mark:
Fira Code 4.000 :heavy_check_mark: :heavy_check_mark: :heavy_check_mark:
Go Mono 2.008 :x: :x: :heavy_check_mark:
Hack 3.003 :x: :x: :heavy_check_mark:
Inconsolata 3.001 :x: :x: :heavy_check_mark:
Iosevka 1.000/3.0.1 :heavy_check_mark: :heavy_check_mark: :heavy_check_mark:
JetBrains Mono 1.000/1.0.3 :heavy_check_mark: :x: :heavy_check_mark:
Latin Modern Mono 2.004 N/A :x: :heavy_check_mark:
Liberation Mono 2.100/2.1.0 :x: :x: :heavy_check_mark:
Linux Libertine Mono O 5.100/5.1.7 N/A :x: :heavy_check_mark:
Menlo 6.100/6.1d5e14 :x: :x: :x:
Monaco 2.000/5.1d1e1 :x: :x: :x:
Nimbus Mono PS 1.000 :x: :x: :heavy_check_mark:
Noto Mono 1.000 :x: :x: :heavy_check_mark:
Noto Sans Mono 2.002 N/A :heavy_check_mark: :heavy_check_mark:
SF Mono 0.000/15.0d5e1 :heavy_check_mark: :heavy_check_mark: :x:
TeX Gyre Cursor 2.004 N/A :x: :heavy_check_mark:
Ubuntu Mono 0.800 :x: :x: :heavy_check_mark:

So on my system at least, the winners are Fira Code and SF Mono (edit: and Iosevka). They’re the only fonts that work both in the terminal and in Jupyter and Juno. I find SF Mono a bit nicer but the license seems to be very restrictive (though I couldn’t find any licensing information in the dmg file downloaded from Apple’s website).

Now I can write

image

:smiley:

Edit: It looks like some font files have conflicting metadata between the “head” and “name” tables (fontRevision and Version fields respectively). I’ve put both versions when they don’t agree.

8 Likes

My personal favorite is

It is compact yet readable, well-designed, and the author is pretty responsive about adding missing chars.

6 Likes

This Iosevka font looks very interesting, and highly customizable. And the combining characters work perfectly. Thanks for mentioning it, I’ve added it to the table.

2 Likes

Try Envy Code R. Very legible.

I have now tried all fonts coming with the Atom fonts plugin GitHub - braver/fonts: Free and open fonts for the Atom editor , and only few of them passed the following test:
∂ₜu - Δu*(γ₁-α)*α̂=0 # это по-русски
(in case your browser doesn’t display everything properly: the second character is subscript-t).

Those were Iosevka family, Corby Mono S, DejaVu fonts, and GNU Unifont. Of these I choose DejaVu Sans Mono - Bront, with Iosevka Extended Medium being the close second. Tested on Mac and Windows.

2 Likes

Thanks @PetrKryslUCSD and @Eben60, I’ll test these ASAP, once my automated testing script is ready.

Just a note that I put up a web page to show a more proper comparison of fonts: https://mono-math.netlify.app/

The comparison above in this thread is flawed (or at least very system-dependent) because it looked at text rendered with fallback fonts for glyphs missing from the tested font. For the web page, the text was rendered without fallback font so any missing glyph is shown as missing.

(I didn’t want to revive this thread but my post above is a bit misleading and too old to edit, and it keeps getting attention…)

6 Likes

Nobody mentioned JuliaMono? https://juliamono.netlify.app/
image

edit: it is the font mentioned on sudete last link, although it was not mentioned in the thread.

10 Likes

A criminal omission…

It’s the problem with reviving old threads: JuliaMono didn’t exist at the time! To me it’s clearly the best recommendation now (as the web page makes clear), so I’ll mark it as solution :slight_smile:

5 Likes

Not starting a new topic for this, but

is growing on me. Looks whimsical, but at the same time that makes characters easy to distinguish.

7 Likes

I’ve been using the new fonts developed at Github:

3 Likes