The Fira Code font (GitHub - tonsky/FiraCode: Free monospaced font with programming ligatures) just got some more Julia specific ligatures! I think some of them are pretty neat.
Thanks, this is awesome! Works in iTerm2 in my VIM without any problems…
doesn’t work in emacs though , at least not without a hack: https://github.com/tonsky/FiraCode/issues/211#issuecomment-239087391
there exist ligatures for .=
and .-
, where can I get a complete list of infix and unary operators?
Fira Code is my goto font, and it’s great. One weakness for Julia coders is the inconsistent ligatures for dotted operators, e.g. .-
vs .+
, which is a bit of a wart:
Also, ligatures don’t seem to work in the new Juno REPL, while they do work in the ordinary terminal REPL on MacOS.
I was going to open an issue because of that, I just need a complete list.
does it work with the hack though?
Upstream issue, in case you want to track it:
Haven’t tried it myself, but apparently it works partially.
maybe offtopic on offtopic: Is there a linux/X11 (or wayland) counterpart of iTerm2?
What feature(s) do you need specifically? Looking at their list, most of it is done by a collection of tools, eg tmux (in any terminal emulator, I use xfce4-terminal
).
There are a lot of them… Julia allows dots to prefix nearly all binary operators, which includes a large number of Unicode characters. See all of the operators grouped under (add-dots ....)
here:
In addition to that, you can also use these operators with combining characters (dots, hats, macrons, etc).
The most important ones are probably the dottable operators with a built-in definition in Base:
= += -= *= /= //= |\\=| ^= ÷= %= <<= >>= >>>= \= &= ⊻=
> < >= ≥ <= ≤ == === ≡ != ≠ !== ≢ ∈ ∉ ∋ ∌ ⊆ ⊈ ⊂ ⊄ ⊊ ≈ ≉
+ - | ⊻
<< >> >>>
* / ÷ % & ⋅ ∘ × \ ∩
// ^
(Some of these operators, like ≉
and ≢
, don’t even have glyphs without dots in common fonts, e.g. the font I’m seeing in my browser right now. Also, some fonts mess up operators with combining characters, e.g. +̂
is not combined in many fonts.)
You might also want a ligature for .(
for dotted function calls like f.(x)
.
I’m not sure that the ligatures for dotted operators are such a great idea, though. For example, how would .⋅
appear if you defined a ligature similar to the one you have for .-
? The raised dot in your ligature looks an awful lot like a multiplication operator.
Note also that <<=
is an assignment operator in Julia and many other languages, and the current ligature doesn’t reflect this (https://github.com/tonsky/FiraCode/issues/560).
The other problem I have when looking at some of these ligatures is that if I’m looking at someone’s code and see a non-obvious ligature, I might not know how to type it. My first guess would be that it is some Unicode character (Julia supports a lot of those and they are common in Julia code), not a ligature.
Note also that -> => ⟶ ⟹
are all distinct operators in Julia. It seems that your ligatures make the first two look very similar to the latter two, which is a problem. (Filed https://github.com/tonsky/FiraCode/issues/559) This illustrates the general danger of mixing fancy ligatures with a language that supports both ASCII and Unicode operators.
I have very little knowledge about ligatures and how the substitution actually works. I know that there are switches called font features that can turn on and off certain ligatures, it would probably make sense to have a julia font feature
that is aware of these things.
Looking at all the possible operators in Julia it is possible to write really confusing code only by using similarly looking Unicode operators.
thanks for pointing me there!
I have a related question: Does anyone know a Windows ttf monospace font, which can display the most basic Julia Unicode characters, like \xor, \euler, \in… in the REPL? It is quite sad, that these are only shown by 2 otherwise terribly looking standard Windows fonts: MS Gothic and NSimSun. (MS Gothic even replaces ‘\’ with a crossed over ‘Y’.)
usually I’m working in Juno and unicode is displayed fine (inline and in REPL)
On windows, a solution for a standalone command line is to use conemu/cmder, and set a font under “Alternative Font” which is used for unicode glyphs.
I’ve found that GNU Unifont Glyphs has all the things.
Thanks, Alan. Unifont as alternative font works in ConEmu! Unfortunately, it seems to be a low resolution raster font, and so some glyphs are not recognizable, but it has all the symbols I need.
I keep on looking for nicer, truly scalable fonts, and would appreciate more suggestions.
…I found FreeMono: http://www.fontspace.com/gnu-freefont/freemono. It has much fewer glyphs, but the included ones are beautiful.