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 730450 - Support non-svg symbolic icons
Support non-svg symbolic icons
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Class: GtkStyleContext
3.13.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2014-05-20 14:20 UTC by Alexander Larsson
Modified: 2014-08-03 00:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Add gtk-encode-symbolic-svg (10.64 KB, patch)
2014-05-20 14:20 UTC, Alexander Larsson
none Details | Review
icon-theme: Support recolorable .symbolic.png files (13.15 KB, patch)
2014-05-20 14:20 UTC, Alexander Larsson
none Details | Review
Example converted png (507 bytes, image/png)
2014-05-20 14:31 UTC, Alexander Larsson
  Details
Add gtk-encode-symbolic-svg (10.76 KB, patch)
2014-07-31 15:12 UTC, Alexander Larsson
none Details | Review
icon-theme: Support recolorable .symbolic.png files (11.67 KB, patch)
2014-07-31 15:12 UTC, Alexander Larsson
none Details | Review
Support pre-rendered symbolic pngs (1.76 KB, patch)
2014-07-31 15:15 UTC, Alexander Larsson
committed Details | Review
Add gtk-encode-symbolic-svg (10.77 KB, patch)
2014-08-01 07:23 UTC, Alexander Larsson
committed Details | Review
icon-theme: Support recolorable .symbolic.png files (11.67 KB, patch)
2014-08-01 07:24 UTC, Alexander Larsson
committed Details | Review

Description Alexander Larsson 2014-05-20 14:20:07 UTC
It would be nice to have a version of symbolic icons that don't use svg, so that we don't have a core dependency on librsvg which is less that fantastically maintained (and pretty slow).
Comment 1 Alexander Larsson 2014-05-20 14:20:37 UTC
Created attachment 276868 [details] [review]
Add gtk-encode-symbolic-svg

This utility loads a symbolic svg at a specified size and
renders a png file in a special format that can be recolored
later.
Comment 2 Alexander Larsson 2014-05-20 14:20:47 UTC
Created attachment 276869 [details] [review]
icon-theme: Support recolorable .symbolic.png files

If an icon theme has a file called "foo-symbolic.symbolic.png" which
was converted from svg using gtk-encode-symbolic-svg we will read
it in an recolor, allowing symbolic icons without using librsvg.
Comment 3 Alexander Larsson 2014-05-20 14:31:54 UTC
Created attachment 276870 [details]
Example converted png
Comment 4 Benjamin Otte (Company) 2014-05-20 19:55:52 UTC
So it's essentially a bitmap with a 4 color colormap where each of the colors has 256 shades? That means no other colors may be present in the image?

I don't mind a solution like this, but I'm not a huge fan of it. As far as I can see it doesn't solve a real problem. And it invents a whole new file format for it.
Comment 5 Alexander Larsson 2014-05-21 07:38:37 UTC
Well, somewhat like that. Each pixel has a 8bit alpha, and is a mix of 4 possible colors with the mix proportions being 256 shades.

This is enough to encode all existing gnome symbolic icons, which means we could ship a symbolic icon theme that doesn't depend on librsvg (and which probably will be a lot faster at loading such icons). So, it does in fact solve a real problem, although I agree that its a pretty limited problem. We could create a more generic solution that allows any N colors + hardcoded colors, but that would require a completely custom file format, rather than just reinterpreting an existing one like png.

Or, one could i guess add extra colors by just making the image larger.
I.e. for a 48x48 icon it could be made 48x96, with the upper copy having hardcoded colors and the lower one the recolorable parts. That will make such icons even more weird when they leak into non-supporting apps though.
Comment 6 Matthias Clasen 2014-05-21 11:45:40 UTC
if you want to go into gdk-pixbuf, you could actually use the png spec and add a separate chunk - then the icons could work like normal pngs in unsuspecting software.
Comment 7 Alexander Larsson 2014-05-21 12:10:58 UTC
Thats another level of custom image format though... You may need to modify libpng to parse it correctly, at least if the extra chunk is complex like compression and other details used for the normal pixels.
Comment 8 Alexander Larsson 2014-05-21 12:13:33 UTC
One option may be to use tiff. That supports layer, but unfortunately it also supports about a gazillion other features...
Comment 9 Benjamin Otte (Company) 2014-05-21 12:15:16 UTC
From my point of view SVG is a hard dependency of GTK anyway. Because there's still gonna be scalable icons in the theme...

