Subject: bug#46827: Broken initial size of GTK3 frame

From: martin rudalics <[email-masked]>
Date: Mon, 1 Mar 2021 09:31:20 +0100

Re-sending this since it apparently got lost by the bug tracker:

 > Reverting 58430f29968a5661caff630d20dbbe7c864fe08d with current master
 > does _not_ fix the bug, so something else must be at play here too.

It turns out that the "something else" is just that

              /* Querying further backends can be very slow, so we only do
                 it if the user has explicitly requested it (Bug#43177).  */
              if (query_all_font_backends == false)
                break;

The attached patch reverting 58430f29968a5661caff630d20dbbe7c864fe08d
and removing the entity above fixes the bug on master.

martin

diff --git a/src/font.c b/src/font.c
index a59ebe216b..1bb1eb29a5 100644
--- a/src/font.c
+++ b/src/font.c
@@ -2797,34 +2797,24 @@ font_list_entities (struct frame *f, Lisp_Object spec)
 	  val = XCDR (val);
 	else
 	  {
-	    Lisp_Object copy;
-
 	    val = (driver_list->driver->list) (f, scratch_font_spec);
-	    /* We put zero_vector in the font-cache to indicate that
-	       no fonts matching SPEC were found on the system.
-	       Failure to have this indication in the font cache can
-	       cause severe performance degradation in some rare
-	       cases, see bug#21028.  */
-	    if (NILP (val))
-	      val = zero_vector;
-	    else
-	      val = Fvconcat (1, &val);
-	    copy = copy_font_spec (scratch_font_spec);
-	    ASET (copy, FONT_TYPE_INDEX, driver_list->driver->type);
-	    XSETCDR (cache, Fcons (Fcons (copy, val), XCDR (cache)));
+	    if (!NILP (val))
+	      {
+		Lisp_Object copy = copy_font_spec (scratch_font_spec);
+
+		val = Fvconcat (1, &val);
+		ASET (copy, FONT_TYPE_INDEX, driver_list->driver->type);
+		XSETCDR (cache, Fcons (Fcons (copy, val), XCDR (cache)));
+	      }
 	  }
-	if (ASIZE (val) > 0
+
+	if (VECTORP (val) && ASIZE (val) > 0
 	    && (need_filtering
 		|| ! NILP (Vface_ignored_fonts)))
 	  val = font_delete_unmatched (val, need_filtering ? spec : Qnil, size);
-	if (ASIZE (val) > 0)
-          {
-            list = Fcons (val, list);
-            /* Querying further backends can be very slow, so we only do
-               it if the user has explicitly requested it (Bug#43177).  */
-            if (query_all_font_backends == false)
-              break;
-          }
+
+	if (VECTORP (val) && ASIZE (val) > 0)
+	  list = Fcons (val, list);
       }

   list = Fnreverse (list);