tonsky / FiraCode

Free monospaced font with programming ligatures
SIL Open Font License 1.1
77.26k stars 3.1k forks source link

Question: how to deal with non-monospace ligatures? #1258

Open AckslD opened 3 years ago

AckslD commented 3 years ago

I'm wondering how to deal with long ligatures since they are effectively not monospace? For example underlines of headers in markdown:

gscreenshot_2021-06-23-171702

or simply trying to draw some boxes in ascii:

gscreenshot_2021-06-24-141149

gscreenshot_2021-06-24-142233

(the character before the right +s is a - even though it looks like a )

I'm using latest ttf-fira-code from the arch repository in neovim 0.5

tonsky commented 3 years ago

I'm not sure what’s causing that in your case. For me they are monospace (Fira Code 5.2 in Sublime Text on macOS):

Screenshot 2021-06-24 at 19 39 11
AckslD commented 3 years ago

That looks much better :) I'm using kitty btw, should have probably mentioned that. I tried to see what's going with running it with --debug-font-fallback. It's hard to see what is what but it does sometimes fallback, for example this is the start:

> kitty --debug-font-fallback
[175 15:14:54.255153] Preloaded font faces:
[175 15:14:54.255177] normal face: /usr/share/fonts/TTF/FiraCode-Regular.ttf:0
[175 15:14:54.255187] bold face: /usr/share/fonts/TTF/FiraCode-Bold.ttf:0
[175 15:14:54.255195] italic face: /usr/share/fonts/TTF/FiraCode-Regular.ttf:0
[175 15:14:54.255203] bi face: /usr/share/fonts/TTF/FiraCode-Bold.ttf:0
U+f3e2 Face(family=Font Awesome 5 Brands, style=Regular, ps_name=FontAwesome5Brands-Regular, path=/usr/share/fonts/TTF/fa-brands-400.ttf, index=0, is_scalable=True, has_color=False, ascender=448, descender=-64, height=558, underline_position=-49, underline_thickness=25, strikethrough_position=132, strikethrough_thickness=25) (new face)
U+f126 Face(family=Font Awesome 5 Free, style=Solid, ps_name=FontAwesome5Free-Solid, path=/usr/share/fonts/TTF/fa-solid-900.ttf, index=0, is_scalable=True, has_color=False, ascender=448, descender=-64, height=558, underline_position=-49, underline_thickness=25, strikethrough_position=132, strikethrough_thickness=25) (new face)
U+2714 Face(family=FreeSerif, style=Regular, ps_name=FreeSerif, path=/usr/share/fonts/gnu-free/FreeSerif.otf, index=0, is_scalable=True, has_color=False, ascender=900, descender=-200, height=1200, underline_position=-150, underline_thickness=50, strikethrough_position=258, strikethrough_thickness=49) (new face)
cormullion commented 3 years ago

I've read that Kitty draws its own boxes, and ignores the ones provided by the font. You could investigate this the truth of this with the Kitty dev...

AckslD commented 3 years ago

Thanks @cormullion! I opened an issue in the kitty repo to see if anyone have some insight into this. I'm afraid I have to little knowledge about font rendering to know how to test it or see if there is a solution :)

AckslD commented 3 years ago

@tonsky Where you using drawing characters https://en.wikipedia.org/wiki/Box-drawing_character in you case or normal ones, ie:

+----------------+
|                |
|  +----------+  |
|  |          |  |
|  |  +----+  |  |
|==|==|    |==|==|
|  |  +----+  |  |
|  |          |  |
|  +----------+  |
|                |
+----------------+
tonsky commented 3 years ago

These are normal ASCII dash, pipe, plus and equals sign

AckslD commented 3 years ago

The developer of kitty said that:

Those arent issues with box drawing characters, those are issues with the new infinite length ligatures in fira code not lining up with the non-ligature glyphs. If you want to draw boxes, use the actual box drawing charaters https://en.wikipedia.org/wiki/Box-drawing_character

Infinite length ligatures are not really a substitute for actual box drawing characters, precisely because there is no longer any guarantee they will line up.

tonsky commented 3 years ago

Well they do line up everywhere but in Kitty ¯\ (ツ)

AckslD commented 3 years ago

@tonsky I just tried using https://aur.archlinux.org/packages/alacritty-ligatures/ and there they indeed line up, so closing this since it seems to indeed be an issue with kitty. Thanks for the help!