summaryrefslogtreecommitdiff
path: root/graphics/update
blob: 46964470ba039c7f11852143ba6ab6b6c731920d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/bin/bash -e
#
# Update generated stuff in graphics/ from the source files.
#
# It would be nice to do this with waf but:
# a) getting the wscript right is a complete pain in the arse
# b) running Inkscape from the command line on OS X is a complete pain in the arse

set -e

pwd=`pwd`
if [ `basename $pwd` != "graphics" ]; then
    echo "$0: run within graphics/"
    exit 1
fi

function required_font()
{
    set +e
    check=$(fc-list | grep "$1")
    set -e
    if [ "$check" == "" ]; then
        echo "Missing font $1"
        exit 1
    fi
}

svg_apps="dcpomatic2_kdm dcpomatic2_server dcpomatic2_batch dcpomatic2_player dcpomatic2_playlist dcpomatic2_disk dcpomatic2_combiner dcpomatic2_editor"


if [ `uname -s` == "Darwin" ]; then
    # Convert OS X icons using OS X-only iconutil
    for p in dcpomatic2 $svg_apps; do
	iconutil --convert icns --output osx/$p.icns osx/$p.iconset
    done
else
    required_font "Libre Baskerville"

    INKSCAPE="$HOME/Applications/inkscape"
    for c in icotool convert inkbatch $INKSCAPE; do
        if [ ! -x "$(command -v $c)" ]; then
            echo "$c is required"
            exit 1
        fi
    done

    INKSCAPE_EXPORT="$INKSCAPE -C --export-type=png"

    # OS X application icons
    mkdir -p osx
    for r in 16 32 128 256 512; do
	for p in dcpomatic2; do
	    mkdir -p osx/$p.iconset
	    convert src/dcpomatic.png -resize $rx$r osx/$p.iconset/icon_${r}x${r}.png
	    convert src/dcpomatic.png -resize $rx$r osx/$p.iconset/icon_${r}x${r}@2x.png
	done
	for p in $svg_apps; do
	    mkdir -p osx/$p.iconset
	    $INKSCAPE_EXPORT --export-filename=osx/$p.iconset/icon_${r}x${r}.png -w $r -h $r src/$p.svg
	    $INKSCAPE_EXPORT --export-filename=osx/$p.iconset/icon_${r}x${r}@2x.png -w $r -h $r src/$p.svg
	done
    done

    # Linux application icons
    mkdir -p linux
    for r in 16 22 32 48 64 128 256 512; do
	mkdir -p linux/$r
	convert src/dcpomatic.png -resize $rx$r linux/$r/dcpomatic2.png
	for p in $svg_apps; do
	    $INKSCAPE_EXPORT --export-filename=linux/$r/$p.png src/$p.svg -w $r -h $r
	done
    done

    # Windows application icons
    mkdir -p windows
    for p in dcpomatic2 $svg_apps; do
	icotool -c -o windows/$p.ico linux/16/$p.png linux/32/$p.png linux/48/$p.png linux/64/$p.png linux/128/$p.png
    done
    convert src/dcpomatic.png -resize 400x400 windows/dcpomatic.bmp

    # OS X preferences icons
    mkdir -p osx/preferences
    for c in black white; do
	for i in defaults email kdm_email cover_sheet keys tms notifications locations sound identifiers servers general advanced non_standard; do
	    inkbatch --inkscape $INKSCAPE -i bounds-$i -o osx/preferences/${i}_${c}.png --width 32 --height 32 src/preferences_$c.svg
	    inkbatch --inkscape $INKSCAPE -i bounds-$i -o osx/preferences/${i}@2x_${c}.png --width 64 --height 64 src/preferences_$c.svg
	done
    done

    # OS X menu bar icon for the server (in dark and light mode)
    $INKSCAPE_EXPORT --export-filename=osx/dcpomatic_small_white.png -w 64 -h 64 src/dcpomatic_small_white.svg
    $INKSCAPE_EXPORT --export-filename=osx/dcpomatic_small_black.png -w 64 -h 64 src/dcpomatic_small_black.svg

    # Splash screen (all platforms)
    $INKSCAPE_EXPORT --export-filename=splash.png src/splash.svg -w 400 -h 300

    # Timeline toolbar icons (all platforms)
    for c in black white; do
        for i in select zoom zoom_all snap sequence; do
            inkbatch --inkscape $INKSCAPE -i timeline-$i -o ${i}_${c}.png --width 32 --height 32 src/timeline_$c.svg
        done
    done

    # Batch converter toolbar icons (all platforms)
    for c in black white; do
        for i in add pause; do
            inkbatch --inkscape $INKSCAPE -i batch-$i -o ${i}_${c}.png --width 32 --height 32 src/batch_$c.svg
        done
    done

    # Link icon
    for c in black white; do
        $INKSCAPE_EXPORT --export-filename=link_$c.png src/link_$c.svg -w 9 -h 16
    done

    # favicon
    mkdir -p web
    convert src/web.png -resize 256x256 -transparent white web/favicon-256x256.png
    for r in 16 32 64 128; do
	convert web/favicon-256x256.png -resize $rx$r web/favicon-${r}x${r}.png
    done
    convert web/favicon-16x16.png web/favicon-32x32.png web/favicon-64x64.png web/favicon-128x128.png web/favicon-256x256.png web/favicon.ico
    convert src/web.png -resize 123x123 -transparent white web/logo.png
fi