Esempio n. 1
0
        public bool TryGetTable(OTTag tag, out OTTable table)
        {
            uint?idx = _offsetTable.GetTableRecordIndex(tag);

            if (idx.HasValue)
            {
                table = _tables[idx.Value];
                return(true);
            }
            else
            {
                table = null;
                return(false);
            }
        }
Esempio n. 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