diff options
author | Robert Pluim <rpluim@gmail.com> | 2019-11-13 15:19:04 +0100 |
---|---|---|
committer | Robert Pluim <rpluim@gmail.com> | 2019-11-14 10:23:37 +0100 |
commit | ca44f33be2e2c91dad4037c730408b2b1d4529dd (patch) | |
tree | 4debce43ee5ff4b755a9cb84b75a855460edc17b /src/font.c | |
parent | 4f45e89852129db6a3026187768c6ba5b30c39fe (diff) | |
download | emacs-ca44f33be2e2c91dad4037c730408b2b1d4529dd.tar.gz emacs-ca44f33be2e2c91dad4037c730408b2b1d4529dd.tar.bz2 emacs-ca44f33be2e2c91dad4037c730408b2b1d4529dd.zip |
Make GTK font chooser respect face-ignored-fonts
* src/font.c (font_delete_unmatched): Move Vface_ignored_fonts
matching to...
(font_is_ignored): ..Here. New function.
* src/gtkutil.c (xg_font_filter): New function, uses font_is_ignored
to filter fonts.
(xg_get_font): Set GTK font chooser filter to xg_font_filter.
* src/gtkutil.h: Add prototype for font_is_ignored.
Diffstat (limited to 'src/font.c')
-rw-r--r-- | src/font.c | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/src/font.c b/src/font.c index 8dfbfa0fac6..7c8e9e30c9d 100644 --- a/src/font.c +++ b/src/font.c @@ -2655,6 +2655,26 @@ font_clear_cache (struct frame *f, Lisp_Object cache, } +/* Check whether NAME should be ignored based on Vface_ignored_fonts. + This is reused by xg_font_filter to apply the same checks to the + GTK font chooser. */ + +bool +font_is_ignored (const char *name, ptrdiff_t namelen) +{ + Lisp_Object tail = Vface_ignored_fonts; + Lisp_Object regexp; + + FOR_EACH_TAIL_SAFE (tail) + { + regexp = XCAR (tail); + if (STRINGP (regexp) + && fast_c_string_match_ignore_case (regexp, name, + namelen) >= 0) + return true; + } + return false; +} static Lisp_Object scratch_font_spec, scratch_font_prefer; /* Check each font-entity in VEC, and return a list of font-entities @@ -2677,22 +2697,10 @@ font_delete_unmatched (Lisp_Object vec, Lisp_Object spec, int size) { char name[256]; ptrdiff_t namelen; - Lisp_Object tail, regexp; - namelen = font_unparse_xlfd (entity, 0, name, 256); if (namelen >= 0) - { - for (tail = Vface_ignored_fonts; CONSP (tail); tail = XCDR (tail)) - { - regexp = XCAR (tail); - if (STRINGP (regexp) - && fast_c_string_match_ignore_case (regexp, name, - namelen) >= 0) - break; - } - if (CONSP (tail)) - continue; - } + if (font_is_ignored (name, namelen)) + continue; } if (NILP (spec)) { |