/// <summary>
            /// Deserializes this structure from binary data.
            /// </summary>
            /// <param name="reader">The <see cref="BinaryReader"/> to read the data from.</param>
            public void ReadFrom(BinaryReader reader)
            {
                _stateCount = reader.ReadUInt16();

                for (int i = 0; i < _stateCount; i++)
                {
                    _stateOffsets.Add(reader.ReadUInt16());
                }

                _stateOffsets.Sentinel = reader.ReadUInt16();

                if (_stateCount % 2 == 1)
                {
                    reader.ReadUInt16();
                }

                int ruleCount = _stateOffsets.Sentinel;

                for (int i = 0; i < ruleCount; i++)
                {
                    Rule rule = new Rule();
                    rule.ReadFrom(reader);

                    _rules.Add(rule);
                }
            }
        /// <summary>
        /// Deserializes this structure from binary data.
        /// </summary>
        /// <param name="reader">The <see cref="BinaryReader"/> to read the data from.</param>
        /// <param name="font">The <see cref="TinyFont"/> containing this appendix.</param>
        /// <exception cref="ArgumentNullException"><paramref name="reader"/> is null.</exception>
        public override void ReadFrom(BinaryReader reader, TinyFont font)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }

            while (true)
            {
                MetadataSetOffset offset = new MetadataSetOffset();
                offset.ReadFrom(reader);

                if (offset.Id == 0xFF)
                {
                    _setsOffsets.Sentinel = offset;
                    break;
                }

                _setsOffsets.Add(offset);
            }

            for (int i = 0; i < _setsOffsets.ItemsCount; i++)
            {
                byte[] data = reader.ReadBytes(_setsOffsets[i + 1].Offset - _setsOffsets[i].Offset);
                Sets.Add(data);
            }
        }
Exemple #3
0
        private void ReadBasicFrom(BinaryReader reader)
        {
            _characterRanges.Clear();
            _characterRanges.Capacity = _description.Ranges;
            for (int i = 0; i < _description.Ranges; i++)
            {
                CharacterRangeDescription range = new CharacterRangeDescription();
                range.ReadFrom(reader);

                _characterRanges.Add(range);
            }
            _characterRanges.Sentinel = new CharacterRangeDescription();
            _characterRanges.Sentinel.ReadFrom(reader);

            _characters.Clear();
            _characters.Capacity = _description.Characters;
            for (int i = 0; i < _description.Characters; i++)
            {
                CharacterDescription character = new CharacterDescription();
                character.ReadFrom(reader);

                _characters.Add(character);
            }
            _characters.Sentinel = new CharacterDescription();
            _characters.Sentinel.ReadFrom(reader);

            int wordwidth = (int)((_characterBitmapDescription.Width * _characterBitmapDescription.BitsPerPixel + 31) / 32 * _characterBitmapDescription.Height * 4);

            _characterBitmapData = reader.ReadBytes(wordwidth);
        }
Exemple #4
0
        /// <summary>
        /// Deserializes this structure from binary data.
        /// </summary>
        /// <param name="reader">The <see cref="BinaryReader"/> to read the data from.</param>
        /// <param name="font">Tiny Font containing this appendix.</param>
        /// <exception cref="ArgumentNullException"><paramref name="reader"/> is null.</exception>
        public override void ReadFrom(BinaryReader reader, TinyFont font)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }

            _featureCount = reader.ReadUInt16();
            _heapSize     = reader.ReadUInt16();

            _featureOffsets.Clear();
            _featureOffsets.Capacity = _featureCount;

            for (int i = 0; i < _featureCount; i++)
            {
                FeatureOffset offset = new FeatureOffset();
                offset.ReadFrom(reader);

                _featureOffsets.Add(offset);
            }

            _featureOffsets.Sentinel.ReadFrom(reader);

            _features.Clear();
            _features.Capacity = _featureCount;

            for (int i = 0; i < _featureCount; i++)
            {
                Feature feature = new Feature();
                feature.ReadFrom(reader);

                _features.Add(feature);
            }

            _features.Sentinel.ReadFrom(reader);

            if (_heapSize > 0)
            {
                _parametersHeap = reader.ReadBytes(_heapSize);
            }
        }