GNOME Bugzilla – Bug 748782
fontchooser should reload list of families/styles on theme change
Last modified: 2015-05-06 05:27:43 UTC
I fixed this in 2009 in bug 569635, but when font chooser was rewritten in 2011, all that work went away.
See deprecated/gtkfontsel.c: gtk_font_selection_reload_fonts() for details.
In the style_set(), can also check the gtk-fontconfig-timestamp number to avoid reloading fonts if they didn't change.
I meant style_updated().
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.
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.
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.
Review of attachment 302856 [details] [review]: looks good
Review of attachment 302857 [details] [review]: ok
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
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".
I've pushed a change that should fix this problem.
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...
Confirmed fixed. Thanks everyone.