And I don't loading times of SVGs was ever an issue either. Even back when all Adwaita assets were still SVGs and they were all loaded on startup, nobody complained.

So I think as long as we get the caching layer in the icontheme right, there shouldn't be any issues...
Comment 10 Alexander Larsson 2014-05-21 13:06:47 UTC
Benjamin: The main problem is that librsvg and libcroco are basically unmaintained, and that relying on svg in themes to work basically makes them a hard dependency of gtk+. This is not an ideal situation.
Comment 11 Jasper St. Pierre (not reading bugmail) 2014-06-17 18:45:44 UTC
(In reply to comment #4)
> So it's essentially a bitmap with a 4 color colormap where each of the colors
> has 256 shades? That means no other colors may be present in the image?

This is how symbolics have always worked. Four colors: fg, warning, error, success.

PNG files also allow for multiple IHDR chunks, so we could have four A8 planes, and add more when we want additional colors. I think relying on RGBA channel data for now is probably fine, though.
Comment 12 Alexander Larsson 2014-06-17 19:04:24 UTC
Jasper: That is not *quite* true. symbolic svgs *can* use absolute colors, but yeah, thats generally how it works in practice.
Comment 13 Jasper St. Pierre (not reading bugmail) 2014-06-17 19:08:18 UTC
I'd say that any symbolic icon SVG that has an absolute color is violating the spirit of symbolics, even if not the letter :)
Comment 14 Alexander Larsson 2014-07-31 15:12:37 UTC
Created attachment 282152 [details] [review]
Add gtk-encode-symbolic-svg

This utility loads a symbolic svg at a specified size and
renders a png file in a special format that can be recolored
later.
Comment 15 Alexander Larsson 2014-07-31 15:12:45 UTC
Created attachment 282153 [details] [review]
icon-theme: Support recolorable .symbolic.png files

If an icon theme has a file called "foo-symbolic.symbolic.png" which
was converted from svg using gtk-encode-symbolic-svg we will read
it in an recolor, allowing symbolic icons without using librsvg.
Comment 16 Alexander Larsson 2014-07-31 15:15:55 UTC
Created attachment 282154 [details] [review]
Support pre-rendered symbolic pngs

This uses the new gtk-encode-symbolic-svg feature of Gtk to pre-render
svgs as recolorable pngs. The pngs are loaded faster and can be
used without librsvg which avoids librsvg as the required dependencies
for Gtk+.
Comment 17 Alexander Larsson 2014-08-01 07:23:22 UTC
Created attachment 282236 [details] [review]
Add gtk-encode-symbolic-svg

This utility loads a symbolic svg at a specified size and
renders a png file in a special format that can be recolored
later.
Comment 18 Alexander Larsson 2014-08-01 07:24:39 UTC
Created attachment 282237 [details] [review]
icon-theme: Support recolorable .symbolic.png files

If an icon theme has a file called "foo-symbolic.symbolic.png" which
was converted from svg using gtk-encode-symbolic-svg we will read
it in an recolor, allowing symbolic icons without using librsvg.
Comment 19 Matthias Clasen 2014-08-03 00:45:50 UTC
Attachment 282236 [details] pushed as 50ba3c7 - Add gtk-encode-symbolic-svg
Attachment 282237 [details] pushed as 1d68801 - icon-theme: Support recolorable .symbolic.png files
Comment 20 Matthias Clasen 2014-08-03 00:46:59 UTC
Attachment 282154 [details] pushed as 05492d1 - Support pre-rendered symbolic pngs