Skip to content

Instantly share code, notes, and snippets.

@rolfschr
Last active August 20, 2024 16:49
Show Gist options
  • Select an option

  • Save rolfschr/4261ea856535c6007194b2b27f3dee04 to your computer and use it in GitHub Desktop.

Select an option

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

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