Beispiel #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;
        }
Beispiel #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;
        }
Beispiel #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);
            }
        }
Beispiel #4
0
 /// <summary>
 ///     Class constructor.
 /// </summary>
 /// <param name="entry"></param>
 public KerningTable(DirectoryEntry entry)
     : base(TableNames.Kern, entry) {}
Beispiel #5
0
 /// <summary>
 ///     Class constructor.
 /// </summary>
 /// <param name="entry"></param>
 public PostTable(DirectoryEntry entry) : base(TableNames.Post, entry) {}
Beispiel #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;
 }
Beispiel #7
0
 /// <summary>
 ///     Class constructor.
 /// </summary>
 /// <param name="entry"></param>
 public HeaderTable(DirectoryEntry entry)
     : base(TableNames.Head, entry) {}
Beispiel #8
0
 /// <summary>
 ///     Class constructor.
 /// </summary>
 /// <param name="entry"></param>
 public HorizontalHeaderTable(DirectoryEntry entry) : base(TableNames.Hhea, entry) {}
Beispiel #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) {}
Beispiel #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);
 }
Beispiel #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) {}
Beispiel #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();
 }
Beispiel #13
0
 public NameTable(DirectoryEntry entry)
     : base(TableNames.Name, entry) {}
Beispiel #14
0
 public OS2Table(DirectoryEntry entry) : base(TableNames.Os2, entry) {}
Beispiel #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);
 }
Beispiel #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);
     }
 }
Beispiel #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) {}