Пример #1
0
        private void ParseVFont(string path)
        {
            lock (ConsoleWriterLock)
            {
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("--- Loading font file \"{0}\" ---", path);
                Console.ResetColor();
            }

            var font = new ValveFont();

            try
            {
                var output = font.Read(path);

                if (OutputFile != null)
                {
                    var fileName = Path.GetFileName(path);
                    fileName = Path.ChangeExtension(fileName, "ttf");

                    DumpFile(fileName, output, true);
                }
            }
            catch (Exception e)
            {
                lock (ConsoleWriterLock)
                {
                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.WriteLine(e);
                    Console.ResetColor();
                }
            }
        }
Пример #2
0
        public void DecryptFonts()
        {
            var path  = Path.Combine(TestContext.CurrentContext.TestDirectory, "Files", "Fonts");
            var files = Directory.GetFiles(path, "*.vfont");

            foreach (var file in files)
            {
                var shader        = new ValveFont();
                var decryptedFont = shader.Read(file);

                using (var decryptedStream = new MemoryStream(decryptedFont))
                    using (var expected = new FileStream(Path.ChangeExtension(file, "ttf"), FileMode.Open, FileAccess.Read))
                    {
                        FileAssert.AreEqual(expected, decryptedStream);
                    }
            }
        }