示例#1
0
 /// <summary>
 /// Writes the offset table.
 /// </summary>
 public void Write(OpenTypeFontWriter writer)
 {
     writer.WriteUInt(Version);
     writer.WriteShort(TableCount);
     writer.WriteUShort(SearchRange);
     writer.WriteUShort(EntrySelector);
     writer.WriteUShort(RangeShift);
 }
示例#2
0
 public void Write(OpenTypeFontWriter writer)
 {
     Debug.Assert(Tag.Length == 4);
     Debug.Assert(Offset != 0);
     Debug.Assert(Length != 0);
     writer.WriteTag(Tag);
     writer.WriteUInt(CheckSum);
     writer.WriteInt(Offset);
     writer.WriteUInt((uint)Length);
 }
示例#3
0
        /// <summary>
        /// Compiles the font to its binary representation.
        /// </summary>
        void Compile()
        {
            MemoryStream       stream = new MemoryStream();
            OpenTypeFontWriter writer = new OpenTypeFontWriter(stream);

            int tableCount = this.tableDictionary.Count;
            int selector   = entrySelectors[tableCount];

            this.offsetTable.Version       = 0x00010000;
            this.offsetTable.TableCount    = tableCount;
            this.offsetTable.SearchRange   = (ushort)((1 << selector) * 16);
            this.offsetTable.EntrySelector = (ushort)selector;
            this.offsetTable.RangeShift    = (ushort)((tableCount - (1 << selector)) * 16);
            this.offsetTable.Write(writer);

            // Sort tables by tag name
            string[] tags = new string[tableCount];
            this.tableDictionary.Keys.CopyTo(tags, 0);
            Array.Sort(tags, StringComparer.Ordinal);

#if VERBOSE
            Debug.WriteLine("Start Compile");
#endif
            // Write tables in alphabetical order
            int tablePosition = 12 + 16 * tableCount;
            for (int idx = 0; idx < tableCount; idx++)
            {
                TableDirectoryEntry entry = this.tableDictionary[tags[idx]];
#if DEBUG
                if (entry.Tag == "glyf" || entry.Tag == "loca")
                {
                    GetType();
                }
#endif
                entry.FontTable.PrepareForCompilation();
                entry.Offset    = tablePosition;
                writer.Position = tablePosition;
                entry.FontTable.Write(writer);
                int endPosition = writer.Position;
                tablePosition   = endPosition;
                writer.Position = 12 + 16 * idx;
                entry.Write(writer);
#if VERBOSE
                Debug.WriteLine(String.Format("  Write Table '{0}', offset={1}, length={2}, checksum={3}, ", entry.Tag, entry.Offset, entry.Length, entry.CheckSum));
#endif
            }
#if VERBOSE
            Debug.WriteLine("End Compile");
#endif
            writer.Stream.Flush();
            int l = (int)writer.Stream.Length;
            l.GetType();
            this.data = stream.ToArray();
        }
示例#4
0
 /// <summary>
 /// When overridden in a derived class, converts the font into its binary representation.
 /// </summary>
 public virtual void Write(OpenTypeFontWriter writer)
 {
 }
示例#5
0
 /// <summary>
 /// Converts the font into its binary representation.
 /// </summary>
 public override void Write(OpenTypeFontWriter writer)
 {
     writer.Write(this.glyphTable, 0, DirectoryEntry.PaddedLength);
 }
示例#6
0
 /// <summary>
 /// Converts the font into its binary representation.
 /// </summary>
 public override void Write(OpenTypeFontWriter writer)
 {
     writer.Write(_irefDirectoryEntry.FontTable._fontData.FontSource.Bytes, _irefDirectoryEntry.Offset, _irefDirectoryEntry.PaddedLength);
 }
 /// <summary>
 /// When overridden in a derived class, converts the font into its binary representation.
 /// </summary>
 public virtual void Write(OpenTypeFontWriter writer)
 {
 }
