예제 #1
0
        } // ReadTableRecord

        public UInt64 Validate(long fileLength)
        {
            // Check that tag is defined and known, and that table
            // offset & length are in bounds.

            if (!OTFont.IsKnownTableType(_tableTag))
            {
                _validationStatus |= OTFile.OTFileValidation_UnknownTableTag;
            }
            if (!OTFont.IsSupportedTableType(_tableTag))
            {
                _validationStatus |= OTFile.OTFileValidation_UnsupportedTableTag;
            }
            if (_tableOffset > fileLength)
            {
                _validationStatus |= OTFile.OTFileValidation_ReferencedStructureOffsetOutOfRange;
            }
            if (_tableOffset + _tableLength > fileLength)
            {
                _validationStatus |= OTFile.OTFileValidation_ReferencedStructureLengthOutOfRange;
            }

            // completed validateions; clear the partial validation flag and check for errors
            _validationStatus &= ~OTFile.OTFileValidation_PartialValidation;
            if ((_validationStatus & OTFile.OTFileValidation_ValidationIssueMask) == 0)
            {
                _validationStatus = OTFile.OTFileValidation_Valid;
            }

            return(_validationStatus);
        } // Validate
예제 #2
0
        private void ReadFont_Internal(MemoryStream ms)
        {
            // results in Offset table for font being read, but no other tables

            // assumed: _offsetInFile has already been set and validated as in bounds
            try
            {
                _offsetTable.ReadOffsetTable(ms, _offsetInFile);
            }
            catch (OTTableParseException e)
            {
                throw new OTFontParseException("Unable to parse font data", e);
            }


            // Offset table for font has been read; we know how many and what kind
            // of tables.

            _tables = new OTTable[_offsetTable.NumTables];                  // initialized with entries == null
            _validationStatusOfTables = new UInt64[_offsetTable.NumTables]; // initialized with entries == NotValidated

            // The following is something temporary: populate an array of OTTable objects
            // passing each its offset table record. The record is all that's needed to
            // parse each table; but once an object is created (OTTable), it can't change
            // itself into a different type; it can only be substituted with a different
            // type of object, and that substitution would have to be done by something
            // else.

            for (int i = 0; i < _offsetTable.NumTables; i++)
            {
                if (OTFont.IsSupportedTableType(_offsetTable.TableRecords[i].Tag))
                {
                    switch (_offsetTable.TableRecords[i].Tag.ToString())
                    {
                    case "COLR":
                        _tables[i] = new TableColr(this, _offsetTable.TableRecords[i]);
                        break;

                    case "fmtx":
                        _tables[i] = new TableFmtx(this, _offsetTable.TableRecords[i]);
                        break;

                    case "head":
                        _tables[i] = new TableHead(this, _offsetTable.TableRecords[i]);
                        break;

                    case "hhea":
                        _tables[i] = new TableHhea(this, _offsetTable.TableRecords[i]);
                        break;

                    case "maxp":
                        _tables[i] = new TableMaxp(this, _offsetTable.TableRecords[i]);
                        break;
                    }
                }
                else
                {
                    _tables[i] = new OTTable(this, _offsetTable.TableRecords[i]);
                }
            }
        } // ReadFont_Internal