/// <summary> /// Read a FNT section from a stream. /// </summary> /// <param name="str">Stream to read from.</param> public override void Read(DataStream str) { DataReader dr = new DataReader(str); uint fntOffset = (uint)str.Position; // Get the number of directories and the offset to subtables // from the main table. uint subtablesOffset = dr.ReadUInt32() + fntOffset; dr.ReadUInt16(); ushort numDirs = dr.ReadUInt16(); this.tables = new Fnt.FntTable[numDirs]; for (int i = 0; i < numDirs; i++) { str.Seek(fntOffset + (i * FntEntrySize), SeekMode.Origin); // Error, in some cases the number of directories is wrong. // Found in FF Four Heroes of Light, Tetris Party deluxe. if (str.Position > subtablesOffset) { numDirs = (ushort)i; Array.Resize(ref this.tables, numDirs); break; } FntTable table = new FntTable( dr.ReadUInt32(), // Offset dr.ReadUInt16(), // Id First File dr.ReadUInt16()); // Id Parent Folder // Read subtable str.Seek(fntOffset + table.Offset, SeekMode.Origin); table.Read(str); this.tables[i] = table; } }
/// <summary> /// Read a FNT section from a stream. /// </summary> /// <param name="str">Stream to read from.</param> public override void Read(DataStream str) { DataReader dr = new DataReader(str); uint fntOffset = (uint)str.Position; // Get the number of directories and the offset to subtables // from the main table. uint subtablesOffset = dr.ReadUInt32() + fntOffset; dr.ReadUInt16(); ushort numDirs = dr.ReadUInt16(); this.tables = new Fnt.FntTable[numDirs]; for (int i = 0; i < numDirs; i++) { str.Seek(fntOffset + (i * FntEntrySize), SeekMode.Origin); // Error, in some cases the number of directories is wrong. // Found in FF Four Heroes of Light, Tetris Party deluxe. if (str.Position > subtablesOffset) { numDirs = (ushort)i; Array.Resize(ref this.tables, numDirs); break; } FntTable table = new FntTable( dr.ReadUInt32(), // Offset dr.ReadUInt16(), // Id First File dr.ReadUInt16()); // Id Parent Folder // Read subtable str.Seek(fntOffset + table.Offset, SeekMode.Origin); table.Read(str); this.tables[i] = table; } }