示例#8
0
 /// <summary>
 /// Converts the font into its binary representation.
 /// </summary>
 public override void Write(OpenTypeFontWriter writer)
 {
   writer.Write(this.irefDirectoryEntry.FontTable.fontData.Data, this.irefDirectoryEntry.Offset, this.irefDirectoryEntry.PaddedLength);
 }
 /// <summary>
 /// Converts the font into its binary representation.
 /// </summary>
 public override void Write(OpenTypeFontWriter writer)
 {
     writer.Write(_bytes, 0, DirectoryEntry.PaddedLength);
 }
 /// <summary>
 /// Converts the font into its binary representation.
 /// </summary>
 public override void Write(OpenTypeFontWriter writer)
 {
     writer.Write(this.irefDirectoryEntry.FontTable.fontData.Data, this.irefDirectoryEntry.Offset, this.irefDirectoryEntry.PaddedLength);
 }
示例#11
0
 public void Write(OpenTypeFontWriter writer)
 {
   Debug.Assert(this.Tag.Length == 4);
   Debug.Assert(this.Offset != 0);
   Debug.Assert(this.Length != 0);
   writer.WriteTag(this.Tag);
   writer.WriteUInt(this.CheckSum);
   writer.WriteInt(this.Offset);
   writer.WriteUInt((uint)this.Length);
 }
示例#12
0
 /// <summary>
 /// Converts the font into its binary representation.
 /// </summary>
 public override void Write(OpenTypeFontWriter writer)
 {
     writer.Write(_irefDirectoryEntry.FontTable._fontData.FontSource.Bytes, _irefDirectoryEntry.Offset, _irefDirectoryEntry.PaddedLength);
 }
示例#13
0
 /// <summary>
 /// Converts the font into its binary representation.
 /// </summary>
 public override void Write(OpenTypeFontWriter writer)
 {
   writer.Write(this.bytes, 0, DirectoryEntry.PaddedLength);
 }
示例#14
0
 /// <summary>
 /// Converts the font into its binary representation.
 /// </summary>
 public override void Write(OpenTypeFontWriter writer)
 {
     writer.Write(GlyphTable, 0, DirectoryEntry.PaddedLength);
 }
示例#15
0
 /// <summary>
 /// Writes the offset table.
 /// </summary>
 public void Write(OpenTypeFontWriter writer)
 {
   writer.WriteUInt(Version);
   writer.WriteShort(TableCount);
   writer.WriteUShort(SearchRange);
   writer.WriteUShort(EntrySelector);
   writer.WriteUShort(RangeShift);
 }
示例#16
0
    /// <summary>
    /// Compiles the font to its binary representation.
    /// </summary>
    void Compile()
    {
      MemoryStream stream = new MemoryStream();
      OpenTypeFontWriter writer = new OpenTypeFontWriter(stream);

      int tableCount = this.tableDictionary.Count;
      int selector = entrySelectors[tableCount];

      this.offsetTable.Version = 0x00010000;
      this.offsetTable.TableCount = tableCount;
      this.offsetTable.SearchRange = (ushort)((1 << selector) * 16);
      this.offsetTable.EntrySelector = (ushort)selector;
      this.offsetTable.RangeShift = (ushort)((tableCount - (1 << selector)) * 16);
      this.offsetTable.Write(writer);

      // Sort tables by tag name
      string[] tags = new string[tableCount];
      this.tableDictionary.Keys.CopyTo(tags, 0);
      Array.Sort(tags, StringComparer.Ordinal);

#if VERBOSE
      Debug.WriteLine("Start Compile");
#endif
      // Write tables in alphabetical order
      int tablePosition = 12 + 16 * tableCount;
      for (int idx = 0; idx < tableCount; idx++)
      {
        TableDirectoryEntry entry = this.tableDictionary[tags[idx]];
#if DEBUG
        if (entry.Tag == "glyf" || entry.Tag == "loca")
          GetType();
#endif
        entry.FontTable.PrepareForCompilation();
        entry.Offset = tablePosition;
        writer.Position = tablePosition;
        entry.FontTable.Write(writer);
        int endPosition = writer.Position;
        tablePosition = endPosition;
        writer.Position = 12 + 16 * idx;
        entry.Write(writer);
#if VERBOSE
        Debug.WriteLine(String.Format("  Write Table '{0}', offset={1}, length={2}, checksum={3}, ", entry.Tag, entry.Offset, entry.Length, entry.CheckSum));
#endif
      }
#if VERBOSE
      Debug.WriteLine("End Compile");
#endif
      writer.Stream.Flush();
      int l = (int)writer.Stream.Length;
      l.GetType();
      this.data = stream.ToArray();
    }