I have been working for a while on GTK support for stateful, animated, symbolic icons. This post is meant to provide an introduction to the format, and encourage experimentation with it. The code will land very soon in GTK 4.21.
Features
At its core, an icon is a an array of paths, which get stroked or filled to render the icon. We allow symbolic as well as fixed colors.
An icon can provide a number of states, and each path can be present in a subset of states.
Thus changing the state an icon can cause paths to appear and disappear. We allow animating
these transitions in various ways (blur, fade, animate).
It is also possible to animate a path continuously in a given state, in various ways.
Examples for transitions and animations can be seen here.
The provided transition and animation styles are very much up for discussion and extension.
The format has some other features and parameters that are best explored while playing
with examples.
Tools
While working on this, Iâve written an icon editor. Currently, it lives as a demo in the GTK repository, but it might end up as a standalone tool eventually.
The application will be available as org.gtk.Shaper in the gnome-nightly flatpak remote very soon.
Documentation
The documentation for the format can be found here, and the documentation for the new paintable implementation can be found here.
Answers to some questions
- Why use an SVG-based format, instead of something more compact and binary, such as OpenType fonts ?
Experience (e.g. the âsymbolic pngâ format) has shown that our designers are unwilling to use formats other than SVG. Inkscape is the tool of choice, and anything that is not interoperable with that tool is going to fail.
- Why not just use SVG ? It does animation, doesnât it ?
SVG animation is different in style from what we are interested in here (dynamic strokes and state transitions). We donât have a SVG library that handles animation. And even if we did, it would require tight integration with our CSS machinery, which it is not set up for.
- Why use a handrolled parser instead of librsvg ?
For these icons to fully integrate with the GTK renderer, we need the SVG scene graph to be translated into render nodes. At this time, librsvg only offers a cairo-based API for delivering its results, which canât do that.
- Why is this not an XDG standard ?
It is much too early to think about setting this format in stone. At this point, it needs adoption and experimentation, to see what works, what doesnât, and what is missing.
