/// <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);
 }
Exemplo n.º 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);
 }
        /// <summary>
        /// Compiles the font to its binary representation.
        /// </summary>
        void Compile()
        {
            MemoryStream       stream = new MemoryStream();
            OpenTypeFontWriter writer = new OpenTypeFontWriter(stream);

            int tableCount = TableDictionary.Count;
            int selector   = _entrySelectors[tableCount];

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

            // Sort tables by tag name
            string[] tags = new string[tableCount];
            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 = 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;
            FontSource = XFontSource.CreateCompiledFont(stream.ToArray());
        }
Exemplo n.º 4
0
 /// <summary>
 /// Converts the font into its binary representation.
 /// </summary>
 public override void Write(OpenTypeFontWriter writer)
 {
     writer.Write(GlyphTable, 0, DirectoryEntry.PaddedLength);
 }
 /// <summary>
 /// When overridden in a derived class, converts the font into its binary representation.
 /// </summary>
 public virtual void Write(OpenTypeFontWriter writer)
 {
 }
Exemplo n.º 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>
 /// Converts the font into its binary representation.
 /// </summary>
 public override void Write(OpenTypeFontWriter writer)
 {
     writer.Write(_bytes, 0, DirectoryEntry.PaddedLength);
 }