On Wed, Aug 6, 2025 at 3:51 AM Juri Linkov wrote: > Thanks for the detailed test cases that demonstrate the problem. > > > The the `tab-bar-format-align-right' width cache isn't updated when > > faces change and doesn't take into account the fact that faces can have > > different attributes on different frames. > > > > To reproduce, launch "emacs -Q" then yank the following into the scratch > > buffer: > > > > (setq global-mode-string > > (list "" "GNU Emacs is a version of Emacs...") > > tab-bar-format > > '(tab-bar-format-align-right tab-bar-format-global)) > > (tab-bar-mode 1) > > > > And evaluate the buffer (M-x eval-buffer RET). > > > > Finally, increase the font size with `global-text-scale-adjust': C-x > C-M-0 +++++ > > > > The tab-bar text will get pushed off the right side on Emacs master but > > not in the latest release. See the attached screenshots. > > > > Furthermore, different frames can have different text sizes. Personally, > > I use this to scale each of my frames' text based on the monitor's > > DPI. To reproduce, launch "emacs -Q", yank the following into the > > scratch buffer, and evaluate it: > > > > (setq global-mode-string > > (list "" "GNU Emacs is a version of Emacs...") > > tab-bar-format > > '(tab-bar-format-align-right tab-bar-format-global)) > > (tab-bar-mode 1) > > (set-face-attribute 'default (selected-frame) :height (* 2 > (face-attribute 'default :height))) > > (make-frame) > > > > The tab-bar text will be correctly aligned in the new frame but not in > > the original frame. > > > > The per-frame issue can be fixed by making the cache per-frame but > > reacting to face changes is harder. Given that this is simply a cache, > > I'd recommend reverting the change and living with the slight > > performance hit. > > Instead of reverting the change maybe it would be better to add > a customizable cache function that anyone could change to adapt caching > to own needs by adding more cache keys such as e.g. '(selected-frame)', > '(face-all-attributes 'default)', 'face-remapping-alist', ... > I right align text on my tab bar and also use multiple text scales on different frames. IMO, customizing the cache function pushes too much of the cache (and string-pixel-width) implementation details on users, and seems a likely source of confusion.