greshake / i3status-rust

Very resourcefriendly and feature-rich replacement for i3status, written in pure Rust
GNU General Public License v3.0
2.85k stars 470 forks source link

[Feature] Use different kinds of unicode spaces for padding in formatters #1875

Open tkapias opened 1 year ago

tkapias commented 1 year ago

Introduction

With some fonts, even monospace ones, i3status-rust will adjust and display characters and spaces in variable width. It's an issue to setup padding, manually or with formatters.

Issue

As said in #1800, to manually add padding to a string I use different kinds of space characters like U+2007 (digit width) or U+2008 (ponctuation width), check the list here.

But, the internal formatters like .eng or .str only use adjusted spaces U+0020. And with some fonts, the displayed width of the strings will be variable even if you use .str(w:20) or .eng(w:20).

Questions/Solutions

The most obvious solution would be to use fixed width fonts, that's what I was doing until recently.

But, I generated a new monospaced font with the last Nerd-fonts, it fixed all my issues with glyphs in the terminal, and it's displayed with a fixed width like expected. Then, I tried it in i3status-rust and surprisingly the characters width was adjusted. But, it got 2 advantages:

As i3status-rust is a one-liner there is not really any need for a fixed width on all characters, but formatters width or space features should have options to specify the unicode space character. And the existence of those should be documented for formatters and manual strings padding.