FontUtils.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. using System.IO;
  2. namespace Ryujinx.HLE.Utilities
  3. {
  4. public static class FontUtils
  5. {
  6. private static readonly uint FontKey = 0x06186249;
  7. public static byte[] DecryptFont(Stream BFTTFStream)
  8. {
  9. uint KXor(uint In) => In ^ 0x06186249;
  10. using (BinaryReader Reader = new BinaryReader(BFTTFStream))
  11. {
  12. using (MemoryStream TTFStream = new MemoryStream())
  13. {
  14. using (BinaryWriter Output = new BinaryWriter(TTFStream))
  15. {
  16. if (KXor(Reader.ReadUInt32()) != 0x18029a7f)
  17. {
  18. throw new InvalidDataException("Error: Input file is not in BFTTF format!");
  19. }
  20. BFTTFStream.Position += 4;
  21. for (int i = 0; i < (BFTTFStream.Length - 8) / 4; i++)
  22. {
  23. Output.Write(KXor(Reader.ReadUInt32()));
  24. }
  25. return TTFStream.ToArray();
  26. }
  27. }
  28. }
  29. }
  30. }
  31. }