tb-keycast icon indicating copy to clipboard operation
tb-keycast copied to clipboard

Wrong width calculations when font differs in buffer and tab-bar

Open ir33k opened this issue 3 years ago • 1 comments

I discover that all calculations of position and width used to align status string to the right and avoid wrapping are incorrect when tab-bar have different font than buffer.

Its because to calculate width of string in pixels string-pixel-width function is used. It works by inserting string to temporary buffer and takes measurements there. If your buffer font is for example monospace but tab-bar font use proportional font it will return wrong value.

I believe that to fix this all we need is to apply font used in tab-bar to string before string-pixel-width function is used.

ir33k avatar Jan 28 '22 16:01 ir33k

I believe that to fix this all we need is to apply font used in tab-bar to string before string-pixel-width function is used.

This should generally be good enough. However, there are several more edge cases you may encounter. See https://github.com/yantar92/org/blob/feature/org-fold-universal-core/lisp/org-macs.el#L890

yantar92 avatar Jan 29 '22 02:01 yantar92