3 # Render SVGFILEs from path/filename.svg to DATADIR/path/filename.tga,
4 # if they are newer than their target tga file.
7 # To compensate for filter rendering errors and to reduce rbg noise,
8 # the svg files are rendered at a large size and then scaled down.
11 # rsvg-convert (librsvg 2.39.0)
12 # convert (imagemagick 6.8.6-9)
15 # ./render-svg.sh DATADIR [SVGFILE...]
18 # Single file: ./render-svg.sh ~/.xonotic/data gfx/menu/luma/cursor.svg
19 # All files: ./render-svg.sh ~/.xonotic/data $(find . -name "*.svg")
23 if [ -z "$1" ] || [ "${1##*.}" = "svg" ]; then
24 echo "Usage: $0 DATADIR [SVGFILE...]"
37 tga="$data/${svg%.*}.tga"
39 if [ "$ext" = "svg" ] && [ -f "$svg" ] && [ "$svg" -nt "$tga" ]; then
42 w=$(identify -format "%w" "$svg")
43 h=$(identify -format "%h" "$svg")
44 scale=$(echo "s=sqrt($maxPixels/$w/$h);if(s>$maxScale)s=$maxScale;s" | bc)
47 rsvg-convert -z "$scale" "$svg" | convert - -scale "$w" "$tga"