Application Icon PNG Vs. SVG... Fight!

I have an application. It ships with it’s own icons, which are installed to the ‘hicolor’ theme. All works great.

Lets say I want to allow users to apply a custom icon for this. They can make an alternative icon and put it in the appropriate location (eg ~/.local/share/icons/hicolor) and it will override the icons installed to the system (eg in /usr/share/icons/hicolor).

But, it seems like, so long as there is a PNG icon present in any of the 48x48 directories, the system chooses it. (Not certain about other resolutions) (edit: confirmed for 256x256 also)

This is kinda a shame, since KDE has nice features that revolve around using the SVG format (like symbolic icons that follow user colour schemes), and also, it’s much easier for a user to replace a single scalable file, than to need to statically generate a set of various different-sized PNG icons.

Also, it’s kinda confusing when no amount of custom icons overriding the stock ones, will be recognised, if this one icon is left without being overridden.

I’ve read pseudocode on freedesktop’s site that suggest that SVG should be preferred over PNG (obviously the pseudocode isn’t quite accurate) and I’ve seen posts suggesting that static PNGs are preferred for performance reasons, but also read the opposite… I’ve read a lot of docs and they either don’t mention this or don’t provide a clear answer.

Edit:
For an example from the official spec:

For example, installing a svg icon in $prefix/share/icons/hicolor/scalable/apps means most desktops will have one icon that works for all sizes.

but

This favours PNG first

for extension in ("png", "svg", "xpm") { 

and

As soon as there is an icon of any size that matches in a theme, the search is stopped.

It also favours scaled icons last. And requires the 48x48 PNG:

Minimally you should install a 48x48 icon in the hicolor theme.

So I don’t see how to prefer the SVG like it says.

What’s the right way to deal with this? Is it an option (or, is it wise) to only ship SVG icons with the app? Is that portable to other modern DE? Is there a way to get the system to prefer the SVG icon? You get the idea. Any advice would be greatly appreciated!

1 Like

Little bump, could really use a hand here.

TL;DR How do we install SVG and PNG icons, and prefer SVG?

Bonus question: Do we even need PNG icons?

Doesn’t it get override by .svg in ~/.local/share/icons? That’s my experience as icon maker. But I guess you’re talking about, if the user want to replace only a single icon and not write a little .theme file to it.

Most apps now a days comes only with a .svg icon, but I can see that older apps still has the legacy of .png.

1 Like

Thanks so much for helping, Storm.

Sadly, and surprisingly, no :frowning:

If there is a PNG icon of any size in /usr/share/icons/hicolor/*/apps/ or in ~/.local/share/icons/hicolor/*/apps/, all SVGs in those directories are ignored. (the * is either the icon dimensions or “scalable” for SVGs)

In order to have the system use an svg, I have to delete any pngs, and restart plasma.

The interesting part of this is that it means that KDE is not ever using SVG icons for any apps which have PNG icons too - which seems to be a LOT of apps. It feels like a bug, but the XDG spec is ambiguously worded so I am uncertain.

Thanks mate that’s good to have some confirmation. I checked a few icons and it seemed that quite a few apps did only have an svg icon, but I was scared to try that, in case it breaks in some other DE.

It was not long ago I filed a report on Dolphin not supporting the latest .svg standard (or KDE for that matter) and it was sorted within a couple of releases, but that might point to the issue of that KDE in the past has been more .png oriented to back in the days when .svg was uncommon - which leads to there might be leftovers from that time. I’m guessing there’s a comma or something that needs to be moved in a config file to sort this problem.

That’s the thing though, it doesn’t seem to be a bug, if we refer to the XDG icon spec (quoted above)

But if that’s accurate, then no (compliant) linux DE, including KDE, is actually using any of our SVG icons, unless there are no PNG icons available… and that seems most improbable… But it matches the behaviour I’m observing. And it’s kinda subtle, visually, so… maybe?

All that makes me wonder if I’m just doing it wrong, hence this thread.

I filed one anyway, I’m at a loss.

Any advice on this front would be warmly welcomed :slight_smile:

1 Like