Subject: bug#52493: 29.0.50; Setting Inconsolata up in init.el makes default face rendered wrong

From: Dmitry Gutov <[email-masked]>
Date: Mon, 9 Jan 2023 02:12:36 +0200

On 07/01/2023 11:15, martin rudalics wrote:
>  > - Width shrinks only once (at certain rare widths), and after that it 
> is stable.
> 
>    x_new_font old char size 21x45 new char size 17x37 text chars 113x36 
> old text pixels 2380x1628 new text pixels 1921x1332
>    xg_wm_set_size_hint scale 2 char width 17 toolbar 0 vscroll 32 
> fringes 16 borders 0 base width 32 width inc 8
>        char height 37 menubar 50 toolbar 82 hscroll 0 borders 0 base 
> height 84 height inc 18
>    xg_frame_set_char_size old native pixels 2428x1628 new native pixels 
> 1969x1332 outer pixels 984x732 outer rest 0x0
>    xg_frame_resized old native pixels 2428x1628 new native pixels 1968x1332
>    adjust_frame_size old native pixels 2428x1628 new native pixels 
> 1968x1332 old text pixels 2380x1628 new text pixels 1920x1332 old text 
> chars 113x36 new text chars 112x36
> 
> Here we calculate outer_width as (/ (+ 1921 32 16) 2) that is 984 and
> outer_height as (/ (+ 1332 50 82) 2) that is 732.  Since 1921 is impair
> we lose one pixel due to scaling.
> 
> Now width_rest calculated as (% (- 984 32) 8) and height_rest calculated
> as (% (- 732 84) 18) are both zero so we do not do any compensating and
> lose one column after resizing.
> 
> I attach a version to handle this particular case.  Let's see whether it
> breaks something else.

Thanks, it's almost perfect:

- My init script ends up at 80x36 pretty reliably, after a bunch of 
frame resizings.

- There seems to be no scenario for successive set-face-attribute calls 
to keep resizing the frame.

Here's a few more complex ones that seem off:

;;; Scenario 1
;; 1.
(set-face-attribute 'default nil :height 110 :family "InconsolataLGC")
;; to get the frame sized right
;; call (set-frame-size nil 80 36)
;; or (set-frame-size nil 160 36)
;; or don't if the frame is at that size already (which it should be)
;; (frame-text-lines) returns 36
;; 2. !important
;; manually resize the frame using the mouse to have one line less
;; (frame-text-lines) will continue to return 36
;; 3.
(set-face-attribute 'default nil :height 110 :family "InconsolataLGC")
;; The frame will get resized to the previous dimensions.
;; Note that the return value of (frame-text-lines) doesn't change.

;;; Scenario 2
;; Do the same steps, except for the width instead of height.
;; Optionally, use different dimensions:
;; (set-frame-size nil 160 36)
;; These are the only ones I found to have this effect for both dimensions.
;; I'm guessing 160x72 will work as well, but that's bigger than my screen.

;;; Scenario 3
;; 1. From Scenario 1.
;; 2. Resize with the mouse both width and height, to have 1 less.
;; 3. Eval the set-frame-attribute form. Nothing happens, the frame size 
stays the same.
;; Step 2 still doesn't change the return values of frame-text-cols/lines.

Attaching the contents of foo for all scenarios.

These are very much non-critical, of course.