UI Scaling: Icons don't support HiDPI themes
References
In this post I am using the breeze icon theme for the examples and pictures. elementary's Danielle Foré did a really great write-up on HiDPI icon themes which explains in more detail how they work and why they're needed and has some icon image examples.
Issue
The new update to fix the blurriness with icons when using UI Scaling (while really awesome and looks much better!) does not honor HiDPI icon themes. This means in certain situations, wrong icons will be shown, and icons will be hard to see at small sizes on high resolution monitors. Most icon themes:
- Provide unique icons at certain sizes for specific reasons (like the Sidebar icons) and
- Usually make larger icons more complex
Here is a demonstration that showing that the sidebar icons change styles when increasing the scaling factor:
Scaling Factor 1:
Scaling Factor 2:
In this example, not only is it using the wrong icons for the sidebar, the icons being used are more complex and it is very difficult to see the unique details at high resolutions. Here is another example from the Detail view using the mime icons: Mimes at Scaling Factor 1 and Mimes at Scaling Factor 2. The icons at scaling factor 1 are easy to make out, at scaling factor 2 they are very difficult to see on a HiDPI display. So aside from it simply being aesthetic, it does affect usability a bit. It's also a big confusing because in Thunar preferences the sidebar is set to 16px but 32px icons are being shown.
Possible Solution
I believe this happens because icons are chosen in Thunar (and I believe Xfce in general since similar updates were made) by manually multiplying the scaling factor by the icon size to then choose the icon (SF2 * 16px = get 32px icon), and I think maybe it could be fixed by using Gtk's icon scale methods.
As noted in Foré's write-up, Gtk supports choosing HiDPI icons when using different scaling factors by looking for folders named @2x
, @3x
, etc. It will choose icons from the HiDPI/scale folders when possible and if not found it will fall back to the basic calculation Thunar/Xfce currently uses. The method I'll use below is gtk_icon_theme_lookup_icon_for_scale, there is also choose_icon_for_scale, load_icon_for_scale, etc.
Using this python script, for scaling factor 1, 2, 3, 4 using lookup_icon_for_scale
I get:
/usr/share/icons/breeze/mimetypes/16/video-x-generic.svg
/usr/share/icons/breeze/mimetypes/16@2x/video-x-generic.svg
/usr/share/icons/breeze/mimetypes/16@3x/video-x-generic.svg
/usr/share/icons/breeze/mimetypes/64/video-x-generic.svg
GtkFileChooser is also a good demonstration of supporting HiDPI icons. When scaling is set to 2x, you can see that the icons Thunar uses at 16px in Details view are different than the icons GtkFileChooser uses (GtkFileChooser uses the 16px style in both scaling factor 1 and 2, whereas Thunar switches to 32px icons at scaling factor 2).