Esempio n. 1
0
 /// <summary>
 ///     Queues the supplied <see cref="FontTable"/> for writing
 ///     to the underlying stream.
 /// </summary>
 /// <remarks>
 ///     The method will not immediately write the supplied font
 ///     table to the underlying stream.  Instead it queues the
 ///     font table since the offset table must be written out
 ///     before any tables.
 /// </remarks>
 /// <param name="table"></param>
 public void Write(FontTable table)
 {
     if (tables.Contains(table.Name))
     {
         throw new ArgumentException("Already written table '" + table.Name + "'");
     }
     tables.Add(table.Name, table);
 }
Esempio n. 2
0
        private void WriteFontTable(FontTable table)
        {
            // Start position required to generate checksum and length
            long startPosition = stream.SetRestorePoint();

            // FontTable subclass is responsible for writing itself
            table.Write(this);

            // Align table on 4-byte boundary
            int padding = stream.Pad();

            // Restore will reset stream position back to startPosition
            long endPosition = stream.Restore();

            // The table length not including the padding
            table.Entry.Length   = (uint)(endPosition - startPosition - padding);
            table.Entry.Offset   = (uint)startPosition;
            table.Entry.CheckSum = CalculateCheckSum(table.Entry.Length);
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
 /// <summary>
 ///     Queues the supplied <see cref="FontTable"/> for writing 
 ///     to the underlying stream.
 /// </summary>
 /// <remarks>
 ///     The method will not immediately write the supplied font 
 ///     table to the underlying stream.  Instead it queues the 
 ///     font table since the offset table must be written out 
 ///     before any tables.
 /// </remarks>
 /// <param name="table"></param>
 public void Write(FontTable table) {
     if (tables.Contains(table.Name)) {
         throw new ArgumentException("Already written table '" + table.Name + "'");
     }
     tables.Add(table.Name, table);
 }
Esempio n. 5
0
        private void WriteFontTable(FontTable table) {
            // Start position required to generate checksum and length
            long startPosition = stream.SetRestorePoint();

            // FontTable subclass is responsible for writing itself
            table.Write(this);

            // Align table on 4-byte boundary
            int padding = stream.Pad();

            // Restore will reset stream position back to startPosition
            long endPosition = stream.Restore();

            // The table length not including the padding
            table.Entry.Length = (uint) (endPosition - startPosition - padding);
            table.Entry.Offset = (uint) startPosition;
            table.Entry.CheckSum = CalculateCheckSum(table.Entry.Length);
        }