After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 54651 - GtkFontSelection needs a filter feature
GtkFontSelection needs a filter feature
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: Other
2.11.x
Other All
: Normal enhancement
: Medium API
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks: 317343 420961
 
 
Reported: 2001-05-14 19:49 UTC by Havoc Pennington
Modified: 2011-09-05 04:17 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
a patch (12.44 KB, patch)
2006-03-27 04:39 UTC, Yevgen Muntyan
none Details | Review

Description Havoc Pennington 2001-05-14 19:49:35 UTC
Should be able to filter which fonts are offered for selection; e.g. a
terminal might offer only monospace fonts.
Comment 1 Havoc Pennington 2001-06-04 22:07:29 UTC
For now terminal apps can just display an error if you choose a font
that won't work well. Plus terminal apps probably want an X font
selector not a Pango font selector anyhow.
Comment 2 Daniel Elstner 2003-01-20 22:43:10 UTC
The gvim GTK+ 2 port needs this feature too, and does use Pango. 
Currently it's just displaying an error message if you choose a
proportional font (using a hack that compares the width of a few
sample glyphs).  But it's really tedious if the font selector shows
say 200 fonts and about 5% of them can actually be used.

I guess this could be implemented by an application by deriving a
wrapper class from PangoFontMap, and applying filtering in the
list_families() vfunc.  Xft/FreeType seems to have API for this (the
spacing property).  But that would require including backend-related
Pango headers, plus at least a fallback implementation for non-Xft
platforms.

I'm willing to implement the filtering feature; at least for the Xft
backend (if noone else does :)  But I'm not sure how much of this
should go into Pango, and which filtering facilities other than
monospace should be provided.
Comment 3 Wouter Bolsterlee (uws) 2006-03-05 16:02:27 UTC
This bug causes problems for both the GNOME fixed width font selection in gnome-font-properties and for the Epiphany font preferences... Daniel, any plans to actually implement this? You will be my official Hero of the Week [tm].
Comment 4 Yevgen Muntyan 2006-03-27 04:39:15 UTC
Created attachment 62089 [details] [review]
a patch

This patch adds "monospace" property t GtkFontSelection and GtkFontButton.
Is it needed to have custom filters? It's not hard to do something like: 

typedef void (*GtkFontFilterFunc) (PangoFontFamily *family, 
                                   gpointer         user_data);
void gtk_font_selection_set_filter_func (GtkFontSelection *fontsel,
                                         GtkFontFilterFunc func, 
                                         gpointer          user_data);

or even add something like GtkFileChooser api for filters.
I personally only need monospace fonts, for a terminal.
Comment 5 Wouter Bolsterlee (uws) 2006-03-27 07:01:24 UTC
Monospace, Serif and Sans-serif seem useful, eg. for web browsers or other html-related rendering applications (help applications, mail clients, ...)
Comment 6 Björn Lindqvist 2006-12-01 18:06:40 UTC
Unfortunately, there is no way for Pango to tell whether a font is serif or not. So that filter can't be made.
Comment 7 Christian Persch 2006-12-02 22:26:58 UTC
We want to filter by font coverage too, so a filter is still required for Epiphany.
Comment 8 Yevgen Muntyan 2007-05-23 16:44:45 UTC
(In reply to comment #7)
> We want to filter by font coverage too, so a filter is still required for
> Epiphany.

This font coverage thing, can it be done in font selector itself or you need a filter function? How about this:

typedef enum {
  GTK_FONT_FILTER_NONE,
  GTK_FONT_FILTER_MONOSPACE
  /* something else? */
} GtkFontFilter;

typedef gboolean (*GtkFontFilterFunc) (PangoFontFamily *family,
                                       gpointer         data);

void gtk_font_selection_set_filter (GtkFontSelection *fs,
                                    GtkFontFilter     type);
void gtk_font_selection_set_filter_func (GtkFontSelection *fs,
                                         GtkFontFilterFunc func,
                                         gpointer          data,
                                         GDestroyNotify    notify);
Comment 9 Wouter Bolsterlee (uws) 2007-05-23 17:26:04 UTC
(In reply to comment #8)
> typedef enum {
>   GTK_FONT_FILTER_NONE,
>   GTK_FONT_FILTER_MONOSPACE
>   /* something else? */
> } GtkFontFilter;

GTK_FONT_FILTER_SERIF and GTK_FONT_FILTER_SANS_SERIF would make an aweful lot of sense as well, especially in a web context, since CSS font-family generic style include "sans-serif", "serif" and "monospace" (please ignore the "fantasy" stuff).
Comment 10 Christian Persch 2007-05-23 19:06:48 UTC
Also filtering by the font's coverage, so you could e.g. just show fonts with full Chinese coverage, fonts with Latin+Cyrillic coverage, etc.


Comment 11 Yevgen Muntyan 2007-05-23 20:17:38 UTC
(In reply to comment #9)
> (In reply to comment #8)
> > typedef enum {
> >   GTK_FONT_FILTER_NONE,
> >   GTK_FONT_FILTER_MONOSPACE
> >   /* something else? */
> > } GtkFontFilter;
> 
> GTK_FONT_FILTER_SERIF and GTK_FONT_FILTER_SANS_SERIF would make an aweful lot
> of sense as well, especially in a web context, since CSS font-family generic
> style include "sans-serif", "serif" and "monospace" (please ignore the
> "fantasy" stuff).

I trusted comment #6 which said it's impossible :)

(In reply to comment #10)
> Also filtering by the font's coverage, so you could e.g. just show fonts with
> full Chinese coverage, fonts with Latin+Cyrillic coverage, etc.

How do you give language to the filter, do you give it a string "Chinese" or some pango stuff or something? Any pointers? I am willing to write the code but have only vague idea about what should be done; and I do want monospace filter!
(I have a copy of GtkFontSelection here with added checkbox for that)
Comment 12 Matthias Clasen 2011-09-05 04:17:41 UTC
I've added filtering to GtkFontChooser