/// <inheritdoc/>
        public override XElement Read(BinaryReader reader, int?count = null)
        {
            var builder = new TextEntryBuilder(new XElement("text"));

            ushort c;

            while ((c = reader.ReadUInt16()) != 0xffff)
            {
                switch (c)
                {
                case 0xf800:
                    // If the color element is the current element, convert it to an empty element
                    // and move its nodes to its parent element.
                    if (builder.Current.Name.LocalName == "color")
                    {
                        builder.ReplaceWithAdd();
                    }

                    builder.Push(new XElement("color", new XAttribute("value", reader.ReadUInt16())));
                    break;

                case 0xf801:
                    builder.Pop();
                    break;

                case 0xf812:
                    builder.Add(new XElement("clear"));
                    break;

                case 0xf813:
                    builder.Add(new XElement("arrow"));
                    break;

                case 0xf880:
                    builder.Add(new XElement("speed", new XAttribute("value", reader.ReadUInt16())));
                    break;

                case 0xf881:
                    builder.Add(new XElement("wait", new XAttribute("value", reader.ReadUInt16())));
                    break;

                case 0xf884:
                    builder.Add(new XElement("tutorialCourse"));
                    break;

                case 0xf885:
                    builder.Add(new XElement("tutorialLevel"));
                    break;

                case 0xf886:
                    builder.Add(new XElement("tutorialQuestion"));
                    break;

                case 0xfffd:
                    builder.Add('\n');
                    break;

                case 0xfffe:
                    builder.Add(new XElement("r"));
                    break;

                case 0xf8ff:
                    throw new InvalidDataException(Resources.FpdOrFntNotRequired);

                default:
                    if (indexToCharDictionary.TryGetValue(c, out var value))
                    {
                        builder.Add(value);
                    }
                    else
                    {
                        throw new KeyNotFoundException(string.Format(Resources.IndexNotFoundInFontFile, c));
                    }
                    break;
                }
            }

            // If the color element is the current element, convert it to an empty element
            // and move its nodes to its parent element.
            if (builder.Current.Name.LocalName == "color")
            {
                builder.ReplaceWithAdd();
            }

            return(builder.ToXElement());
        }
        /// <inheritdoc/>
        public override XElement Read(BinaryReader reader, int?count = null)
        {
            var builder = new TextEntryBuilder(new XElement("text"));

            char c;

            while ((c = reader.ReadChar()) != '\uf8ff')
            {
                switch (c)
                {
                case '\uf800':
                    // If the color element is the current element, convert it to an empty element
                    // and move its nodes to its parent element.
                    if (builder.Current.Name.LocalName == "color")
                    {
                        builder.ReplaceWithAdd();
                    }

                    builder.Push(new XElement("color", new XAttribute("value", reader.ReadUInt16())));
                    break;

                case '\uf801':
                    builder.Pop();
                    break;

                case '\uf812':
                    builder.Add(new XElement("clear"));
                    break;

                case '\uf813':
                    builder.Add(new XElement("arrow"));
                    break;

                case '\uf880':
                    builder.Add(new XElement("speed", new XAttribute("value", reader.ReadUInt16())));
                    break;

                case '\uf881':
                    builder.Add(new XElement("wait", new XAttribute("value", reader.ReadUInt16())));
                    break;

                case '\uf8fd':
                    builder.Add('\n');
                    break;

                case '\uffff':
                    throw new InvalidDataException(Resources.FpdOrFntRequired);

                default:
                    builder.Add(c);
                    break;
                }
            }

            // If the color element is the current element, convert it to an empty element
            // and move its nodes to its parent element.
            if (builder.Current.Name.LocalName == "color")
            {
                builder.ReplaceWithAdd();
            }

            return(builder.ToXElement());
        }