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

From: martin rudalics <[email-masked]>
Date: Mon, 26 Dec 2022 10:10:21 +0100

> Aaand, here you go:

So far I'm pretty sure that we have some rounding problem here - maybe
due to scaling.  The last version of my patch is attached, please use
that for further experiments.

Now first do what you have done so far (three iterations) and post the
results.

Next, if possible, try to turn scaling off, do the same experiments and
post the results.

Finally, with scaling turned on again, start Emacs with

--eval "(setq frame-resize-pixelwise t)"

do the same experiments and post the results.

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..4501c8dc14 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -906,6 +906,14 @@ adjust_frame_size (struct frame *f, int new_text_width, int new_text_height,
 
   unblock_input ();
 
+  if (old_native_height != new_native_height
+      || old_text_lines != new_text_lines)
+    call7 (Qfoo_it, intern ("adjust_frame_size"),
+	   intern ("old pixels/lines"), make_fixnum (old_native_height),
+	   make_fixnum (old_text_lines),
+	   intern ("new pixels/lines"), make_fixnum (new_native_height),
+	   make_fixnum (new_text_lines));
+
 #ifdef HAVE_WINDOW_SYSTEM
   {
     /* Adjust size of F's child frames.  */
diff --git a/src/gtkutil.c b/src/gtkutil.c
index a6bba096a4..c201669a49 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -1149,6 +1149,13 @@ xg_frame_resized (struct frame *f, int width, int height)
 	   f->new_size_p ? f->new_height : -1);
 
       FRAME_RIF (f)->clear_under_internal_border (f);
+
+      call8 (Qfoo_it, intern ("xg_frame_resized"),
+	     intern ("old"), make_fixnum (FRAME_PIXEL_HEIGHT (f)),
+	     intern ("req"), make_fixnum (f->new_height),
+	     intern ("con/text"), make_fixnum (height),
+	     make_fixnum (FRAME_PIXEL_TO_TEXT_HEIGHT (f, height)));
+
       change_frame_size (f, width, height, false, true, false);
       SET_FRAME_GARBAGED (f);
       cancel_mouse_face (f);
@@ -1317,6 +1324,14 @@ xg_frame_set_char_size (struct frame *f, int width, int height)
   SET_FRAME_GARBAGED (f);
   cancel_mouse_face (f);
 
+  call7 (Qfoo_it, intern ("xg_frame_set_char_size"),
+	 intern ("old"), make_fixnum (FRAME_PIXEL_HEIGHT (f)),
+	 intern ("arg"), make_fixnum (height),
+	 intern ("new"), make_fixnum (f->new_height));
+  call4 (Qfoo_it,
+	 intern ("  outer"), make_fixnum (outer_height),
+	 intern ("gheight"), make_fixnum (gheight));
+
   /* We can not call change_frame_size for a mapped frame,
      we can not set pixel width/height either.  The window manager may
      override our resize request, XMonad does this all the time.
@@ -2028,6 +2043,13 @@ 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));
+      call4 (Qfoo_it, intern ("  menubar_height"), make_fixnum (FRAME_MENUBAR_HEIGHT (f)),
+	     intern ("toolbar_height"), make_fixnum (FRAME_TOOLBAR_HEIGHT (f)));
       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..277b53043a 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -26197,9 +26197,17 @@ x_new_font (struct frame *f, Lisp_Object font_object, int fontset)
      because it's done in Fx_show_tip, and it leads to problems because
      the tip frame has no widget.  */
   if (FRAME_X_WINDOW (f) != 0 && !FRAME_TOOLTIP_P (f))
-    adjust_frame_size
-      (f, FRAME_COLS (f) * FRAME_COLUMN_WIDTH (f),
-       FRAME_LINES (f) * FRAME_LINE_HEIGHT (f), 3, false, Qfont);
+    {
+      call7 (Qfoo_it, intern ("x_new_font"),
+	     intern ("line_height"), make_fixnum (FRAME_LINE_HEIGHT (f)),
+	     intern ("lines"), make_fixnum (FRAME_LINES (f)),
+	     intern ("new_text_height"),
+	     make_fixnum (FRAME_LINES (f) * FRAME_LINE_HEIGHT (f)));
+
+      adjust_frame_size
+	(f, FRAME_COLS (f) * FRAME_COLUMN_WIDTH (f),
+	 FRAME_LINES (f) * FRAME_LINE_HEIGHT (f), 3, false, Qfont);
+    }
 
 #ifdef HAVE_X_I18N
   if (FRAME_XIC (f)