havoc icon indicating copy to clipboard operation
havoc copied to clipboard

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

Open jmcamp opened this issue 3 years ago • 5 comments

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.

jmcamp avatar Jan 07 '22 22:01 jmcamp

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.

ii8 avatar Jan 10 '22 16:01 ii8

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.

jmcamp avatar Jan 11 '22 05:01 jmcamp

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.

ii8 avatar Jan 11 '22 10:01 ii8

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.

jmcamp avatar Jan 11 '22 13:01 jmcamp

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.

ii8 avatar Jan 11 '22 13:01 ii8