141 lines
3.9 KiB
Bash
Executable File
141 lines
3.9 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
## makesymbolpack.sh
|
|
## Version 1.0
|
|
## https://git.zaks.web.za/thisiszeev/makesymbolpacks
|
|
## Ze'ev Schurmann
|
|
##
|
|
## Licensed under GPL3.0 or later
|
|
##
|
|
## This script is to convert a Font Awesome Sprite SVG into an Inkscape Symbol Pack SVG
|
|
##
|
|
## This script is my own work and is a labour of love. I love Font Awesome, I wanted to
|
|
## have easy access to the icons from inside Inkscape. So here you go.
|
|
##
|
|
## More detailed information on how to use this script, and how to add the Symbol Packs
|
|
## to Inkscape can be found on the project Git repo. The link is above.
|
|
##
|
|
## DISCLAIMER: Font Awesome by no ways endorses or sponsors my work. My efforts are my
|
|
## own. I did get their blessing to post the completed Symbol packs on this
|
|
## repo to make it even easier for you to enjoy Font Awesome with Inkscape.
|
|
|
|
if [[ -z $1 ]]; then
|
|
echo "Usage:"
|
|
echo
|
|
echo " $ ./makesymbolpack.sh {name-of-sprite-file} \"{title-of-symbol-pack}\""
|
|
echo
|
|
echo "makesymbolpack.sh"
|
|
echo "Version 1.0"
|
|
echo "https://git.zaks.web.za/thisiszeev/makesymbolpacks"
|
|
echo "Ze'ev Schurmann"
|
|
echo
|
|
echo "Licensed under GPL3.0 or later"
|
|
echo
|
|
echo "This script is to convert a Font Awesome Sprite SVG into an Inkscape Symbol Pack SVG"
|
|
echo
|
|
echo "This script is my own work and is a labour of love. I love Font Awesome, I wanted to"
|
|
echo "have easy access to the icons from inside Inkscape. So here you go."
|
|
echo
|
|
echo "More detailed information on how to use this script, and how to add the Symbol Packs"
|
|
echo "to Inkscape can be found on the project Git repo. The link is above."
|
|
echo
|
|
echo "DISCLAIMER: Font Awesome by no ways endorses or sponsors my work. My efforts are my"
|
|
echo " own. I did get their blessing to post the completed Symbol packs on this"
|
|
echo " repo to make it even easier for you to enjoy Font Awesome with Inkscape."
|
|
exit 1
|
|
|
|
fi
|
|
|
|
inputfile="$1"
|
|
title="$2"
|
|
outputfile=$(echo "$title" | awk '{print tolower($0)}' | tr ' ' '-').svg
|
|
OLDIFS=$IFS
|
|
mode="1"
|
|
|
|
if [[ ! -f $inputfile ]]; then
|
|
|
|
echo "$inputfile not found."
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if [[ -f $outputfile ]]; then
|
|
|
|
echo "$outputfile already exists. Press ENTER to overwrite it or CTRL+C to stop..."
|
|
read -r entry
|
|
rm -f $outputfile
|
|
touch $outputfile
|
|
|
|
fi
|
|
|
|
while read -r line; do
|
|
|
|
linearray=($line)
|
|
|
|
if [[ $mode == "1" ]]; then
|
|
|
|
if [[ ${linearray[0]} == "<svg" ]]; then
|
|
|
|
echo "<svg xmlns=\"http://www.w3.org/2000/svg\" style=\"fill:black;stroke:none\">" >> $outputfile
|
|
echo " <title>$title</title>" >> $outputfile
|
|
echo " <defs>" >> $outputfile
|
|
((mode++))
|
|
|
|
else
|
|
|
|
echo "$line" >> $outputfile
|
|
|
|
fi
|
|
|
|
elif [[ $mode == "2" ]]; then
|
|
|
|
if [[ ${linearray[0]} == "<symbol" ]]; then
|
|
|
|
IFS='"'
|
|
idarray=(${linearray[1]})
|
|
IFS='-'
|
|
wordarray=(${idarray[1]})
|
|
IFS=$OLDIFS
|
|
title=$(echo "${wordarray[@]}" | sed -e 's/\b\(.\)/\u\1/g')
|
|
echo " $line" >> $outputfile
|
|
echo " <title>$title</title>" >> $outputfile
|
|
echo "$title"
|
|
|
|
elif [[ ${linearray[0]} == "</symbol>" ]]; then
|
|
|
|
echo " $line" >> $outputfile
|
|
|
|
elif [[ ${linearray[0]} == "</svg>" ]]; then
|
|
|
|
echo " </defs>" >> $outputfile
|
|
echo "</svg>" >> $outputfile
|
|
((mode++))
|
|
|
|
else
|
|
|
|
echo " $line" >> $outputfile
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done < $inputfile
|
|
|
|
echo
|
|
echo "Thank you for using my script. I hope you find it as useful as I do. That's why I made it."
|
|
echo
|
|
echo "You can find more of my scripts at https://git.zaks.web.za/thisiszeev"
|
|
echo
|
|
echo "If you found this script useful, or you would like to support my work, please consider making"
|
|
echo "a small donation at https://paypal.me/thisiszeev"
|
|
echo
|
|
echo "\$5 buys me a cup of coffee"
|
|
echo "\$10 buys me a nice burger"
|
|
echo "\$20 buys me a bottle of wine"
|
|
echo "Anything above that will be awesome as well"
|
|
echo
|
|
echo "If you do make a donation, please drop me a message on Reddit u/thisiszeev"
|
|
echo
|
|
echo "Support is freely given to those who donate."
|
|
echo
|