polybar / polybar

A fast and easy-to-use status bar
https://polybar.github.io
MIT License
14.04k stars 703 forks source link

Token min and max width calculations wrong with non-ASCII characters #3074

Closed patrick96 closed 1 month ago

patrick96 commented 8 months ago

The calculation for padding and truncation of label tokens is inconsistent. For max-width it counts the number of unicode characters while for min-width it counts the number of bytes. This falls apart if the token text contains non-ASCII.

We should always use unicode codepoints for min and max-width

Discussed in https://github.com/polybar/polybar/discussions/3069

Originally posted by **nymver** January 4, 2024 So I have a module that displays the artist and title of current playing song. I have specified tokens (minimum and maximum width) (label = %output:-45:45%). If there are no Cyrillic letters in the text, everything is fine, but if there are, for some reason the width of the label is reduced. Module: ``` [module/running_string] type = custom/script exec = $HOME/.config/polybar/scripts/running_string tail = true format =
patrick96 commented 1 month ago

Fixed in #3090. This is not on master yet, it will be in the 3.7.2 release