Пример #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 = 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);

            // 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);
            }
            writer.Stream.Flush();
            int l = (int)writer.Stream.Length;
            FontSource = XFontSource.CreateCompiledFont(stream.ToArray());
        }
Пример #4
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);
 }
Пример #5
0
 /// <summary>
 /// Converts the font into its binary representation.
 /// </summary>
 public override void Write(OpenTypeFontWriter writer)
 {
     writer.Write(_bytes, 0, DirectoryEntry.PaddedLength);
 }
Пример #6
0
 /// <summary>
 /// When overridden in a derived class, converts the font into its binary representation.
 /// </summary>
 public virtual void Write(OpenTypeFontWriter writer)
 {
 }
Пример #7
0
 /// <summary>
 /// Converts the font into its binary representation.
 /// </summary>
 public override void Write(OpenTypeFontWriter writer)
 {
     writer.Write(GlyphTable, 0, DirectoryEntry.PaddedLength);
 }