Update tools

* _clean_attrs and _clean_style_attr delete more default values
* convert.sh now creates directories that needed
This commit is contained in:
Sergei Eremenko 2017-08-15 14:40:52 +03:00
parent e531a56f7a
commit 86a45e66ce
4 changed files with 159 additions and 82 deletions

View file

@ -15,6 +15,11 @@
# values from elements.
# Details https://www.w3.org/TR/SVG/attindex.html
#
# Get defaults from Inkscape:
# sed -e '/^$/d' -e '/NO.DEFAULT/d' -e 's/"//g' \
# /usr/share/inkscape/attributes/css_defaults \
# | awk -F" - " '{printf "s/[ ]%s=\"%s\"//gI\n", $1,$2}'
#
# Usage:
# sed -r -i -f _clean_attrs.sed FILE...
@ -37,12 +42,13 @@ s/[ ]id="svg[0-9][^ ]*"//gI
# remove attributes with default values
s/[ ]alignment-baseline="auto"//gI
s/[ ]backface-visibility="visible"//gI
s/[ ]baseline-shift="baseline"//gI
s/[ ]clip="auto"//gI
s/[ ]clip-path="none"//gI
s/[ ]clip-rule="nonzero"//gI
s/[ ]clip="auto"//gI
s/[ ]color-interpolation-filters="linearRGB"//gI
s/[ ]color-interpolation="sRGB"//gI
s/[ ]color-interpolation-filters="linearRGB"//gI
s/[ ]color-profile="auto"//gI
s/[ ]color-rendering="auto"//gI
s/[ ]cursor="auto"//gI
@ -50,42 +56,80 @@ s/[ ]direction="ltr"//gI
s/[ ]display="inline"//gI
s/[ ]dominant-baseline="auto"//gI
s/[ ]enable-background="accumulate"//gI
s/[ ]fill-opacity="[1-9][0-9.]*"//gI
s/[ ]fill="black"//gI
s/[ ]fill-opacity="1"//gI
s/[ ]fill-rule="nonzero"//gI
s/[ ]fill="(#000|#000000|black)"//gI
s/[ ]filter="none"//gI
s/[ ]flood-color="(#000|#000000|black)"//gI
s/[ ]flood-opacity="[1-9][0-9.]*"//gI
s/[ ]font-size-adjust="none"//gI
s/[ ]flood-color="black"//gI
s/[ ]flood-opacity="1"//gI
s/[ ]font-feature-settings="normal"//gI
s/[ ]font-size="medium"//gI
s/[ ]font-size-adjust="none"//gI
s/[ ]font-stretch="normal"//gI
s/[ ]font-style="normal"//gI
s/[ ]font-variant="normal"//gI
s/[ ]font-variant-alternates="normal"//gI
s/[ ]font-variant-caps="normal"//gI
s/[ ]font-variant-east-asian="normal"//gI
s/[ ]font-variant-ligatures="normal"//gI
s/[ ]font-variant-numeric="normal"//gI
s/[ ]font-variant-position="normal"//gI
s/[ ]font-weight="normal"//gI
s/[ ]glyph-orientation-horizontal="0deg"//gI
s/[ ]glyph-orientation-vertical="auto"//gI
s/[ ]image-rendering="auto"//gI
s/[ ]isolation="auto"//gI
s/[ ]kerning="auto"//gI
s/[ ]letter-spacing="normal"//gI
s/[ ]lighting-color="white"//gI
s/[ ]marker="none"//gI
s/[ ]marker-end="none"//gI
s/[ ]marker-mid="none"//gI
s/[ ]marker-start="none"//gI
s/[ ]mask="none"//gI
s/[ ]opacity="[1-9][0-9.]*"//gI
s/[ ]mix-blend-mode="normal"//gI
s/[ ]opacity="1"//gI
s/[ ]overflow="hidden"//gI
s/[ ]paint-order="normal"//gI
s/[ ]perspective="none"//gI
s/[ ]pointer-events="visiblePainted"//gI
s/[ ]shape-inside="auto"//gI
s/[ ]shape-margin="0"//gI
s/[ ]shape-outside="auto"//gI
s/[ ]shape-padding="none"//gI
s/[ ]shape-rendering="auto"//gI
s/[ ]solid-color="#000000"//gI
s/[ ]solid-opacity="1"//gI
s/[ ]stop-color="black"//gI
s/[ ]stop-opacity="1"//gI
s/[ ]stroke="none"//gI
s/[ ]stroke-dasharray="none"//gI
s/[ ]stroke-dashoffset="0"//gI
s/[ ]stroke-linecap="butt"//gI
s/[ ]stroke-linejoin="miter"//gI
s/[ ]stroke-miterlimit="4"//gI
s/[ ]stroke-opacity="[1-9][0-9.]*"//gI
s/[ ]stroke-opacity="1"//gI
s/[ ]stroke-width="1"//gI
s/[ ]stroke="none"//gI
s/[ ]text-align="start"//gI
s/[ ]text-anchor="start"//gI
s/[ ]text-decoration="none"//gI
s/[ ]text-decoration-line="none"//gI
s/[ ]text-decoration-style="solid"//gI
s/[ ]text-indent="0"//gI
s/[ ]text-orientation="mixed"//gI
s/[ ]text-rendering="auto"//gI
s/[ ]text-transform="none"//gI
s/[ ]transform="none"//gI
s/[ ]transform-style="flat"//gI
s/[ ]unicode-bidi="normal"//gI
s/[ ]visibility="visible"//gI
s/[ ]white-space="normal"//gI
s/[ ]word-spacing="normal"//gI
s/[ ]writing-mode="lr-tb"//gI
# delete attributes with nonsense values
s/[ ]fill-opacity="[1-9][0-9.]*"//gI
s/[ ]fill="(#000|#000000|black)"//gI
s/[ ]flood-color="(#000|#000000|black)"//gI
s/[ ]flood-opacity="[1-9][0-9.]*"//gI
s/[ ]opacity="[1-9][0-9.]*"//gI
s/[ ]stroke-opacity="[1-9][0-9.]*"//gI

