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

From: martin rudalics <[email-masked]>
Date: Sun, 25 Dec 2022 11:21:36 +0100

> adjust_frame_size .. pixel_height .. 1260 .. text_height .. 1260
 > x_new_font .. ascent .. 31 .. descent .. 6 .. line_height .. 37
 > adjust_frame_size .. pixel_height .. 1224 .. text_height .. 1224
 > x_new_font .. ascent .. 31 .. descent .. 6 .. line_height .. 37
 > adjust_frame_size .. pixel_height .. 1188 .. text_height .. 1188
 > x_new_font .. ascent .. 31 .. descent .. 6 .. line_height .. 37

FWIW I can't see anything wrong with the font.  From the earlier

xg_frame_set_char_size, visible, PS=1408x1188, XS=1408x1184
ConfigureNotify, PS=1408x1188, XS=1408x1152
xg_frame_resized, changed, PS=1408x1188, XS=1408x1152

I can only tell that, for example, we want to resize the frame from
1408x1188 to 1408x1184 pixels but the ensuing ConfigureNotify tells us
that mutter has sized us down to 1408x1152 pixels (that's the -36
increment you see every time) and we comply.  I have no idea why that
should happen - after all 1184 is (* 37 32) so it's rather the earlier
1188 that's wrong here.  But we've also set the base height to 84 and a
height increment of 18 which are both suspicious.

Anyway: I attach a new patch to shed more light on this.  Three
'set-face-attribute' iterations suffice, post me the contents of *foo*
please.

Thanks, martin

diff --git a/lisp/window.el b/lisp/window.el
index a11293d372..3d064e12d7 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -10596,6 +10596,17 @@ window-prefix-map
   "0" #'delete-windows-on)
 (define-key ctl-x-map "w" window-prefix-map)
 
+(defun foo-it (&rest rest)
+  (with-current-buffer (get-buffer-create "*foo*")
+    (goto-char (point-max))
+    (when rest
+      (insert (format "%s" (car rest)))
+      (setq rest (cdr rest))
+      (while rest
+	(insert (format " .. %s" (car rest)))
+	(setq rest (cdr rest)))
+      (insert "\n"))))
+
 (provide 'window)
 
 ;;; window.el ends here
diff --git a/src/frame.c b/src/frame.c
index b57b296be5..eae0b6127b 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -718,6 +718,18 @@ adjust_frame_size (struct frame *f, int new_text_width, int new_text_height,
   new_text_height = FRAME_PIXEL_TO_TEXT_HEIGHT (f, new_native_height);
   new_text_lines = new_text_height / unit_height;
 
+  call7 (Qfoo_it, intern ("adjust_frame_size_1"),
+	 intern ("new_text_height"), make_fixnum (new_text_height),
+	 intern ("old_native_height"), make_fixnum (old_native_height),
+	 intern ("text_to_pixel"),
+	 make_fixnum (FRAME_TEXT_TO_PIXEL_HEIGHT (f, new_text_height)));
+
+  call8 (Qfoo_it,
+	 intern ("   top_margin"), make_fixnum (FRAME_TOP_MARGIN_HEIGHT (f)),
+	 intern ("scroll_bar"), make_fixnum (FRAME_SCROLL_BAR_AREA_HEIGHT (f)),
+	 intern ("2*border"), make_fixnum (2 * FRAME_INTERNAL_BORDER_WIDTH (f)),
+	 intern ("   min_inner_height"), make_fixnum (min_inner_height));
+
   if (FRAME_WINDOW_P (f)
       && f->can_set_window_size
       /* For inhibit == 1 call the window_size_hook only if a native
@@ -906,6 +918,10 @@ adjust_frame_size (struct frame *f, int new_text_width, int new_text_height,
 
   unblock_input ();
 
+  call5 (Qfoo_it, intern ("adjust_frame_size_2"),
+	 intern ("pixel_height"), make_fixnum (FRAME_PIXEL_HEIGHT (f)),
+	 intern ("text_height"), make_fixnum (FRAME_TEXT_HEIGHT (f)));
+
 #ifdef HAVE_WINDOW_SYSTEM
   {
     /* Adjust size of F's child frames.  */
diff --git a/src/gtkutil.c b/src/gtkutil.c
index a6bba096a4..3a6d14b3a9 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -2028,6 +2028,11 @@ xg_wm_set_size_hint (struct frame *f, long int flags, bool user_position)
 		 &f->output_data.xp->size_hints,
 		 sizeof (size_hints)) != 0)
     {
+      call8 (Qfoo_it, intern ("xg_wm_set_size_hint"),
+	     intern ("line_height & scale"),
+	     make_fixnum (FRAME_LINE_HEIGHT (f)), make_fixnum (scale),
+	     intern ("base_height"), make_fixnum (size_hints.base_height),
+	     intern ("height_inc"), make_fixnum (size_hints.height_inc));
       block_input ();
       gtk_window_set_geometry_hints (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
                                      NULL, &size_hints, hint_flags);
diff --git a/src/window.c b/src/window.c
index f116b9a9d7..c090f29461 100644
--- a/src/window.c
+++ b/src/window.c
@@ -8394,6 +8394,7 @@ syms_of_window (void)
   DEFSYM (Qheader_line_format, "header-line-format");
   DEFSYM (Qtab_line_format, "tab-line-format");
   DEFSYM (Qno_other_window, "no-other-window");
+  DEFSYM (Qfoo_it, "foo-it");
 
   DEFVAR_LISP ("temp-buffer-show-function", Vtemp_buffer_show_function,
 	       doc: /* Non-nil means call as function to display a help buffer.
diff --git a/src/xterm.c b/src/xterm.c
index 7eaf59d54b..a701bae9af 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -26175,6 +26175,11 @@ x_new_font (struct frame *f, Lisp_Object font_object, int fontset)
   get_font_ascent_descent (font, &font_ascent, &font_descent);
   FRAME_LINE_HEIGHT (f) = font_ascent + font_descent;
 
+  call7 (Qfoo_it, intern ("x_new_font"),
+	 intern ("ascent"), make_fixnum (font_ascent),
+	 intern ("descent"), make_fixnum (font_descent),
+	 intern ("line_height"), make_fixnum (FRAME_LINE_HEIGHT (f)));
+
 #ifndef USE_X_TOOLKIT
   FRAME_MENU_BAR_HEIGHT (f) = FRAME_MENU_BAR_LINES (f) * FRAME_LINE_HEIGHT (f);
 #endif