Represents a TrueType font in memory.
Ejemplo n.º 1
0
        byte[] bytes; // Instructions. n is the number of BYTE items that fit in the size of the table.

        public FontProgram(FontData fontData)
            : base(fontData, Tag)
        {
            DirectoryEntry.Tag = TableTagNames.Fpgm;
            DirectoryEntry     = fontData.tableDictionary[TableTagNames.Fpgm];
            Read();
        }
Ejemplo n.º 2
0
        public static void Test()
        {
            Font     font  = new Font("Times New Roman", 10);
            FontData image = new FontData(font);

//      Font font = new Font("Isabelle", 12);
//      LOGFONT logFont = new LOGFONT();
//      font.ToLogFont(logFont);
//
//      IntPtr hfont = CreateFontIndirect(logFont);
////      IntPtr hfont2 = font.ToHfont();
////      System.Windows.Forms.MessageBox.Show(hfont2.ToString());
//
//      Graphics gfx = Graphics.FromHwnd(IntPtr.Zero);
//      IntPtr hdc = gfx.GetHdc();
//      IntPtr oldFont =  SelectObject(hdc, hfont);
//      int size = GetFontData(hdc, 0, 0, null, 0);
//
//      byte[] fontbits = new byte[size];
//      int xx = GetFontData(hdc, 0, 0, fontbits, size);
//      SelectObject(hdc, oldFont);
//      DeleteObject(hfont);
//      gfx.ReleaseHdc(hdc);
//
//      FontData image = new FontData(fontbits);
//      //image.Read();
//
//
//      //HandleRef
//
//      font.GetType();
        }
Ejemplo n.º 3
0
        byte[] bytes; // Set of instructions executed whenever point size or font or transformation change. n is the number of BYTE items that fit in the size of the table.

        public ControlValueProgram(FontData fontData)
            : base(fontData, Tag)
        {
            DirectoryEntry.Tag = TableTagNames.Prep;
            DirectoryEntry     = fontData.tableDictionary[TableTagNames.Prep];
            Read();
        }
Ejemplo n.º 4
0
        FWord[] array; // List of n values referenceable by instructions. n is the number of FWORD items that fit in the size of the table.

        public ControlValueTable(FontData fontData)
            : base(fontData, Tag)
        {
            DirectoryEntry.Tag = TableTagNames.Cvt;
            DirectoryEntry     = fontData.tableDictionary[TableTagNames.Cvt];
            Read();
        }
Ejemplo n.º 5
0
 public GlyphSubstitutionTable(FontData fontData)
     : base(fontData, Tag)
 {
     DirectoryEntry.Tag = TableTagNames.GSUB;
     DirectoryEntry     = fontData.tableDictionary[TableTagNames.GSUB];
     Read();
 }
Ejemplo n.º 6
0
    ///// <summary>
    ///// Initializes a new instance of the <see cref="TrueTypeFontTable"/> class.
    ///// </summary>
    //public TrueTypeFontTable(FontData fontData)
    //{
    //  this.fontData = fontData;
    //}

    public TrueTypeFontTable(FontData fontData, string tag)
    {
      this.fontData = fontData;
      if (fontData != null && fontData.tableDictionary.ContainsKey(tag))
        this.DirectoryEntry = fontData.tableDictionary[tag];
      else
        this.DirectoryEntry = new TableDirectoryEntry(tag);
      this.DirectoryEntry.FontTable = this;
    }
Ejemplo n.º 7
0
        /// <summary>
        /// Creates and reads a TableDirectoryEntry from the font image.
        /// </summary>
        public static TableDirectoryEntry ReadFrom(FontData fontData)
        {
            TableDirectoryEntry entry = new TableDirectoryEntry();

            entry.Tag      = fontData.ReadTag();
            entry.CheckSum = fontData.ReadULong();
            entry.Offset   = fontData.ReadLong();
            entry.Length   = (int)fontData.ReadULong();
            return(entry);
        }
