Skip to content

Instantly share code, notes, and snippets.

@rolfschr
Last active August 20, 2024 16:49
Show Gist options
  • Save rolfschr/4261ea856535c6007194b2b27f3dee04 to your computer and use it in GitHub Desktop.
Save rolfschr/4261ea856535c6007194b2b27f3dee04 to your computer and use it in GitHub Desktop.
zutty & HackNerdFontMono
Hi,
I'm trying to reproduce the experience I have with `urxvt` with `zutty` using the font "HackNerdFontMono". While I can use the font, I do have problems with it:
* The font color is the same as the background color (at least for me). Changing the colors (i.e. new "theme" in ~/.Xresources) did not have an effect.
* I do not have "Braille" symbols available (`btop` used as indicator here).
* I also want to have the special glyphs from that font. Those are not provideb by the font "Hack".
There are some screenshots with tests below. I'm sorry this is so chaotic, I worked on two different systems (wayland + xserver, not sure this makes a difference); both running NixOS.
Posting everything within the same comment would have helped to re-order but I had issues with this (besides also using two different GitHub accounts [work+personal]).
I have no clue about fonts and virtual terminals so please forgive if I'm asking/doing anything wrong/stupid here.
I have used zutty v0.16 as show here: https://github.com/NixOS/nixpkgs/pull/257156#issuecomment-2278807153
The comment below (https://gist.github.com/rolfschr/4261ea856535c6007194b2b27f3dee04?permalink_comment_id=5150931#gistcomment-5150931) shows my expected outcome.
Basic comparison is:
`urxvt -fn "xft:Hack Nerd Font Mono:size=12"` vs `zutty -font "HackNerdFontMono"`
@rolfschr
Copy link
Author

rolfschr commented Aug 11, 2024

Zutty - DejaVuSansMono

Zutty with DejaVuSansMono doesn't show braille signs in btop (CPU) and does not have the glyphs (lsd):

image

image

(Not sure the double with font error is important here.)

Zutty's default with default font 9x18

Zutty shows the braille, but no glyphs (which is fine, of course:

image

@rolfschr
Copy link
Author

For a quick overview on Braille support for nerd fonts, see ryanoasis/nerd-fonts#1064 and ryanoasis/nerd-fonts#837

@rolfschr
Copy link
Author

Zutty - HackNerdFontMono

Somehow, the font color is the same as the background (even when using a dedicated theme). The glyphs are shown (I think):

image

(btop is similar to DejaVuSansMono [no braille] but worse due to the same color of bg & font)

@rolfschr
Copy link
Author

Urxvt - Hack Nerd Font Mono

Glyphs + Braille are shown. Though on another system, I had to give urxvt another (=second) font to get Braille to work (which is consistent with the Braille support for Nerd fonts, see links above). On my current machine, it (=Braille) seems to work out of the box:

image

image

@rolfschr
Copy link
Author

Urxvt - DejaVu Sans Mono

image

@rollf
Copy link

rollf commented Aug 15, 2024

Zutty Hack lsd (Xserver)

image

Zutty HackNerdFontMono lsd (Xserver)

image
image

@rollf
Copy link

rollf commented Aug 15, 2024

Zutty HackNerdFontMono btop (Xserver)

image

@rolfschr
Copy link
Author

Feedback from the author:

I was able to reproduce your issue with HackNerdFontMono (not showing
anything but the background). That is due to a bug which is corrected
by the below snippet - feel free to test it:

diff --git a/src/font.cc b/src/font.cc
index d3f9118..6fd73fe 100644
--- a/src/font.cc
+++ b/src/font.cc
@@ -65,6 +65,9 @@ namespace zutty
       if (c == Unicode_Replacement_Character)
          return true;

+      if (c > std::numeric_limits<uint16_t>::max ())
+         return false;
+
       return ((dwidth && wcwidth (c) == 2) ||
               (!dwidth && wcwidth (c) < 2));
    }

@rolfschr
Copy link
Author

rolfschr commented Aug 20, 2024

The author integrated this (background issue) into zutty:

https://git.hq.sig7.se/zutty.git/commit/04b2ca3b3aaa070c41583247f8112c31b6003886

As for the Braille + nerd font glyph support, one needs to find a font that contains both. Zutty will not do any magic here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment