Exemplo n.º 1
0
        public void Read(FileReader reader)
        {
            string Signature = reader.ReadString(4, Encoding.ASCII);

            if (Signature != "FINF")
            {
                throw new Exception($"Invalid signature {Signature}! Expected FINF.");
            }
            Size              = reader.ReadUInt32();
            Type              = reader.ReadByte();
            Height            = reader.ReadByte();
            Width             = reader.ReadByte();
            Ascend            = reader.ReadByte();
            LineFeed          = reader.ReadUInt16();
            AlterCharIndex    = reader.ReadUInt16();
            DefaultLeftWidth  = reader.ReadByte();
            DefaultGlyphWidth = reader.ReadByte();
            DefaultCharWidth  = reader.ReadByte();
            CharEncoding      = reader.ReadByte();
            uint tglpOffset = reader.ReadUInt32();
            uint cwdhOffset = reader.ReadUInt32();
            uint cmapOffset = reader.ReadUInt32();

            tglp = new TGLP();
            using (reader.TemporarySeek(tglpOffset - 8, SeekOrigin.Begin))
            {
                tglp.Read(reader);
            }
        }
Exemplo n.º 2
0
        public void Read(FileReader reader, FFNT header)
        {
            CharacterWidths = new List <CWDH>();
            CodeMaps        = new List <CMAP>();

            string Signature = reader.ReadString(4, Encoding.ASCII);

            if (Signature != "FINF")
            {
                throw new Exception($"Invalid signature {Signature}! Expected FINF.");
            }
            Size = reader.ReadUInt32();

            if (header.Platform <= FFNT.PlatformType.Ctr && header.Version < 0x04000000)
            {
                Type              = reader.ReadEnum <FontType>(true);
                LineFeed          = reader.ReadByte();
                AlterCharIndex    = reader.ReadUInt16();
                DefaultLeftWidth  = reader.ReadByte();
                DefaultGlyphWidth = reader.ReadByte();
                DefaultCharWidth  = reader.ReadByte();
                CharEncoding      = reader.ReadEnum <CharacterCode>(true);
                uint tglpOffset = reader.ReadUInt32();
                uint cwdhOffset = reader.ReadUInt32();
                uint cmapOffset = reader.ReadUInt32();

                Height = reader.ReadByte();
                Width  = reader.ReadByte();
                Ascent = reader.ReadByte();
                reader.ReadByte(); //Padding

                //Add counter for TGLP
                //Note the other counters are inside sections due to recusive setup
                header.BlockCounter += 1;

                TextureGlyph = new TGLP();
                using (reader.TemporarySeek(tglpOffset - 8, SeekOrigin.Begin))
                    TextureGlyph.Read(reader, header);

                CharacterWidth = new CWDH();
                CharacterWidths.Add(CharacterWidth);
                using (reader.TemporarySeek(cwdhOffset - 8, SeekOrigin.Begin))
                    CharacterWidth.Read(reader, header, CharacterWidths);

                CodeMap = new CMAP();
                CodeMaps.Add(CodeMap);
                using (reader.TemporarySeek(cmapOffset - 8, SeekOrigin.Begin))
                    CodeMap.Read(reader, header, CodeMaps);
            }
            else
            {
                Type              = reader.ReadEnum <FontType>(true);
                Height            = reader.ReadByte();
                Width             = reader.ReadByte();
                Ascent            = reader.ReadByte();
                LineFeed          = reader.ReadUInt16();
                AlterCharIndex    = reader.ReadUInt16();
                DefaultLeftWidth  = reader.ReadByte();
                DefaultGlyphWidth = reader.ReadByte();
                DefaultCharWidth  = reader.ReadByte();
                CharEncoding      = reader.ReadEnum <CharacterCode>(true);
                uint tglpOffset = reader.ReadUInt32();
                uint cwdhOffset = reader.ReadUInt32();
                uint cmapOffset = reader.ReadUInt32();

                //Add counter for TGLP
                //Note the other counters are inside sections due to recusive setup
                header.BlockCounter += 1;

                TextureGlyph = new TGLP();
                using (reader.TemporarySeek(tglpOffset - 8, SeekOrigin.Begin))
                    TextureGlyph.Read(reader, header);

                CharacterWidth = new CWDH();
                CharacterWidths.Add(CharacterWidth);
                using (reader.TemporarySeek(cwdhOffset - 8, SeekOrigin.Begin))
                    CharacterWidth.Read(reader, header, CharacterWidths);

                CodeMap = new CMAP();
                CodeMaps.Add(CodeMap);
                using (reader.TemporarySeek(cmapOffset - 8, SeekOrigin.Begin))
                    CodeMap.Read(reader, header, CodeMaps);
            }
        }