Skip to content

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

@patrick96

Description

@patrick96

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 #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 = <label>
label = %output:-45:45%

Screenshot_2024-01-04_02 42 18
Screenshot_2024-01-04_02 42 24

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions