Fix part of T63102: wrong Python API Reference link in Help menu.
[blender.git] / release / datafiles / blender_icons_update.py
1 #!/usr/bin/env python3
2
3 # This script updates icons from the SVG file
4 import os
5 import subprocess
6 import sys
7
8 def run(cmd):
9     print("   ", " ".join(cmd))
10     subprocess.check_call(cmd)
11
12 BASEDIR = os.path.abspath(os.path.dirname(__file__))
13
14 inkscape_bin = os.environ.get("INKSCAPE_BIN", "inkscape")
15 blender_bin = os.environ.get("BLENDER_BIN", "blender")
16
17 if sys.platform == 'darwin':
18     inkscape_app_path = '/Applications/Inkscape.app/Contents/Resources/script'
19     if os.path.exists(inkscape_app_path):
20         inkscape_bin = inkscape_app_path
21     blender_app_path = '/Applications/blender.app/Contents/MacOS/blender'
22     if os.path.exists(blender_app_path):
23         blender_bin = blender_app_path
24
25 cmd = (
26     inkscape_bin,
27     os.path.join(BASEDIR, "blender_icons.svg"),
28     "--export-width=602",
29     "--export-height=640",
30     "--without-gui",
31     "--export-png=" + os.path.join(BASEDIR, "blender_icons16.png"),
32 )
33 run(cmd)
34
35 cmd = (
36     inkscape_bin,
37     os.path.join(BASEDIR, "blender_icons.svg"),
38     "--export-width=1204",
39     "--export-height=1280",
40     "--without-gui",
41     "--export-png=" + os.path.join(BASEDIR, "blender_icons32.png"),
42 )
43 run(cmd)
44
45
46 # For testing it can be good to clear all old
47 # rm ./blender_icons16/*.dat
48 # rm ./blender_icons32/*.dat
49
50 datatoc_icon_split_py = os.path.join(BASEDIR, "..", "..", "source", "blender", "datatoc", "datatoc_icon_split.py")
51
52 # create .dat pixmaps (which are stored in git)
53 cmd = (
54     blender_bin, "--background", "--factory-startup", "-noaudio",
55     "--python", datatoc_icon_split_py, "--",
56     "--image=" + os.path.join(BASEDIR, "blender_icons16.png"),
57     "--output=" + os.path.join(BASEDIR, "blender_icons16"),
58     "--output_prefix=icon16_",
59     "--name_style=UI_ICONS",
60     "--parts_x", "26", "--parts_y", "30",
61     "--minx", "3", "--maxx", "53", "--miny", "3", "--maxy", "8",
62     "--minx_icon", "2", "--maxx_icon", "2", "--miny_icon", "2", "--maxy_icon", "2",
63     "--spacex_icon", "1", "--spacey_icon", "1",
64 )
65 run(cmd)
66
67 cmd = (
68     blender_bin, "--background", "--factory-startup", "-noaudio",
69     "--python", datatoc_icon_split_py, "--",
70     "--image=" + os.path.join(BASEDIR, "blender_icons32.png"),
71     "--output=" + os.path.join(BASEDIR, "blender_icons32"),
72     "--output_prefix=icon32_",
73     "--name_style=UI_ICONS",
74     "--parts_x", "26", "--parts_y", "30",
75     "--minx", "6", "--maxx", "106", "--miny", "6", "--maxy", "16",
76     "--minx_icon", "4", "--maxx_icon", "4", "--miny_icon", "4", "--maxy_icon", "4",
77     "--spacex_icon", "2", "--spacey_icon", "2",
78 )
79 run(cmd)
80
81 os.remove(os.path.join(BASEDIR, "blender_icons16.png"))
82 os.remove(os.path.join(BASEDIR, "blender_icons32.png"))
83
84 # For testing, if we want the PNG of each image
85 # ./datatoc_icon_split_to_png.py ./blender_icons16/*.dat
86 # ./datatoc_icon_split_to_png.py ./blender_icons32/*.dat