Skip to content

Text Alignment with Different Fonts/Fonts that contain Icons #56

@duclos-cavalcanti

Description

@duclos-cavalcanti

Hi,

Im pretty happy with dzen and its scriptable capabilties. Aside from a general menu-like program, I also use it as a statusbar. I have however struggled with alignment issues.

Im aware (at least I believe so) that ^p() and even ^p(_LEFT/_RIGHT/_CENTER) are calculated relative to the current cursor position on the dzen instance. So, this isnt necessarily the best option if one is aiming to have a bar with left, center and right aligned text/icons.

Im also aware of the undocumented ^ba($bar_width, _LEFT/_CENTER/_RIGHT) option. However, if I was to run

echo "^ba(1920,_LEFT)Left^ba(1920,_CENTER)Center" | dzen2 -w 1920 -ta l -p

Things don't go as planned. Its hard to know why or if I am using it incorrectly since there isnt much to read on. But it seems that this justification of text is always relative to the current cursor position.

Im also aware of textwidth, where one could sample the width in pixels of a given string with a given font. That way knowing the width of ones text, together with the usage of absolute positioning of pa(), it then becomes feasible a proper alignment of a statusbar.

However, using different fonts through fn(), especially nerd/patched/powerline fonts, I at least have not been successfully able to find pixelwidths of different texts that are patched with icons. It may well be due to the fact that textwidth may only accept X logical font description of fonts and apparently icon patched fonts do not fall into that configuration.

Therefore alignment ends up hard coded which is a bit of a bummer.

I was wondering if a veteran user or mantainer or anyone knows about undocumented features or solutions to properly align a dzen statusbar which contains different fonts and/or with icons, could enlighten me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions