diff options
| author | Robert Pluim | 2019-11-13 15:19:04 +0100 |
|---|---|---|
| committer | Robert Pluim | 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.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, | |||
| 2655 | } | 2655 | } |
| 2656 | 2656 | ||
| 2657 | 2657 | ||
| 2658 | /* Check whether NAME should be ignored based on Vface_ignored_fonts. | ||
| 2659 | This is reused by xg_font_filter to apply the same checks to the | ||
| 2660 | GTK font chooser. */ | ||
| 2661 | |||
| 2662 | bool | ||
| 2663 | font_is_ignored (const char *name, ptrdiff_t namelen) | ||
| 2664 | { | ||
| 2665 | Lisp_Object tail = Vface_ignored_fonts; | ||
| 2666 | Lisp_Object regexp; | ||
| 2667 | |||
| 2668 | FOR_EACH_TAIL_SAFE (tail) | ||
| 2669 | { | ||
| 2670 | regexp = XCAR (tail); | ||
| 2671 | if (STRINGP (regexp) | ||
| 2672 | && fast_c_string_match_ignore_case (regexp, name, | ||
| 2673 | namelen) >= 0) | ||
| 2674 | return true; | ||
| 2675 | } | ||
| 2676 | return false; | ||
| 2677 | } | ||
| 2658 | static Lisp_Object scratch_font_spec, scratch_font_prefer; | 2678 | static Lisp_Object scratch_font_spec, scratch_font_prefer; |
| 2659 | 2679 | ||
| 2660 | /* Check each font-entity in VEC, and return a list of font-entities | 2680 | /* 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) | |||
| 2677 | { | 2697 | { |
| 2678 | char name[256]; | 2698 | char name[256]; |
| 2679 | ptrdiff_t namelen; | 2699 | ptrdiff_t namelen; |
| 2680 | Lisp_Object tail, regexp; | ||
| 2681 | |||
| 2682 | namelen = font_unparse_xlfd (entity, 0, name, 256); | 2700 | namelen = font_unparse_xlfd (entity, 0, name, 256); |
| 2683 | if (namelen >= 0) | 2701 | if (namelen >= 0) |
| 2684 | { | 2702 | if (font_is_ignored (name, namelen)) |
| 2685 | for (tail = Vface_ignored_fonts; CONSP (tail); tail = XCDR (tail)) | 2703 | continue; |
| 2686 | { | ||
| 2687 | regexp = XCAR (tail); | ||
| 2688 | if (STRINGP (regexp) | ||
| 2689 | && fast_c_string_match_ignore_case (regexp, name, | ||
| 2690 | namelen) >= 0) | ||
| 2691 | break; | ||
| 2692 | } | ||
| 2693 | if (CONSP (tail)) | ||
| 2694 | continue; | ||
| 2695 | } | ||
| 2696 | } | 2704 | } |
| 2697 | if (NILP (spec)) | 2705 | if (NILP (spec)) |
| 2698 | { | 2706 | { |