Пример #1
0
        } // Validate

        #endregion


        #region Private instance methods

        protected override void ReadTable_Internal()
        {
            // Base class constructor ran partial validations on the table record,
            // including checking that the offset and length are within bounds

            if ((_validationStatus & OTFile.OTFileValidation_StructureOffsetOutOfRange) != 0)
            {
                // out of range so can't read anything
                return;
            }

            MemoryStream ms = _parentFont.MemoryStream;


            // Get the version and check that before continuing
            try
            {
                ms.Seek(_tableRecord.Offset, SeekOrigin.Begin);
                _version = OTFixed.ReadFixed(ms);
            }
            catch (OTDataIncompleteReadException e)
            {
                _validationStatus |= OTFile.OTFileValidation_ReadTrunctated;
                throw new OTFileParseException("OT parse error: unable to read " + _tableTag + " table", e);
            }

            if (_version.Mantissa != 2)
            {
                _validationStatus |= OTFile.OTFileValidation_StructureVersionNotSupported;
                throw new OTUnknownVersionException("OT parse error: unrecognized " + _tableTag + " version");
            }

            if (_version.FixedTableMinorVersionToInteger() > _fmtx_2_latestKnownMinorVersion)
            {
                _validationStatus |= OTFile.OTFileValidation_StructureMinorVersionUnknown;
            }
            if (_tableRecord.Length < _fmtx_2_0_headerLength)
            {
                _validationStatus |= OTFile.OTFileValidation_TableLengthTooShort;
            }


            // Known version, OK to continue
            try
            {
                _glyphIndex          = OTFile.ReadUInt32(ms);
                _horizontalBefore    = OTFile.ReadUInt8(ms);
                _horizontalAfter     = OTFile.ReadUInt8(ms);
                _horizontalCaretHead = OTFile.ReadUInt8(ms);
                _horizontalCaretBase = OTFile.ReadUInt8(ms);
                _verticalBefore      = OTFile.ReadUInt8(ms);
                _verticalAfter       = OTFile.ReadUInt8(ms);
                _verticalCaretHead   = OTFile.ReadUInt8(ms);
                _verticalCaretBase   = OTFile.ReadUInt8(ms);
            }
            catch (OTDataIncompleteReadException e)
            {
                _validationStatus |= OTFile.OTFileValidation_ReadTrunctated;
                throw new OTFileParseException("OT parse error: unable to read " + _tableTag + " table", e);
            }
        } // ReadTable_Internal
Пример #2
0
        } // Validate

        #endregion


        #region Private instance methods

        protected override void ReadTable_Internal()
        {
            // Base class constructor ran partial validations on the table record,
            // including checking that the offset and length are within bounds

            if ((_validationStatus & OTFile.OTFileValidation_StructureOffsetOutOfRange) != 0)
            {
                // out of range so can't read anything
                return;
            }

            MemoryStream ms = _parentFont.MemoryStream;


            // Get the version and check that before continuing
            try
            {
                ms.Seek(_tableRecord.Offset, SeekOrigin.Begin);
                _version = OTFixed.ReadFixed(ms);
            }
            catch (OTDataIncompleteReadException e)
            {
                _validationStatus |= OTFile.OTFileValidation_ReadTrunctated;
                throw new OTFileParseException("OT parse error: unable to read " + _tableTag + " table", e);
            }

            if (_version.Mantissa != 0 && _version.Mantissa != 1)
            {
                _validationStatus |= OTFile.OTFileValidation_StructureVersionNotSupported;
                throw new OTUnknownVersionException("OT parse error: unrecognized " + _tableTag + " version");
            }

            switch (_version.Mantissa)
            {
            case 0:
                if (_version.FixedTableMinorVersionToInteger() > _maxp_0_latestKnownMinorVersion)
                {
                    _validationStatus |= OTFile.OTFileValidation_StructureMinorVersionUnknown;
                }
                if (_tableRecord.Length < _maxp_0_5_headerLength)
                {
                    _validationStatus |= OTFile.OTFileValidation_TableLengthTooShort;
                }
                break;

            case 1:
                if (_version.FixedTableMinorVersionToInteger() > _maxp_1_latestKnownMinorVersion)
                {
                    _validationStatus |= OTFile.OTFileValidation_StructureMinorVersionUnknown;
                }
                if (_tableRecord.Length < _maxp_1_0_headerLength)
                {
                    _validationStatus |= OTFile.OTFileValidation_TableLengthTooShort;
                }
                break;
            }


            // Known version, OK to continue
            try
            {
                _numGlyphs = OTFile.ReadUInt16(ms);
            }
            catch (OTDataIncompleteReadException e)
            {
                _validationStatus |= OTFile.OTFileValidation_ReadTrunctated;
                throw new OTFileParseException("OT parse error: unable to read " + _tableTag + " table", e);
            }

            if (_version.Mantissa == 1)
            {
                try
                {
                    _maxPoints             = OTFile.ReadUInt16(ms);
                    _maxContours           = OTFile.ReadUInt16(ms);
                    _maxCompositePoints    = OTFile.ReadUInt16(ms);
                    _maxCompositeContours  = OTFile.ReadUInt16(ms);
                    _maxZones              = OTFile.ReadUInt16(ms);
                    _maxTwilightPoints     = OTFile.ReadUInt16(ms);
                    _maxStorage            = OTFile.ReadUInt16(ms);
                    _maxFunctionDefs       = OTFile.ReadUInt16(ms);
                    _maxInstructionDefs    = OTFile.ReadUInt16(ms);
                    _maxStackElements      = OTFile.ReadUInt16(ms);
                    _maxSizeOfInstructions = OTFile.ReadUInt16(ms);
                    _maxComponentElements  = OTFile.ReadUInt16(ms);
                    _maxComponentDepth     = OTFile.ReadUInt16(ms);
                }
                catch (OTDataIncompleteReadException e)
                {
                    _validationStatus |= OTFile.OTFileValidation_ReadTrunctated;
                    throw new OTFileParseException("OT parse error: unable to read " + _tableTag + " table", e);
                }
            }
        } // ReadTable_Internal