emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 20d13e4 1/2: Stop querying for fonts as soon as a match is found


From: Robert Pluim
Subject: master 20d13e4 1/2: Stop querying for fonts as soon as a match is found
Date: Tue, 15 Sep 2020 11:40:28 -0400 (EDT)

branch: master
commit 20d13e424fb2e7dcc5e6ea1848bca4376d22bab1
Author: Robert Pluim <rpluim@gmail.com>
Commit: Robert Pluim <rpluim@gmail.com>

    Stop querying for fonts as soon as a match is found
    
    Scanning through fonts can be very slow, especially with the 'x' font
    backend, and the result is almost always not used.  Stop looking for a
    font as soon as one is found rather than scanning all the backends.
    
    * src/font.c (font_list_entities): Stop scanning through the font
    backends as soon as we find a match unless
    'query-all-font-backends is set (Bug#43177).
    (syms_of_font): New variable 'query-all-font-backends', default
    false.
---
 src/font.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/font.c b/src/font.c
index 2786a77..779b852 100644
--- a/src/font.c
+++ b/src/font.c
@@ -2810,7 +2810,13 @@ font_list_entities (struct frame *f, Lisp_Object spec)
                || ! NILP (Vface_ignored_fonts)))
          val = font_delete_unmatched (val, need_filtering ? spec : Qnil, size);
        if (ASIZE (val) > 0)
-         list = Fcons (val, list);
+          {
+            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;
+          }
       }
 
   list = Fnreverse (list);
@@ -5527,6 +5533,13 @@ Non-nil means don't query fontconfig for color fonts, 
since they often
 cause Xft crashes.  Only has an effect in Xft builds.  */);
   xft_ignore_color_fonts = true;
 
+  DEFVAR_BOOL ("query-all-font-backends", query_all_font_backends,
+               doc: /*
+If non-nil attempt to query all available font backends.
+By default Emacs will stop searching for a matching font at the first
+match.  */);
+  query_all_font_backends = false;
+
 #ifdef HAVE_WINDOW_SYSTEM
 #ifdef HAVE_FREETYPE
   syms_of_ftfont ();



reply via email to

[Prev in Thread] Current Thread [Next in Thread]