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



commit 8a36b786bcc15f450b50ee1fcf24ac1d72549901
Author: Jehan <jehan girinstud io>
Date:   Sat Jun 23 20:20:24 2018 +0200

    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.

 tools/extract-vector-icon.sh | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
---
diff --git a/tools/extract-vector-icon.sh b/tools/extract-vector-icon.sh
index 94a6ce77d4..6bb9a3415e 100755
--- a/tools/extract-vector-icon.sh
+++ b/tools/extract-vector-icon.sh
@@ -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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]