]> de.git.xonotic.org Git - xonotic/mediasource.git/blob - gfx/luma/render-version.sh
6709481b625c270777683f0ad5e29121e369aeb0
[xonotic/mediasource.git] / gfx / luma / render-version.sh
1 #!/bin/sh -e
2 # TASK
3 #   Render menu background layers with VERSION string
4 #
5 # NOTES
6 #   It is necessary to have the Xolonium font installed on the system,
7 #   because svg rendering tools cannot handle embedded or linked fonts.
8 #   To compensate for filter rendering errors and to reduce rbg noise,
9 #   the svg files are rendered at a large size and then scaled down.
10 #
11 # DEPENDENCIES
12 #   rsvg-convert (librsvg 2.39.0)
13 #   convert (imagemagick 6.8.6-9)
14 #   Xolonium-Regular font
15 #
16 # USAGE
17 #   ./render-version.sh [--no-font-check] DATADIR VERSION
18 #
19 # USAGE EXAMPLE
20 #   ./render-version.sh ~/.xonotic/data "1.0"
21
22
23 # Check for Xolonium font
24 if [ "$1" = "--no-font-check" ]; then
25         shift
26 else
27         if [ -z "$(fc-list ':family=Xolonium GPL:style=Regular')" ]; then
28                 echo "Cannot find the Xolonium-Regular font."
29                 echo "Please install Xolonium before running this script."
30                 exit 2
31         fi
32 fi
33
34
35 # Check for arguments
36 if [ -z "$1" ] || [ -z "$2" ]; then
37         echo "Usage: $0 [--no-font-check] INPUTDIR OUTPUTDIR VERSION"
38         exit 1
39 fi
40
41
42 input="$1"
43 output="$2"
44 version="$3"
45 svgs="gfx/menu/luma/background_l2.svg
46       gfx/menu/luma/background_ingame_l2.svg"
47
48
49 for svg in $svgs; do
50         dir="$output/${svg%/*}"
51         tga="$output/${svg%.*}.tga"
52
53         mkdir -p "$output"
54         # -auto-orient works around an inversion regression present in imagemagick 6.9.11-60
55         sed "s/LUMA/$version/g" "$input/$svg" | rsvg-convert -z 2 | convert - -auto-orient -scale "50%" "$tga"
56 done