View file

@ -15,6 +15,11 @@
# values from style attributes.
# Details https://www.w3.org/TR/SVG/styling.html
#
# Get CSS defaults from Inkscape:
# sed -e '/^$/d' -e '/NO.DEFAULT/d' -e 's/"//g' \
# /usr/share/inkscape/attributes/css_defaults \
# | awk -F" - " '{printf "s/%s:%s;//gI\n", $1,$2}'
#
# Usage:
# sed -r -i -f _clean_style_attr.sed FILE...
@ -23,79 +28,106 @@
# add a trailing semicolon for secure matching
s/style="([^"]+[^;])"/style="\1;"/gI
# remove properties with default values
s/font-family:(sans|sans-serif);//gI
s/font-style:normal;//gI
s/font-variant:normal;//gI
s/font-weight:normal;//gI
s/font-stretch:normal;//gI
s/font-size:medium;//gI
s/font-size-adjust:none;//gI
s/font-variant-alternates:normal;//gI
s/font-variant-position:normal;//gI
s/font-feature-settings:normal;//gI
s/font-variant-ligatures:normal;//gI
s/font-variant-caps:normal;//gI
s/font-variant-numeric:normal;//gI
s/kerning:auto;//gI
s/line-height:normal;//gI
s/text-indent:0;//gI
s/text-align:start;//gI
s/text-decoration:none;//gI
s/text-decoration-line:none;//gI
s/text-decoration-style:solid;//gI
s/text-decoration-color:(#000|#000000|black|currentColor);//gI
s/letter-spacing:normal;//gI
s/word-spacing:normal;//gI
s/text-transform:none;//gI
s/block-progression:tb;//gI
s/writing-mode:lr-tb;//gI
s/glyph-orientation-vertical:auto;//gI
s/glyph-orientation-horizontal:0deg;//gI
s/direction:ltr;//gI
s/unicode-bidi:normal;//gI
s/text-anchor:start;//gI
s/dominant-baseline:auto;//gI
# delete properties with default values
s/alignment-baseline:auto;//gI
s/backface-visibility:visible;//gI
s/baseline-shift:baseline;//gI
s/white-space:normal;//gI
s/block-progression:tb;//gI
s/clip:auto;//gI
s/clip-path:none;//gI
s/clip-rule:nonzero;//gI
s/mask:none;//gI
s/display:inline;//gI
s/overflow:visible;//gI
s/visibility:visible;//gI
s/isolation:auto;//gI
s/mix-blend-mode:normal;//gI
s/color-interpolation:sRGB;//gI
s/color-interpolation-filters:linearRGB;//gI
s/solid-color:(#000|#000000|black);//gI
s/solid-opacity:[1-9][0-9.]*;//gI
s/color-profile:auto;//gI
s/color-rendering:auto;//gI
s/cursor:auto;//gI
s/direction:ltr;//gI
s/display:inline;//gI
s/dominant-baseline:auto;//gI
s/enable-background:accumulate;//gI
s/fill:black;//gI
s/fill-opacity:1;//gI
s/fill-rule:nonzero;//gI
s/fill-opacity:[1-9][0-9.]*;//gI
s/([^-])opacity:[1-9][0-9.]*;/\1/gI
s/filter:none;//gI
s/flood-color:black;//gI
s/flood-opacity:1;//gI
s/font-feature-settings:normal;//gI
s/font-size:medium;//gI
s/font-size-adjust:none;//gI
s/font-stretch:normal;//gI
s/font-style:normal;//gI
s/font-variant:normal;//gI
s/font-variant-alternates:normal;//gI
s/font-variant-caps:normal;//gI
s/font-variant-east-asian:normal;//gI
s/font-variant-ligatures:normal;//gI
s/font-variant-numeric:normal;//gI
s/font-variant-position:normal;//gI
s/font-weight:normal;//gI
s/glyph-orientation-horizontal:0deg;//gI
s/glyph-orientation-vertical:auto;//gI
s/image-rendering:auto;//gI
s/isolation:auto;//gI
s/kerning:auto;//gI
s/letter-spacing:normal;//gI
s/lighting-color:white;//gI
s/marker:none;//gI
s/marker-end:none;//gI
s/marker-mid:none;//gI
s/marker-start:none;//gI
s/mask:none;//gI
s/mix-blend-mode:normal;//gI
s/([^-])opacity:1;/\1/gI
s/overflow:hidden;//gI
s/paint-order:normal;//gI
s/perspective:none;//gI
s/pointer-events:visiblePainted;//gI
s/shape-inside:auto;//gI
s/shape-margin:0;//gI
s/shape-outside:auto;//gI
s/shape-padding:none;//gI
s/shape-rendering:auto;//gI
s/solid-color:#000000;//gI
s/solid-opacity:1;//gI
s/stop-color:black;//gI
s/stop-opacity:1;//gI
s/stroke:none;//gI
s/stroke-width:1;//gI
s/stroke-dasharray:none;//gI
s/stroke-dashoffset:0;//gI
s/stroke-linecap:butt;//gI
s/stroke-linejoin:miter;//gI
s/stroke-miterlimit:4;//gI
s/stroke-dasharray:none;//gI
s/stroke-dashoffset:0;//gI
s/stroke-opacity:[1-9][0-9.]*;//gI
s/vector-effect:none;//gI
s/marker:none;//gI
s/marker-start:none;//gI
s/marker-mid:none;//gI
s/marker-end:none;//gI
s/paint-order:normal;//gI
s/color-rendering:auto;//gI
s/shape-rendering:auto;//gI
s/shape-padding:0;//gI
s/shape-margin:0;//gI
s/stroke-opacity:1;//gI
s/stroke-width:1;//gI
s/text-align:start;//gI
s/text-anchor:start;//gI
s/text-decoration-line:none;//gI
s/text-decoration-style:solid;//gI
s/text-decoration:none;//gI
s/text-indent:0;//gI
s/text-orientation:mixed;//gI
s/text-rendering:auto;//gI
s/image-rendering:auto;//gI
s/enable-background:accumulate;//gI
s/text-transform:none;//gI
s/transform:none;//gI
s/transform-style:flat;//gI
s/unicode-bidi:normal;//gI
s/vector-effect:none;//gI
s/visibility:visible;//gI
s/white-space:normal;//gI
s/word-spacing:normal;//gI
s/writing-mode:lr-tb;//gI
# delete properties with nonsense values
s/fill-opacity:[1-9][0-9.]*;//gI
s/font-family:(sans|sans-serif);//gI
s/line-height:normal;//gI
s/([^-])opacity:[1-9][0-9.]*;/\1/gI
s/overflow:visible;//gI
s/shape-padding:0;//gI
s/solid-color:(#000|#000000|black);//gI
s/solid-opacity:[1-9][0-9.]*;//gI
s/stroke-opacity:[1-9][0-9.]*;//gI
s/text-decoration-color:(#000|#000000|black|currentColor);//gI
# delete Inkscape properties
/-inkscape-/ {
@ -130,17 +162,18 @@
}
# delete unused properties from non-container elements
/<(defs|g|marker|mask|svg|symbol)/! {
/<(a|defs|glyph|g|marker|mask|missing-glyph|pattern|svg|switch|symbol|use)/! {
s/enable-background:[^;"]+;//gI
}
# delete unused properties from non-text content elements
/<(g|altGlyph|textPath|text|tref|tspan)/! {
/<(altGlyph|textPath|text|tref|tspan|flowRoot|flowPara|flowSpan|a|defs|glyph|g|marker|mask|missing-glyph|pattern|svg|switch|symbol|use)/! {
s/alignment-baseline:[^;"]+;//gI
s/baseline-shift:[^;"]+;//gI
s/block-progression:[^;"]+;//gI
s/direction:[^;"]+;//gI
s/dominant-baseline:[^;"]+;//gI
s/font:[^;"]+;//gI
s/font-family:[^;"]+;//gI
s/font-feature-settings:[^;"]+;//gI
s/font-size-adjust:[^;"]+;//gI

View file

@ -95,7 +95,7 @@ for file in "$@"; do
fi
else
case "$file" in
*-symbolic.svg|*-symbolic@symbolic.svg)
*-symbolic.svg|*-symbolic-rtl.svg|*-symbolic@symbolic.svg)
# it's symbolic icon
add_class_symbolic "$file"
;;

View file

@ -22,18 +22,18 @@ find "$SCRIPT_DIR" -maxdepth 1 -type d | while read theme_dir; do
-name '*@16x16.svg' -print0 -o \
-name '*@22x22.svg' -print0 -o \
-name '*@24x24.svg' -print0 | xargs -0 -i \
cp -auv '{}' "$theme_dir/$sub_dir"
cp -auv --parents '{}' "$theme_dir/$sub_dir"
;;
devices|places)
find "$SOURCE_DIR/$sub_dir" \
-name '*@16x16.svg' -print0 | xargs -0 -i \
cp -auv '{}' "$theme_dir/$sub_dir"
cp -auv --parents '{}' "$theme_dir/$sub_dir"
;;
panel)
find "$SOURCE_DIR/$sub_dir" \
-name '*@22x22.svg' -print0 -o \
-name '*@24x24.svg' -print0 | xargs -0 -i \
cp -auv '{}' "$theme_dir/$sub_dir"
cp -auv --parents '{}' "$theme_dir/$sub_dir"
;;
esac
done
@ -55,25 +55,25 @@ find "$SCRIPT_DIR" -maxdepth 1 -type d | while read theme_dir; do
-name '*@22x22.svg' -print0 -o \
-name '*@24x24.svg' -print0 -o \
-name '*@symbolic.svg' -print0 | xargs -0 -i \
cp -auv '{}' "$theme_dir/$sub_dir"
cp -auv --parents '{}' "$theme_dir/$sub_dir"
;;
devices|places)
find "$SOURCE_DIR/$sub_dir" \
-name '*@16x16.svg' -print0 -o \
-name '*@symbolic.svg' -print0 | xargs -0 -i \
cp -auv '{}' "$theme_dir/$sub_dir"
cp -auv --parents '{}' "$theme_dir/$sub_dir"
;;
panel)
find "$SOURCE_DIR/$sub_dir" \
-name '*@22x22.svg' -print0 -o \
-name '*@24x24.svg' -print0 -o \
-name '*@symbolic.svg' -print0 | xargs -0 -i \
cp -auv '{}' "$theme_dir/$sub_dir"
cp -auv --parents '{}' "$theme_dir/$sub_dir"
;;
apps|categories|emblems|emotes|mimetypes|status)
find "$SOURCE_DIR/$sub_dir" \
-name '*@symbolic.svg' -print0 | xargs -0 -i \
cp -auv '{}' "$theme_dir/$sub_dir"
cp -auv --parents '{}' "$theme_dir/$sub_dir"
;;
esac
done
@ -94,7 +94,7 @@ find "$SCRIPT_DIR" -maxdepth 1 -type d | while read theme_dir; do
find "$SOURCE_DIR/$sub_dir" \
-name '*@22x22.svg' -print0 -o \
-name '*@24x24.svg' -print0 | xargs -0 -i \
cp -auv '{}' "$theme_dir/$sub_dir"
cp -auv --parents '{}' "$theme_dir/$sub_dir"
;;
esac
done