tools: post-process SVG objects with "color-important" label.

This will allow a designer to simply "tag" an object so that its color
does not get overrided by GTK+ without needing to edit the file as text.
This commit is contained in:
Jehan 2018-06-23 20:20:24 +02:00
parent 5e25cdc713
commit 8a36b786bc
1 changed files with 5 additions and 1 deletions

View File

@ -47,7 +47,7 @@ fi
# Extract the icon code.
#icon=`xmllint "$source" --xpath '//*[local-name()="g" and @id="'$id'"]'`
icon=`xmllint "$source" --xpath '//*[@id="'$id'"]'`
icon=`xmllint "$source" --xpath '//*[@id="'$id'"]' --noblanks`
# Get rid of any transform on the top node to help librsvg.
#icon=`echo $icon | sed 's/^\(<[^>]*\) transform="[^"]*"/\1/'`
if [ $? -ne 0 ]; then
@ -55,6 +55,10 @@ if [ $? -ne 0 ]; then
exit 1;
fi;
# Add !important to any object with label "color-important".
icon=`echo $icon | sed 's/<\([^<>]*\)style="\([^"]*\)fill:\([^;"]*\)\([^"]*\)"\([^<>]*\)inkscape:label="color-important"\([^>]*\)>/<\1style="\2fill:\3 !important\4"\5\6>/'`
icon=`echo $icon | sed 's/<\([^<>]*\)inkscape:label="color-important"\([^>]*\)style="\([^"]*\)fill:\([^;"]*\)\([^"]*\)"\([^<>]*\)>/<\1\2style="\3fill:\4 !important\5"\6>/'`
# The typical namespaces declared at start of a SVG made with Inkscape.
# Since we are not sure of what namespace will use the object XML, and
# since we don't want to end up with invalid XML, we just keep them all