Esempio n. 1
0
        private IndexToLocationTable CreateLocaTable(GlyfDataTable glyfTable) {
            DirectoryEntry entry = new DirectoryEntry(TableNames.Loca);
            IndexToLocationTable loca = new IndexToLocationTable(entry, glyfTable.Count);

            uint offset = 0;
            for (int i = 0; i < glyfTable.Count; i++) {
                loca.AddOffset(offset);
                offset += glyfTable[i].Length;
            }

            // Add trailer offset
            loca.AddOffset(offset);

            return loca;
        }
Esempio n. 2
0
        private HorizontalMetricsTable CreateHmtxTable(GlyfDataTable glyfTable) {
            // Fetches horizontal metrics for all glyphs
            HorizontalMetricsTable hmtxOld = reader.GetHorizontalMetricsTable();

            DirectoryEntry entry = new DirectoryEntry(TableNames.Hmtx);
            HorizontalMetricsTable hmtx =
                new HorizontalMetricsTable(entry, glyfTable.Count);

            // Copy required horizontal metrics.
            IndexMappings mappings = reader.IndexMappings;
            foreach (int subsetIndex in mappings.SubsetIndices) {
                int glyphIndex = mappings.GetGlyphIndex(subsetIndex);
                hmtx[subsetIndex] = hmtxOld[glyphIndex].Clone();
            }

            return hmtx;
        }
Esempio n. 3
0
        protected internal void Read(FontFileStream stream) {
            // Skip sfnt version (0x00010000 for version 1.0).
            stream.Skip(PrimitiveSizes.Fixed);

            // Number of tables
            int numTables = stream.ReadUShort();

            // Skip searchRange, entrySelector and rangeShift entries (3 x ushort)
            stream.Skip(PrimitiveSizes.UShort*3);

            directoryEntries = new Hashtable(numTables);
            for (int i = 0; i < numTables; i++) {
                DirectoryEntry entry = new DirectoryEntry(
                    stream.ReadTag(), // 4-byte identifier.
                    stream.ReadULong(), // CheckSum for this table. 
                    stream.ReadULong(), // Offset from beginning of TrueType font file. 
                    stream.ReadULong() // Length of this table. 
                    );
                directoryEntries.Add(entry.TableName, entry);
            }
        }
Esempio n. 4
0
 /// <summary>
 ///     Class constructor.
 /// </summary>
 /// <param name="entry"></param>
 public KerningTable(DirectoryEntry entry)
     : base(TableNames.Kern, entry) {}
Esempio n. 5
0
 /// <summary>
 ///     Class constructor.
 /// </summary>
 /// <param name="entry"></param>
 public PostTable(DirectoryEntry entry) : base(TableNames.Post, entry) {}
Esempio n. 6
0
 /// <summary>
 ///     Class constructor
 /// </summary>
 /// <param name="tableName">The table name.</param>
 /// <param name="entry">Table directory entry.</param>
 public FontTable(string tableName, DirectoryEntry entry) {
     this.directoryEntry = entry;
 }
Esempio n. 7
0
 /// <summary>
 ///     Class constructor.
 /// </summary>
 /// <param name="entry"></param>
 public HeaderTable(DirectoryEntry entry)
     : base(TableNames.Head, entry) {}
Esempio n. 8
0
 /// <summary>
 ///     Class constructor.
 /// </summary>
 /// <param name="entry"></param>
 public HorizontalHeaderTable(DirectoryEntry entry) : base(TableNames.Hhea, entry) {}
Esempio n. 9
0
 /// <summary>
 ///     Initialises a new instance of the 
 ///     <see cref="IndexToLocationTable"/> class.
 /// </summary>
 /// <param name="entry"></param>
 public IndexToLocationTable(DirectoryEntry entry)
     : base(TableNames.Loca, entry) {}
Esempio n. 10
0
 /// <summary>
 ///     Initialises a new instance of the HorizontalMetricsTable class.
 /// </summary>
 /// <param name="entry"></param>
 public HorizontalMetricsTable(DirectoryEntry entry, int numMetrics)
     : base(TableNames.Hmtx, entry) {
     this.metrics = new ArrayList(numMetrics);
 }
Esempio n. 11
0
 /// <summary>
 ///     Initialises a new instance of the 
 ///     <see cref="HorizontalMetricsTable"/> class.
 /// </summary>
 /// <param name="entry"></param>
 public HorizontalMetricsTable(DirectoryEntry entry)
     : base(TableNames.Hmtx, entry) {}
Esempio n. 12
0
 /// <summary>
 ///     Creates an instance of the <see cref="GlyfDataTable"/> class.
 /// </summary>
 /// <param name="entry"></param>
 public GlyfDataTable(DirectoryEntry entry) : base(TableNames.Glyf, entry) {
     this.glyphDescriptions = new SortedList();
 }
Esempio n. 13
0
 public NameTable(DirectoryEntry entry)
     : base(TableNames.Name, entry) {}
Esempio n. 14
0
 public OS2Table(DirectoryEntry entry) : base(TableNames.Os2, entry) {}
Esempio n. 15
0
 /// <summary>
 ///     Initialises a new instance of the IndexToLocationTable class.
 /// </summary>
 /// <param name="entry"></param>
 public IndexToLocationTable(DirectoryEntry entry, int numOffsets)
     : base(TableNames.Loca, entry) {
     this.offsets = new ArrayList(numOffsets);
 }
Esempio n. 16
0
 /// <summary>
 ///     Sets the stream position to the offset in the supplied directory
 ///     entry. Also ensures that the FontFileStream has enough bytes 
 ///     available to read a font table.  Throws an exception if this 
 ///     condition is not met.
 /// </summary>
 /// <param name="entry"></param>
 /// <exception cref="ArgumentException">
 ///     If the supplied stream does not contain enough data.
 /// </exception>
 private void OffsetStream(DirectoryEntry entry) {
     stream.Position = entry.Offset;
     if ((stream.Position + entry.Length) > stream.Length) {
         string msg = String.Format(
             "Error reading table '{0}'.  Expected {1} bytes, current position {2}, stream length {3}",
             entry.TableName, entry.Length, stream.Position, stream.Length);
         throw new ArgumentException(msg);
     }
 }
Esempio n. 17
0
 /// <summary>
 ///     Initialises a new instance of the <see cref="MaximumProfileTable"/>
 ///     class.
 /// </summary>
 /// <param name="entry"></param>
 public MaximumProfileTable(DirectoryEntry entry) : base(TableNames.Maxp, entry) {}