ii8 / havoc

minimal terminal emulator for wayland
Other
108 stars 18 forks source link

havoc doesn't display alsamixer / ncurses box-drawing characters correctly with RobotoMono font #41

Open jmcamp opened 2 years ago

jmcamp commented 2 years ago

I'm running havoc git on sway on arch linux.

If I set my font to RobotoMono in havoc.cfg like so: [font] path=/usr/share/fonts/TTF/RobotoMono-Regular.ttf then the box drawing characters aren't displayed correctly when running alsamixer: havoc_alsamixer_RobotoMono

If I change my font to JetBrainsMonoNL-Regular.ttf then it's displayed correctly: havoc_alsamixer_JetBrainsMonoNL

If I use sakura with RobotoMono, it's displayed correctly: sakura_alsamixer_RobotoMono

Since RobotoMono works with sakura, it appears the problem is with havoc.

ii8 commented 2 years ago

So the issue here seems to be that the box drawing glyphs do not exist in that Roboto font, but not only that, the .notdef glyph which represents a character that does not have a glyph in a particular font is also missing(which violates the spec IIRC) This is why there is just random data in those cells, because there was nothing to render into them. I will add some code later so havoc can draw it's own .notdef glyph replacement when it is missing from a font.

What this sakura terminal probably does is take the glyph from a different font.

jmcamp commented 2 years ago

I found a workaround by launching havoc with a custom config file when I want to run alsamixer, like so: $ havoc -c $HOME/.config/havoc.cfg.with_alternate_font alsamixer "havoc.cfg.with_alternate_font" is identical to "havoc.cfg" except it specifies a font which has the box drawing characters. This way I get to use my preferred Roboto font in all cases except for alsamixer, which is fine with me.

ii8 commented 2 years ago

Nice. Alternatively you could add the box drawing characters to roboto with font forge. Or we implement a font fallback mechanism in havoc so missing glyphs can be taken from other fonts, but I don't really want to add a fontconfig dependency.

jmcamp commented 2 years ago

I found that Foot Terminal by default uses it's own internal box drawing characters: https://codeberg.org/dnkl/foot/src/branch/master/doc/foot.ini.5.scd#L130

Since there's a workaround I'm not sure it makes sense to add this to Havoc. I like Havoc because it's simple and light and not weighed down by too many rarely used features.

ii8 commented 2 years ago

It's a nice idea but looks like it's not all that trivial, theres 3 thousand lines of code in foot just for box drawing https://codeberg.org/dnkl/foot/src/branch/master/box-drawing.c Thats twice as much as my font renderer and caching mechanism just for some lines. Maybe I can find a simpler way to do it.