summaryrefslogtreecommitdiffstats
path: root/editor/themes/editor_theme_builders.py
blob: ec5653fb095f7342504dd4310b494017f9189efd (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
"""Functions used to generate source files during build time"""

import os


def make_fonts_header(target, source, env):
    dst = str(target[0])

    with open(dst, "w", encoding="utf-8", newline="\n") as g:
        g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
        g.write("#ifndef _EDITOR_FONTS_H\n")
        g.write("#define _EDITOR_FONTS_H\n")

        # Saving uncompressed, since FreeType will reference from memory pointer.
        for i in range(len(source)):
            file = str(source[i])
            with open(file, "rb") as f:
                buf = f.read()

            name = os.path.splitext(os.path.basename(file))[0]

            g.write("static const int _font_" + name + "_size = " + str(len(buf)) + ";\n")
            g.write("static const unsigned char _font_" + name + "[] = {\n")
            for j in range(len(buf)):
                g.write("\t" + str(buf[j]) + ",\n")

            g.write("};\n")

        g.write("#endif")