aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/font.c36
-rw-r--r--src/gtkutil.c18
-rw-r--r--src/gtkutil.h5
3 files changed, 45 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
2662bool
2663font_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}
2658static Lisp_Object scratch_font_spec, scratch_font_prefer; 2678static 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 {
diff --git a/src/gtkutil.c b/src/gtkutil.c
index 16d765533a7..c4d2ef9d80b 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -2228,6 +2228,21 @@ xg_get_file_name (struct frame *f,
2228 2228
2229static char *x_last_font_name; 2229static char *x_last_font_name;
2230 2230
2231#if GTK_CHECK_VERSION (3, 2, 0)
2232static gboolean
2233xg_font_filter (const PangoFontFamily *family,
2234 const PangoFontFace *face,
2235 gpointer data)
2236{
2237 const char *name = pango_font_family_get_name ((PangoFontFamily *)family);
2238 ptrdiff_t namelen = strlen (name);
2239
2240 if (font_is_ignored (name, namelen))
2241 return FALSE;
2242 return TRUE;
2243}
2244#endif
2245
2231/* Pop up a GTK font selector and return the name of the font the user 2246/* Pop up a GTK font selector and return the name of the font the user
2232 selects, as a C string. The returned font name follows GTK's own 2247 selects, as a C string. The returned font name follows GTK's own
2233 format: 2248 format:
@@ -2247,6 +2262,9 @@ xg_get_font (struct frame *f, const char *default_name)
2247 w = gtk_font_chooser_dialog_new 2262 w = gtk_font_chooser_dialog_new
2248 ("Pick a font", GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f))); 2263 ("Pick a font", GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)));
2249 2264
2265#if GTK_CHECK_VERSION (3, 2, 0)
2266 gtk_font_chooser_set_filter_func (GTK_FONT_CHOOSER (w), xg_font_filter, NULL, NULL);
2267#endif
2250 if (default_name) 2268 if (default_name)
2251 { 2269 {
2252 /* Convert fontconfig names to Gtk names, i.e. remove - before 2270 /* Convert fontconfig names to Gtk names, i.e. remove - before
diff --git a/src/gtkutil.h b/src/gtkutil.h
index 229aa08f817..a059f532197 100644
--- a/src/gtkutil.h
+++ b/src/gtkutil.h
@@ -203,5 +203,10 @@ extern void xg_initialize (void);
203extern bool xg_ignore_gtk_scrollbar; 203extern bool xg_ignore_gtk_scrollbar;
204 204
205extern bool xg_gtk_initialized; 205extern bool xg_gtk_initialized;
206
207#if GTK_CHECK_VERSION (3, 2, 0)
208extern bool font_is_ignored (const char *, ptrdiff_t);
209#endif
210
206#endif /* USE_GTK */ 211#endif /* USE_GTK */
207#endif /* GTKUTIL_H */ 212#endif /* GTKUTIL_H */