Example #1
0
        private void Read(Stream stream)
        {
            using (BinaryReader reader = IOTools.OpenReadFile(stream, IsLittleEndian))
            {
                // Read Header
                if (reader.ReadUInt32() != MagicNumber)
                {
                    throw new Exception("FNT0 Header: wrong magicnumber");
                }
                if (reader.ReadUInt32() != 0x00010000)
                {
                    throw new Exception("FNT0 Header: wrong unknown");
                }
                Width  = reader.ReadUInt16();
                Height = reader.ReadUInt16();
                if (reader.ReadInt32() != 0)
                {
                    throw new Exception("FNT0 Header: wrong padding");
                }

                int unknownPos = reader.ReadInt32();
                int dicPos     = reader.ReadInt32();

                // Read Unknown Block
                Unknown = reader.ReadBytes(dicPos - unknownPos);

                // Read Combressed Block
                Compressed = new FNTCompressed(reader);

                if (stream.Position != stream.Length)
                {
                    throw new Exception("FNT0 Header: wrong size");
                }
            }
        }
Example #2
0
        private void Read(Stream stream, long position)
        {
            stream.Position = position;
            BinaryReader reader = new BinaryReader(stream);

            Header = new FNTHeader(reader);
            reader.BaseStream.Position = Header.HeaderSize;
            Palette    = new FNTPalette(reader, Header.Glyphs.NumberOfColor);
            WidthTable = new FNTWidthTable(reader);
            Unknown    = new FNTUnknown(reader);
            Reserved   = new FNTReserved(reader, Header.Glyphs.Count);
            Compressed = new FNTCompressed(reader);

            if (Header.LastPosition != 0)
            {
                reader.BaseStream.Position = Header.LastPosition;
                Last = new FNTLast(reader, Header.Glyphs.Count);
            }
        }