ThatTrueStruggle

Fontifier.py

May 8th, 2016
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.05 KB | None | 0 0
  1. import struct
  2.  
  3. TPLData = open(raw_input("Path to TPL? "), "rb").read()
  4. BRFNTData = open(raw_input("Path to BRFNT? "), "rb").read()
  5. FormatType = int(raw_input("Image Format Type? "))
  6. OutData = open(raw_input("Output File Name? "), "wb")
  7.  
  8. BRFNTHeader = BRFNTData[0x00:0x60]
  9. CWDHData = BRFNTData[BRFNTData.find("CWDH"):len(BRFNTData)]
  10. RAWTPLData = TPLData[0x80:len(TPLData)]
  11. CMAPosChange = BRFNTData.find("CMAP") - BRFNTData.find("CWDH")
  12.  
  13. OutData.write(BRFNTHeader)
  14. OutData.write(RAWTPLData)
  15. CWDHPos = OutData.tell()
  16. OutData.write(CWDHData)
  17.  
  18. BRFNTSize = OutData.tell()
  19. OutData.seek(0x08, 0)
  20.  
  21. OutData.write(struct.pack('>L', BRFNTSize)) # Current BRFNT Size
  22. OutData.seek(0x24, 0)
  23.  
  24. OutData.write(struct.pack('>L', CWDHPos + 8)) # CWDH Position
  25. OutData.write(struct.pack('>L', CWDHPos + CMAPosChange + 8)) #CMAP Position
  26.  
  27. OutData.seek(0x3C, 0)
  28. OutData.write(struct.pack('>L', len(RAWTPLData) / 2)) # Size of one image
  29.  
  30. OutData.seek(0x42, 0)
  31. OutData.write(struct.pack('>H', FormatType))
  32. OutData.close()
  33.  
  34. raw_input("Done! Press enter to exit.")
Advertisement
Add Comment
Please, Sign In to add comment