diff options
author | Robert Pluim <rpluim@gmail.com> | 2020-09-11 10:29:24 +0200 |
---|---|---|
committer | Robert Pluim <rpluim@gmail.com> | 2020-09-15 17:39:24 +0200 |
commit | 20d13e424fb2e7dcc5e6ea1848bca4376d22bab1 (patch) | |
tree | b34403ca88e4c0a2d2f073073a5075c0fa06744b /src/font.c | |
parent | 0a7152e095e51febedf3da794eacb3a6b538e64e (diff) | |
download | emacs-20d13e424fb2e7dcc5e6ea1848bca4376d22bab1.tar.gz emacs-20d13e424fb2e7dcc5e6ea1848bca4376d22bab1.tar.bz2 emacs-20d13e424fb2e7dcc5e6ea1848bca4376d22bab1.zip |
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.
Diffstat (limited to 'src/font.c')
-rw-r--r-- | src/font.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/font.c b/src/font.c index 2786a772dc3..779b8520962 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 (); |