Ejemplo n.º 8
0
        ///// <summary>
        ///// Initializes a new instance of the <see cref="TrueTypeFontTable"/> class.
        ///// </summary>
        //public TrueTypeFontTable(FontData fontData)
        //{
        //  this.fontData = fontData;
        //}

        public TrueTypeFontTable(FontData fontData, string tag)
        {
            this.fontData = fontData;
            if (fontData != null && fontData.tableDictionary.ContainsKey(tag))
            {
                this.DirectoryEntry = fontData.tableDictionary[tag];
            }
            else
            {
                this.DirectoryEntry = new TableDirectoryEntry(tag);
            }
            this.DirectoryEntry.FontTable = this;
        }
Ejemplo n.º 9
0
 /// <summary>
 /// This is an external helper function.
 /// </summary>
 public static byte[] F74167FFE4044F53B28A4AF049E9EF25(XFont font, XPdfFontOptions options, bool subset)
 {
     byte[] data = null;
     if (subset)
     {
         TrueTypeDescriptor descriptor = new TrueTypeDescriptor(font, options, null);
         FontData           image      = descriptor.fontData;
         CMapInfo           cmapInfo   = new CMapInfo(descriptor);
         cmapInfo.AddAnsiChars();
         image = image.CreateFontSubSet(cmapInfo.GlyphIndices, false);
         data  = image.Data;
     }
     else
     {
         FontData fontData = new FontData(font, options);
         data = fontData.Data;
     }
     return(data);
 }
Ejemplo n.º 10
0
 /// <summary>
 /// This is an external helper function.
 /// </summary>
 public static byte[] F74167FFE4044F53B28A4AF049E9EF25(XFont font, XPdfFontOptions options, bool subset)
 {
   byte[] data = null;
   if (subset)
   {
     TrueTypeDescriptor descriptor = new TrueTypeDescriptor(font, options, null);
     FontData image = descriptor.fontData;
     CMapInfo cmapInfo = new CMapInfo(descriptor);
     cmapInfo.AddAnsiChars();
     image = image.CreateFontSubSet(cmapInfo.GlyphIndices, false);
     data = image.Data;
   }
   else
   {
     FontData fontData = new FontData(font, options);
     data = fontData.Data;
   }
   return data;
 }
Ejemplo n.º 11
0
 public IRefFontTable(FontData fontData, TrueTypeFontTable fontTable)
   : base(null, fontTable.DirectoryEntry.Tag)
 {
   this.fontData = fontData;
   this.irefDirectoryEntry = fontTable.DirectoryEntry;
 }
Ejemplo n.º 12
0
    public static void Test()
    {
      Font font = new Font("Times New Roman", 10);
      FontData image = new FontData(font);

//      Font font = new Font("Isabelle", 12);
//      LOGFONT logFont = new LOGFONT();
//      font.ToLogFont(logFont);
//
//      IntPtr hfont = CreateFontIndirect(logFont);
////      IntPtr hfont2 = font.ToHfont();
////      System.Windows.Forms.MessageBox.Show(hfont2.ToString());
//
//      Graphics gfx = Graphics.FromHwnd(IntPtr.Zero);
//      IntPtr hdc = gfx.GetHdc();
//      IntPtr oldFont =  SelectObject(hdc, hfont);
//      int size = GetFontData(hdc, 0, 0, null, 0);
//
//      byte[] fontbits = new byte[size];
//      int xx = GetFontData(hdc, 0, 0, fontbits, size);
//      SelectObject(hdc, oldFont);
//      DeleteObject(hfont);
//      gfx.ReleaseHdc(hdc);
//
//      FontData image = new FontData(fontbits);
//      //image.Read();
//
//
//      //HandleRef
//
//      font.GetType();
    }
Ejemplo n.º 13
0
 public HorizontalHeaderTable(FontData fontData)
     : base(fontData, Tag)
 {
     Read();
 }
Ejemplo n.º 14
0
 public OS2Table(FontData fontData)
     : base(fontData, Tag)
 {
     Read();
 }
Ejemplo n.º 15
0
 public GlyphDataTable(FontData fontData)
     : base(fontData, Tag)
 {
     DirectoryEntry.Tag = TableTagNames.Glyf;
     Read();
 }
Ejemplo n.º 16
0
 public GenericFontTable(FontData fontData, string tag)
     : base(fontData, tag)
 {
     this.fontData = fontData;
 }
