forc.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import pathlib
  2. import log
  3. import shutil
  4. import files
  5. from format import formats
  6. def createFont(formatData, outPath, tempPath, filename, flags, font):
  7. """
  8. Calls the functions that assemble and create a font via forc's internal compiler method.
  9. """
  10. # VARIABLES
  11. # ------------------------------------------------------
  12. extension = formatData["extension"]
  13. imageFormat = formatData["imageFormat"]
  14. formatName = formatData["name"]
  15. outFontPath = tempPath / (filename + extension)
  16. testTTX = tempPath / (filename + "_test.ttx")
  17. # COMPILER
  18. # ------------------------------------------------------
  19. log.out(f"[forc compiler]", 90)
  20. # save TTX
  21. log.out(f"- Packing font data into binary and writing it to file...", 90)
  22. files.writeFile(outFontPath, font.toBytes(), 'Could not write binary font to file')
  23. # TESTING
  24. # ------------------------------------------------------
  25. if not flags['no_test']:
  26. log.out(f'- Testing font by attempting to decompile as TTX..', 90)
  27. files.compileTTX(outFontPath, testTTX)
  28. return outFontPath