]> de.git.xonotic.org Git - xonotic/mediasource.git/blob - gfx/luma/render-version.sh
Merge branch 'sev/luma' into 'master'
[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)
13 #   convert (imagemagick)
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: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] DATADIR VERSION"
38         exit 1
39 fi
40
41
42 data="$1"
43 version="$2"
44 svgs="gfx/menu/luma/background_l2.svg
45       gfx/menu/luma/background_ingame_l2.svg"
46
47
48 for svg in $svgs; do
49         dir="$data/${svg%/*}"
50         tga="$data/${svg%.*}.tga"
51
52         mkdir -p "$dir"
53         sed "s/LUMA/$version/g" "$svg" | rsvg-convert -z 2 | convert - -scale "50%" "$tga"
54 done