Ejemplo n.º 17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CMapTable"/> class.
 /// </summary>
 public CMapTable(FontData fontData)
     : base(fontData, Tag)
 {
     Read();
 }
Ejemplo n.º 18
0
        /// <summary>
        /// Creates a new font image that is a subset of this font image containing only the specified glyphs.
        /// </summary>
        public FontData CreateFontSubSet(Dictionary <int, object> glyphs, bool cidFont)
        {
            // Create new font image
            FontData fontData = new FontData(this);

            // Create new loca and glyf table
            IndexToLocationTable loca = new IndexToLocationTable();

            loca.ShortIndex = this.loca.ShortIndex;
            GlyphDataTable glyf = new GlyphDataTable();

            // Add all required tables
            //fontData.AddTable(this.os2);
            if (!cidFont)
            {
                fontData.AddTable(this.cmap);
            }
            if (this.cvt != null)
            {
                fontData.AddTable(this.cvt);
            }
            if (this.fpgm != null)
            {
                fontData.AddTable(this.fpgm);
            }
            fontData.AddTable(glyf);
            fontData.AddTable(this.head);
            fontData.AddTable(this.hhea);
            fontData.AddTable(this.hmtx);
            fontData.AddTable(loca);
            if (this.maxp != null)
            {
                fontData.AddTable(this.maxp);
            }
            //fontData.AddTable(this.name);
            if (this.prep != null)
            {
                fontData.AddTable(this.prep);
            }

            // Get closure of used glyphs
            this.glyf.CompleteGlyphClosure(glyphs);

            // Create a sorted array of all used glyphs
            int glyphCount = glyphs.Count;

            int[] glyphArray = new int[glyphCount];
            glyphs.Keys.CopyTo(glyphArray, 0);
            Array.Sort <int>(glyphArray);

            // Calculate new size of glyph table.
            int size = 0;

            for (int idx = 0; idx < glyphCount; idx++)
            {
                size += this.glyf.GetGlyphSize(glyphArray[idx]);
            }
            glyf.DirectoryEntry.Length = size;

            // Create new loca table
            int numGlyphs = this.maxp.numGlyphs;

            loca.locaTable = new int[numGlyphs + 1];

            // Create new glyf table
            glyf.glyphTable = new byte[glyf.DirectoryEntry.PaddedLength];

            // Fill new glyf and loca table
            int glyphOffset = 0;
            int glyphIndex  = 0;

            for (int idx = 0; idx < numGlyphs; idx++)
            {
                loca.locaTable[idx] = glyphOffset;
                if (glyphIndex < glyphCount && glyphArray[glyphIndex] == idx)
                {
                    glyphIndex++;
                    byte[] bytes  = this.glyf.GetGlyphData(idx);
                    int    length = bytes.Length;
                    if (length > 0)
                    {
                        Buffer.BlockCopy(bytes, 0, glyf.glyphTable, glyphOffset, length);
                        glyphOffset += length;
                    }
                }
            }
            loca.locaTable[numGlyphs] = glyphOffset;

            // Compile font tables into byte array
            fontData.Compile();

            return(fontData);
        }
Ejemplo n.º 19
0
 public GenericFontTable(FontData fontData, string tag)
   : base(fontData, tag)
 {
   this.fontData = fontData;
 }
Ejemplo n.º 20
0
 public MaximumProfileTable(FontData fontData)
     : base(fontData, Tag)
 {
     Read();
 }
Ejemplo n.º 21
0
        public ushort[] glyphIdArray;    // Glyph index array (arbitrary length)

        public CMap4(FontData fontData, WinEncodingId encodingId)
            : base(fontData, "----")
        {
            this.encodingId = encodingId;
            Read();
        }
Ejemplo n.º 22
0
 public NameTable(FontData fontData)
     : base(fontData, Tag)
 {
     Read();
 }
Ejemplo n.º 23
0
 public IndexToLocationTable(FontData fontData)
     : base(fontData, Tag)
 {
     DirectoryEntry = this.fontData.tableDictionary[TableTagNames.Loca];
     Read();
 }
Ejemplo n.º 24
0
 public HorizontalMetricsTable(FontData fontData)
     : base(fontData, Tag)
 {
     Read();
 }
