private static YamlMappingNode SaveKerningTable(FontKerningTable table)
        {
            YamlMappingNode mapping = new YamlMappingNode();

            if (table == null)
            {
                return(mapping);
            }


            return(mapping);
        }
示例#2
0
        public void Read(FileReader reader)
        {
            reader.ByteOrder = Syroot.BinaryData.ByteOrder.BigEndian;

            Signature = reader.ReadString(4, Encoding.ASCII);
            if (Signature != "FFNT" && Signature != "CFNT" && Signature != "RFNT")
            {
                throw new Exception($"Invalid signature {Signature}! Expected FFNT or CFNT or RFNT.");
            }

            BOM = reader.ReadUInt16();
            reader.CheckByteOrderMark(BOM);

            //Parse header first and check the version
            //Brfnt uses a slightly different header structure
            if (Signature == "RFNT")
            {
                Version = reader.ReadUInt16();
                uint FileSize = reader.ReadUInt32();
                HeaderSize = reader.ReadUInt16();
                ushort BlockCount = reader.ReadUInt16();
            }
            else
            {
                HeaderSize = reader.ReadUInt16();
                Version    = reader.ReadUInt32();
                uint   FileSize   = reader.ReadUInt16();
                ushort BlockCount = reader.ReadUInt16();
                ushort Padding    = reader.ReadUInt16();
            }

            //Check platform based on version, magic, and endianness
            if (reader.ByteOrder == Syroot.BinaryData.ByteOrder.LittleEndian)
            {
                if (Version >= 0x04010000)
                {
                    Platform = PlatformType.NX;
                }
                else
                {
                    Platform = PlatformType.Ctr;
                }
            }
            else
            {
                Platform = PlatformType.Cafe;
            }

            if (Signature == "CFNT")
            {
                Platform = PlatformType.Ctr;
            }
            if (Signature == "RFNT")
            {
                Platform = PlatformType.Wii;
            }

            Console.WriteLine($"Platform {Platform}");

            reader.Seek(HeaderSize, SeekOrigin.Begin);
            FontSection = new FINF();
            FontSection.Read(reader, this);

            //Check for any unread blocks
            reader.Seek(HeaderSize, SeekOrigin.Begin);
            while (!reader.EndOfStream)
            {
                long BlockStart = reader.Position;

                string BlockSignature = reader.ReadString(4, Encoding.ASCII);
                uint   BlockSize      = reader.ReadUInt32();

                switch (BlockSignature)
                {
                case "FFNT":
                case "FFNA":
                case "FCPX":
                case "CWDH":
                case "CGLP":
                case "CMAP":
                case "TGLP":
                case "FINF":
                    break;

                case "KRNG":
                    KerningTable = new FontKerningTable();
                    KerningTable.Read(reader, this, BlockSize);
                    break;

                case "GLGR":
                case "HTGL":
                    break;

                default:
                    throw new Exception("Unknown block found! " + BlockSignature);
                }

                reader.SeekBegin(BlockStart + BlockSize);
            }
        }
示例#3
0
        public void Read(FileReader reader)
        {
            reader.ByteOrder = Syroot.BinaryData.ByteOrder.BigEndian;

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

            if (Signature != "FFNT" && Signature != "CFNT")
            {
                throw new Exception($"Invalid signature {Signature}! Expected FFNT or CFNT.");
            }

            BOM = reader.ReadUInt16();
            reader.CheckByteOrderMark(BOM);
            HeaderSize = reader.ReadUInt16();
            Version    = reader.ReadUInt32();
            uint   FileSize   = reader.ReadUInt16();
            ushort BlockCount = reader.ReadUInt16();
            ushort Padding    = reader.ReadUInt16();

            if (reader.ByteOrder == Syroot.BinaryData.ByteOrder.LittleEndian)
            {
                if (Version > 0x3000000 || Version > 0x00000103)
                {
                    Platform = PlatformType.NX;
                }
                else
                {
                    Platform = PlatformType.Ctr;
                }
            }
            else
            {
                Platform = PlatformType.Cafe;
            }

            if (Signature == "CFNT")
            {
                Platform = PlatformType.Ctr;
            }

            reader.Seek(HeaderSize, SeekOrigin.Begin);
            FontSection = new FINF();
            FontSection.Read(reader, this);
            Blocks.Add(FontSection);

            //Check for any unread blocks
            reader.Seek(HeaderSize, SeekOrigin.Begin);
            while (!reader.EndOfStream)
            {
                long BlockStart = reader.Position;

                string BlockSignature = reader.ReadString(4, Encoding.ASCII);
                uint   BlockSize      = reader.ReadUInt32();

                switch (BlockSignature)
                {
                case "FFNT":
                case "FFNA":
                case "FCPX":
                case "CWDH":
                case "CGLP":
                case "CMAP":
                case "TGLP":
                case "FINF":
                    break;

                case "KRNG":
                    KerningTable = new FontKerningTable();
                    KerningTable.Read(reader, this);
                    break;

                case "GLGR":
                case "HTGL":
                    break;

                default:
                    throw new Exception("Unknown block found! " + BlockSignature);
                }

                reader.SeekBegin(BlockStart + BlockSize);
            }
        }