예제 #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);
                _majorVersion = OTFile.ReadUInt16(ms);
                _minorVersion = OTFile.ReadUInt16(ms);
            }
            catch (OTDataIncompleteReadException e)
            {
                _validationStatus |= OTFile.OTFileValidation_ReadTrunctated;
                throw new OTFileParseException("OT parse error: unable to read " + _tableTag + " table", e);
            }

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

            if (_minorVersion > _hhea_1_latestKnownVersion)
            {
                _validationStatus |= OTFile.OTFileValidation_StructureMinorVersionUnknown;
            }
            if (_tableRecord.Length < _hhea_1_0_headerLength)
            {
                _validationStatus |= OTFile.OTFileValidation_TableLengthTooShort;
            }


            // Known version, OK to continue
            try
            {
                _ascender            = OTFile.ReadOTFword(ms);
                _descender           = OTFile.ReadOTFword(ms);
                _lineGap             = OTFile.ReadOTFword(ms);
                _advanceWidthMax     = OTFile.ReadOTUfword(ms);
                _minLeftSideBearing  = OTFile.ReadOTFword(ms);
                _minRightSideBearing = OTFile.ReadOTFword(ms);
                _xMaxExtent          = OTFile.ReadOTFword(ms);
                _caretSlopeRise      = OTFile.ReadInt16(ms);
                _caretSlopeRun       = OTFile.ReadInt16(ms);
                _caretOffset         = OTFile.ReadInt16(ms);
                _reserved1           = OTFile.ReadInt16(ms);
                _reserved2           = OTFile.ReadInt16(ms);
                _reserved3           = OTFile.ReadInt16(ms);
                _reserved4           = OTFile.ReadInt16(ms);
                _metricDataFormat    = OTFile.ReadInt16(ms);
                _numberOfHMetrics    = OTFile.ReadUInt16(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);
                _majorVersion = OTFile.ReadUInt16(ms);
                _minorVersion = OTFile.ReadUInt16(ms);
            }
            catch (OTDataIncompleteReadException e)
            {
                _validationStatus |= OTFile.OTFileValidation_ReadTrunctated;
                throw new OTFileParseException("OT parse error: unable to read " + _tableTag + " table", e);
            }

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

            if (_minorVersion > _head_1_latestKnownMinorVersion)
            {
                _validationStatus |= OTFile.OTFileValidation_StructureMinorVersionUnknown;
            }
            if (_tableRecord.Length < _head_1_0_headerLength)
            {
                _validationStatus |= OTFile.OTFileValidation_TableLengthTooShort;
            }


            // Known version, OK to continue
            try
            {
                _fontRevision       = OTFixed.ReadFixed(ms);
                _checkSumAdjustment = OTFile.ReadUInt32(ms);
                _magicNumber        = OTFile.ReadUInt32(ms);
                _flagsRaw           = OTFile.ReadUInt16(ms);
                _unitsPerEm         = OTFile.ReadUInt16(ms);
                _createdRaw         = OTFile.ReadOTLongDateTimeAsInt64(ms);
                _modifiedRaw        = OTFile.ReadOTLongDateTimeAsInt64(ms);
                _xMin              = OTFile.ReadInt16(ms);
                _yMin              = OTFile.ReadInt16(ms);
                _xMax              = OTFile.ReadInt16(ms);
                _yMax              = OTFile.ReadInt16(ms);
                _macStyleRaw       = OTFile.ReadUInt16(ms);
                _lowestRecPPEm     = OTFile.ReadUInt16(ms);
                _fontDirectionHint = OTFile.ReadInt16(ms);
                _indexToLocFormat  = OTFile.ReadInt16(ms);
                _glyphDataFormat   = OTFile.ReadInt16(ms);
            }
            catch (OTDataIncompleteReadException e)
            {
                _validationStatus |= OTFile.OTFileValidation_ReadTrunctated;
                throw new OTFileParseException("OT parse error: unable to read " + _tableTag + " table", e);
            }

            SetHeadFlagValues();     // set HeadFlags struct values
            SetHeadMacStyleValues(); // set HeadMacStyle struct values
        } // ReadTable_Internal