Esempio n. 1
0
        /// <summary>
        ///     Gets a reference to the table structure identified by <i>tableName</i>
        /// </summary>
        /// <remarks>
        ///     Only the following tables are supported:
        ///     <see cref="TableNames.Head"/> - Font header,
        ///     <see cref="TableNames.Hhea"/> - Horizontal header,
        ///     <see cref="TableNames.Hmtx"/> - Horizontal metrics,
        ///     <see cref="TableNames.Maxp"/> - Maximum profile,
        ///     <see cref="TableNames.Loca"/> - Index to location,
        ///     <see cref="TableNames.Glyf"/> - Glyf data,
        ///     <see cref="TableNames.Cvt"/> - Control value,
        ///     <see cref="TableNames.Prep"/> - Control value program,
        ///     <see cref="TableNames.Fpgm"/> - Font program
        /// </remarks>
        /// <param name="tableName">A 4-character code identifying a table.</param>
        /// <exception cref="ArgumentException">
        ///     If <b>tableName</b> does not represent a table in this font.
        /// </exception>
        internal FontTable GetTable(string tableName)
        {
            if (!ContainsTable(tableName))
            {
                throw new ArgumentException("Cannot locate table '" + tableName + "'", "tableName");
            }

            // Obtain from cache is present
            if (tableCache.Contains(tableName))
            {
                return((FontTable)tableCache[tableName]);
            }

            // Otherwise instantiate appropriate FontTable subclass and parse
            DirectoryEntry tableEntry = GetDictionaryEntry(tableName);
            FontTable      table      = tableEntry.MakeTable(this);

            if (table != null)
            {
                OffsetStream(tableEntry);
                table.Read(this);
            }
            return(table);
        }