Find blur filters and hidden text in your SVG icons
Our quest to make Eclipse RCP and SWT faster continues. SWT renders SVG icons with JSVG on the UI thread, so everything inside an icon costs time. Two kinds of leftovers turned out to be expensive in the Eclipse platform icons.
Gaussian blur filters.
JSVG computes every feGaussianBlur on each rasterization.
In 63 icons the blur did not change the result visibly, so we removed it.
The first render of these icons in a fresh JVM dropped from 3.0 s to 2.5 s.
Invisible text.
Twelve icons contained a leftover <text> element with the content “Kozuka Mincho Pr6N H”, probably left behind by the drawing tool.
To render it, JSVG enumerates all installed fonts once per JVM, which costs roughly 100 ms.
We removed it as well.
Check your own icons
find-svg-blur-and-text.py scans a folder recursively and lists every blur and text element it finds:
#!/usr/bin/env python3
"""Lists every Gaussian blur and text element in the SVG files below a folder."""
import sys
import xml.etree.ElementTree as ET
from pathlib import Path
root = Path(sys.argv[1] if len(sys.argv) > 1 else ".")
hits = 0
for svg in sorted(root.rglob("*.svg")):
try:
elements = ET.parse(svg).iter()
except ET.ParseError as e:
print(f"{svg}: cannot parse: {e}")
continue
for el in elements:
tag = el.tag.rpartition("}")[2]
if tag == "feGaussianBlur":
print(f"{svg}: blur stdDeviation={el.get('stdDeviation')}")
hits += 1
elif tag == "text":
print(f"{svg}: text '{''.join(el.itertext()).strip()}'")
hits += 1
print(f"{hits} findings", file=sys.stderr)
sys.exit(1 if hits else 0)
Run it on your plug-in or product:
python3 find-svg-blur-and-text.py path/to/your/repo
Text in an icon is almost always a leftover. A blur, on the other hand, can be a real shadow or glow. Before you delete one, render the icon with and without it and compare the result. The script exits with 1 when it finds something, so you can use it as a check in your build.
Need support for your RCP and SWT application? Contact us via: https://vogella.com/contact.html