Subject: bug#19972: Font size change doesn't update (window-total-width)

From: martin rudalics <[email-masked]>
Date: Mon, 02 Mar 2015 18:10:35 +0100

> - Consider the case of full-screen frames, which never change in pixel
 >   size. The window-width should change when the font size changes in
 >   this case too.

This is the case (hopefully) with Emacs 25 but not with Emacs 24.5.
Although some window managers may refuse to change the frame size even
with Emacs 24.5 as we've learned here.

 > - set-frame-font is a built-in function with a KEEP-SIZE param which
 >   tells it to try to preserve the pixel-size of the frame after the
 >   font has changed: my code is copied from there.

If you look at the implementation of this you will see that it first
resizes the frame (via x_new_font) and then tries to size it back to the
original size.  This will fail miserably when the frame was maximized
before (because maximization is a state and not just a specific size)
and will fail when the frame size was not an integral multiple of its
default character size (because `set-frame-font' does some strange
rounding).  So never ever use `set-frame-font' with KEEP-SIZE non-nil.
With Emacs 25 you can do, for example,

(let ((frame-inhibit-implied-resize t))
   (custom-push-theme 'theme-face 'default 'user 'set '((t (:height 128))))
   (face-spec-recalc 'default (selected-frame)))

unless you have set `frame-inhibit-implied-resize' to non-nil already.
Which currently causes `window-total-width' to return a wrong value ;-)

 > So there really shouldn’t be any assumption that the frame size will
 > necessarily change when the font changes.

Emacas <= 24.5 at least _always_ tries to change it.

martin