diff options
| author | Robert Pluim | 2020-09-11 10:29:24 +0200 |
|---|---|---|
| committer | Robert Pluim | 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.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) | |||
| 2810 | || ! NILP (Vface_ignored_fonts))) | 2810 | || ! NILP (Vface_ignored_fonts))) |
| 2811 | val = font_delete_unmatched (val, need_filtering ? spec : Qnil, size); | 2811 | val = font_delete_unmatched (val, need_filtering ? spec : Qnil, size); |
| 2812 | if (ASIZE (val) > 0) | 2812 | if (ASIZE (val) > 0) |
| 2813 | list = Fcons (val, list); | 2813 | { |
| 2814 | list = Fcons (val, list); | ||
| 2815 | /* Querying further backends can be very slow, so we only do | ||
| 2816 | it if the user has explicitly requested it (Bug#43177). */ | ||
| 2817 | if (query_all_font_backends == false) | ||
| 2818 | break; | ||
| 2819 | } | ||
| 2814 | } | 2820 | } |
| 2815 | 2821 | ||
| 2816 | list = Fnreverse (list); | 2822 | list = Fnreverse (list); |
| @@ -5527,6 +5533,13 @@ Non-nil means don't query fontconfig for color fonts, since they often | |||
| 5527 | cause Xft crashes. Only has an effect in Xft builds. */); | 5533 | cause Xft crashes. Only has an effect in Xft builds. */); |
| 5528 | xft_ignore_color_fonts = true; | 5534 | xft_ignore_color_fonts = true; |
| 5529 | 5535 | ||
| 5536 | DEFVAR_BOOL ("query-all-font-backends", query_all_font_backends, | ||
| 5537 | doc: /* | ||
| 5538 | If non-nil attempt to query all available font backends. | ||
| 5539 | By default Emacs will stop searching for a matching font at the first | ||
| 5540 | match. */); | ||
| 5541 | query_all_font_backends = false; | ||
| 5542 | |||
| 5530 | #ifdef HAVE_WINDOW_SYSTEM | 5543 | #ifdef HAVE_WINDOW_SYSTEM |
| 5531 | #ifdef HAVE_FREETYPE | 5544 | #ifdef HAVE_FREETYPE |
| 5532 | syms_of_ftfont (); | 5545 | syms_of_ftfont (); |