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 748782 - fontchooser should reload list of families/styles on theme change
fontchooser should reload list of families/styles on theme change
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: .General
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2015-05-01 22:42 UTC by Behdad Esfahbod
Modified: 2015-05-06 05:27 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
fontchooser: Use gtk-fontconfig-timestamp setting (1.80 KB, patch)
2015-05-04 12:29 UTC, Emmanuele Bassi (:ebassi)
committed Details | Review
settings: Wayland-only systems also use fontconfig (1.10 KB, patch)
2015-05-04 12:29 UTC, Emmanuele Bassi (:ebassi)
committed Details | Review

Description Behdad Esfahbod 2015-05-01 22:42:18 UTC
I fixed this in 2009 in bug 569635, but when font chooser was rewritten in 2011, all that work went away.
Comment 1 Behdad Esfahbod 2015-05-01 22:42:44 UTC
See deprecated/gtkfontsel.c:  gtk_font_selection_reload_fonts() for details.
Comment 2 Behdad Esfahbod 2015-05-01 22:46:24 UTC
In the style_set(), can also check the gtk-fontconfig-timestamp number to avoid reloading fonts if they didn't change.
Comment 3 Behdad Esfahbod 2015-05-01 22:50:48 UTC
I meant style_updated().
Comment 4 Emmanuele Bassi (:ebassi) 2015-05-04 12:15:56 UTC
GtkFontChooserWidget reloads the fonts when the style or screen change — see gtkfontchooserwidget.c:gtk_font_chooser_widget_load_fonts.

As far as I can see, pretty much the same code is used to load the fonts both in the GtkFontSel and GtkFontChooserWidget classes.

(In reply to Behdad Esfahbod from comment #2)
> In the style_set(), can also check the gtk-fontconfig-timestamp number to
> avoid reloading fonts if they didn't change.

That could be useful indeed, especially for large font collections.
Comment 5 Emmanuele Bassi (:ebassi) 2015-05-04 12:29:49 UTC
Created attachment 302856 [details] [review]
fontchooser: Use gtk-fontconfig-timestamp setting

We can use the GtkSettings:gtk-fontconfig-timestamp property to decide
whether or not we should reload fonts on style and screen changes. This
should avoid doing a lot of work with large font collections when only
the theme has changed.
Comment 6 Emmanuele Bassi (:ebassi) 2015-05-04 12:29:55 UTC
Created attachment 302857 [details] [review]
settings: Wayland-only systems also use fontconfig

We're relying on the X11 backend being compiled in, but that may not be
the case.
Comment 7 Matthias Clasen 2015-05-05 01:35:42 UTC
Review of attachment 302856 [details] [review]:

looks good
Comment 8 Matthias Clasen 2015-05-05 01:38:57 UTC
Review of attachment 302857 [details] [review]:

ok
Comment 9 Emmanuele Bassi (:ebassi) 2015-05-05 10:25:09 UTC
Attachment 302856 [details] pushed as c6df175 - fontchooser: Use gtk-fontconfig-timestamp setting
Attachment 302857 [details] pushed as 487332c - settings: Wayland-only systems also use fontconfig
Comment 10 Behdad Esfahbod 2015-05-05 19:24:09 UTC
Ok I tried with gtk+ master and indeed the font dialog updates itself, but fails to repaint.  As soon as I click on the window or otherwise interact with it, it updates.

Test like this:

1. Install a font, say Lobster, by copying lobster.ttf to ~/.fonts/

2. Open gedit, type some text, open font dialog, choose Lobster, close.  Your test should render in Lobster now,

3. Open font dialog, type Lobster, so you see Lobster in the font dialog,

3. In a terminal window, move lobster.ttf out of ~/.fonts/

4. After 4 seconds, you should see the text in gedit window change to render using another font.  But the font dialog still happily lists Lobster (even though the sample there also changes to using another font).

5. Now click on the font dialog, it will update itself to say "No fonts matched your search".
Comment 11 Matthias Clasen 2015-05-06 04:55:36 UTC
I've pushed a change that should fix this problem.
Comment 12 Behdad Esfahbod 2015-05-06 05:23:17 UTC
Thanks Matthias.  It's great that the style system is smart enough to skip redundant paints.  The whole thing definitely feels much faster than when I was adding this feature 7 years ago...
Comment 13 Behdad Esfahbod 2015-05-06 05:27:43 UTC
Confirmed fixed.  Thanks everyone.