diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-05-17 15:46:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-17 15:46:44 +0200 |
commit | 107651806f1b922f672ec1b87766b765202cbbd7 (patch) | |
tree | 290d095954459480ddaf84401163b80483cd49da /scene/resources/default_theme/default_theme_builders.py | |
parent | 9cc17a8439d4909324da014a1d2e90cfaa9fb979 (diff) | |
parent | d211c05111eed90baa7e70cb4e818fd328e97770 (diff) |
Merge pull request #39603 from Calinou/default-theme-use-dynamicfont
Diffstat (limited to 'scene/resources/default_theme/default_theme_builders.py')
-rw-r--r-- | scene/resources/default_theme/default_theme_builders.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/scene/resources/default_theme/default_theme_builders.py b/scene/resources/default_theme/default_theme_builders.py new file mode 100644 index 0000000000..0455d6d246 --- /dev/null +++ b/scene/resources/default_theme/default_theme_builders.py @@ -0,0 +1,40 @@ +"""Functions used to generate source files during build time + +All such functions are invoked in a subprocess on Windows to prevent build flakiness. + +""" +import os +import os.path +from platform_methods import subprocess_main + + +def make_fonts_header(target, source, env): + dst = target[0] + + g = open(dst, "w", encoding="utf-8") + + g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") + g.write("#ifndef _DEFAULT_FONTS_H\n") + g.write("#define _DEFAULT_FONTS_H\n") + + # Saving uncompressed, since FreeType will reference from memory pointer. + for i in range(len(source)): + with open(source[i], "rb") as f: + buf = f.read() + + name = os.path.splitext(os.path.basename(source[i]))[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") + + g.close() + + +if __name__ == "__main__": + subprocess_main(globals()) |