2018-11-18 19:37:41 +00:00
|
|
|
|
using System.IO;
|
|
|
|
|
|
|
|
|
|
namespace Ryujinx.HLE.Utilities
|
|
|
|
|
{
|
|
|
|
|
public static class FontUtils
|
|
|
|
|
{
|
|
|
|
|
private static readonly uint FontKey = 0x06186249;
|
|
|
|
|
|
2018-12-05 00:52:39 +00:00
|
|
|
|
public static byte[] DecryptFont(Stream BFTTFStream)
|
2018-11-18 19:37:41 +00:00
|
|
|
|
{
|
|
|
|
|
uint KXor(uint In) => In ^ 0x06186249;
|
|
|
|
|
|
2018-12-05 00:52:39 +00:00
|
|
|
|
using (BinaryReader Reader = new BinaryReader(BFTTFStream))
|
2018-11-18 19:37:41 +00:00
|
|
|
|
{
|
2018-12-05 00:52:39 +00:00
|
|
|
|
using (MemoryStream TTFStream = new MemoryStream())
|
2018-11-18 19:37:41 +00:00
|
|
|
|
{
|
2018-12-05 00:52:39 +00:00
|
|
|
|
using (BinaryWriter Output = new BinaryWriter(TTFStream))
|
2018-11-18 19:37:41 +00:00
|
|
|
|
{
|
2018-12-05 00:52:39 +00:00
|
|
|
|
if (KXor(Reader.ReadUInt32()) != 0x18029a7f)
|
2018-11-18 19:37:41 +00:00
|
|
|
|
{
|
|
|
|
|
throw new InvalidDataException("Error: Input file is not in BFTTF format!");
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-05 00:52:39 +00:00
|
|
|
|
BFTTFStream.Position += 4;
|
2018-11-18 19:37:41 +00:00
|
|
|
|
|
2018-12-05 00:52:39 +00:00
|
|
|
|
for (int i = 0; i < (BFTTFStream.Length - 8) / 4; i++)
|
2018-11-18 19:37:41 +00:00
|
|
|
|
{
|
2018-12-05 00:52:39 +00:00
|
|
|
|
Output.Write(KXor(Reader.ReadUInt32()));
|
2018-11-18 19:37:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-12-05 00:52:39 +00:00
|
|
|
|
return TTFStream.ToArray();
|
2018-11-18 19:37:41 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|