Ejemplo n.º 25
0
        public short glyphDataFormat;  // 0 for current format

        public FontHeaderTable(FontData fontData)
            : base(fontData, Tag)
        {
            Read();
        }
Ejemplo n.º 26
0
 public IndexToLocationTable(FontData fontData)
   : base(fontData, Tag)
 {
   DirectoryEntry = this.fontData.tableDictionary[TableTagNames.Loca];
   Read();
 }
Ejemplo n.º 27
0
 public GlyphDataTable(FontData fontData)
   : base(fontData, Tag)
 {
   DirectoryEntry.Tag = TableTagNames.Glyf;
   Read();
 }
Ejemplo n.º 28
0
 public PostScriptTable(FontData fontData)
     : base(fontData, Tag)
 {
     Read();
 }
Ejemplo n.º 29
0
 public FontData(FontData fontData)
 {
     this.offsetTable = fontData.offsetTable;
 }
Ejemplo n.º 30
0
    /// <summary>
    /// Creates a new font image that is a subset of this font image containing only the specified glyphs.
    /// </summary>
    public FontData CreateFontSubSet(Dictionary<int, object> glyphs, bool cidFont)
    {
      // Create new font image
      FontData fontData = new FontData(this);

      // Create new loca and glyf table
      IndexToLocationTable loca = new IndexToLocationTable();
      loca.ShortIndex = this.loca.ShortIndex;
      GlyphDataTable glyf = new GlyphDataTable();

      // Add all required tables
      //fontData.AddTable(this.os2);
      if (!cidFont)
        fontData.AddTable(this.cmap);
      if (this.cvt != null)
        fontData.AddTable(this.cvt);
      if (this.fpgm != null)
        fontData.AddTable(this.fpgm);
      fontData.AddTable(glyf);
      fontData.AddTable(this.head);
      fontData.AddTable(this.hhea);
      fontData.AddTable(this.hmtx);
      fontData.AddTable(loca);
      if (this.maxp != null)
        fontData.AddTable(this.maxp);
      //fontData.AddTable(this.name);
      if (this.prep != null)
        fontData.AddTable(this.prep);

      // Get closure of used glyphs
      this.glyf.CompleteGlyphClosure(glyphs);

      // Create a sorted array of all used glyphs
      int glyphCount = glyphs.Count;
      int[] glyphArray = new int[glyphCount];
      glyphs.Keys.CopyTo(glyphArray, 0);
      Array.Sort<int>(glyphArray);

      // Calculate new size of glyph table.
      int size = 0;
      for (int idx = 0; idx < glyphCount; idx++)
        size += this.glyf.GetGlyphSize(glyphArray[idx]);
      glyf.DirectoryEntry.Length = size;

      // Create new loca table
      int numGlyphs = this.maxp.numGlyphs;
      loca.locaTable = new int[numGlyphs + 1];

      // Create new glyf table
      glyf.glyphTable = new byte[glyf.DirectoryEntry.PaddedLength];

      // Fill new glyf and loca table
      int glyphOffset = 0;
      int glyphIndex = 0;
      for (int idx = 0; idx < numGlyphs; idx++)
      {
        loca.locaTable[idx] = glyphOffset;
        if (glyphIndex < glyphCount && glyphArray[glyphIndex] == idx)
        {
          glyphIndex++;
          byte[] bytes = this.glyf.GetGlyphData(idx);
          int length = bytes.Length;
          if (length > 0)
          {
            Buffer.BlockCopy(bytes, 0, glyf.glyphTable, glyphOffset, length);
            glyphOffset += length;
          }
        }
      }
      loca.locaTable[numGlyphs] = glyphOffset;

      // Compile font tables into byte array
      fontData.Compile();

      return fontData;
    }
Ejemplo n.º 31
0
 public IRefFontTable(FontData fontData, TrueTypeFontTable fontTable)
     : base(null, fontTable.DirectoryEntry.Tag)
 {
     this.fontData           = fontData;
     this.irefDirectoryEntry = fontTable.DirectoryEntry;
 }
Ejemplo n.º 32
0
 public FontData(FontData fontData)
 {
   this.offsetTable = fontData.offsetTable;
 }