C# xps odttf 反混淆 加载odttf字体

 void ODTTFToTTF(string path)
        {
            byte[] ds = System.IO.File.ReadAllBytes(path);
            string guid = System.IO.Path.GetFileNameWithoutExtension(path).Replace("-", "");
            byte[] gs = new byte[16];
            for (int i = 0; i < 16; i++)
            {
                gs[i] = Convert.ToByte(guid.Substring(i * 2, 2), 16);
            }
            for (int i = 0; i < 32; i++)
            {
                int gi = 15 - (i % 16);
                ds[i] ^= gs[gi];
            }
            System.IO.File.WriteAllBytes(path.Replace(".odttf", ".ttf"), ds);
        }

wpf加载字体

   PrivateFontCollection privateFontCollection = new PrivateFontCollection();

string filePath=@"D:\dox\Documents\1\Resources\Fonts\75F1B63C-0F36-40E5-A921-EA4F7F3B01C9.ttf"";

 privateFontCollection.AddFontFile(filePath)

  var font = new FontFamily(new Uri(filePath), privateFontCollection.Families[0].Name);

你可能感兴趣的:(c#,开发语言,wpf)