rougier / mastodon-alt

Emacs alternative mastodon layout
GNU General Public License v3.0
46 stars 10 forks source link

Compute right-aligned status indicators not in characters, but pixels? #6

Open DivineDominion opened 1 year ago

DivineDominion commented 1 year ago

The proposed look and feel is great! 👍

I have display issues with the statuses, though: This depends on the font being used, I guess, but not all emoji are of the same width. Some take up 2 characters. This doesn't gel well with right-aligning, though, in some circumstances like this one:

image

image

I believe once we calculate the width of the string with the faces applied, we could use :align-to (- right (??? . px))), i.e. specify the unit in pixels instead of characters: https://www.gnu.org/software/emacs/manual/html_node/elisp/Pixel-Specification.html

I also found that mastodon-alt-tl-show-status is not used at all a.t.m. so I couldn't toggle the statuses off completely. I'm adding a PR in a second.

rougier commented 1 year ago

Oh that would be great if you can fix it. I'm using the nerd font that guarantee glyhp to be one character wide but I noticed the problem with emojis. How do you get the string width in pixels though?

DivineDominion commented 1 year ago

How do you get the string width in pixels though?

I have no clue, yet. :) Will be asking around!

https://www.gnu.org/software/emacs/manual/html_node/elisp/Size-of-Displayed-Text.html

DivineDominion commented 1 year ago

This looks promising: https://github.com/emacs-mirror/emacs/blob/master/lisp/emacs-lisp/subr-x.el#L318

No time to try until later today, though.

bmp commented 1 year ago

@rougier Thank you for the wonderful theme!

@DivineDominion Did you manage to fix this?

I would have loved to do this, but I don't know how to go about doing this.