editor_theme_builders.py 965 B

123456789101112131415161718192021222324252627282930
  1. """Functions used to generate source files during build time"""
  2. import os
  3. def make_fonts_header(target, source, env):
  4. dst = str(target[0])
  5. with open(dst, "w", encoding="utf-8", newline="\n") as g:
  6. g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
  7. g.write("#ifndef _EDITOR_FONTS_H\n")
  8. g.write("#define _EDITOR_FONTS_H\n")
  9. # Saving uncompressed, since FreeType will reference from memory pointer.
  10. for i in range(len(source)):
  11. file = str(source[i])
  12. with open(file, "rb") as f:
  13. buf = f.read()
  14. name = os.path.splitext(os.path.basename(file))[0]
  15. g.write("static const int _font_" + name + "_size = " + str(len(buf)) + ";\n")
  16. g.write("static const unsigned char _font_" + name + "[] = {\n")
  17. for j in range(len(buf)):
  18. g.write("\t" + str(buf[j]) + ",\n")
  19. g.write("};\n")
  20. g.write("#endif")