Example #1
0
        /// <summary>
        /// Loads the specified reader.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <param name="index">The index.</param>
        /// <returns></returns>
        public static OpenTypeFont Load(OpenTypeFontReader reader, int index)
        {
            if (reader == null)
            {
                throw new PdfArgumentNullException("reader");
            }
            long position = reader.Position;

            if (reader.ReadLONG() == 0x74746366)
            {
                reader.ReadFixed();
                long num3 = reader.ReadULONG();
                if ((index < 0) || (index >= num3))
                {
                    throw new PdfReadFontException("index must be bigger than 0 and less than " + ((long)num3) + ".");
                }
                reader.Skip((long)(4 * index));
                long pos = reader.ReadULONG();
                reader.Seek(pos);
            }
            else
            {
                reader.Seek(position);
            }
            return(new OpenTypeFont(reader));
        }
Example #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:OpenTypeFontTable" /> class.
 /// </summary>
 /// <param name="tag">The tag.</param>
 /// <param name="checkSum">The check sum.</param>
 /// <param name="offset">The offset.</param>
 /// <param name="length">The length.</param>
 /// <param name="reader">The reader.</param>
 public OpenTypeFontTable(string tag, long checkSum, long offset, long length, OpenTypeFontReader reader)
 {
     this.tag      = tag;
     this.checkSum = checkSum;
     this.offset   = offset;
     this.length   = length;
     this.reader   = reader;
 }
Example #3
0
 /// <summary>
 /// Checks the reader.
 /// </summary>
 protected void CheckReader()
 {
     if (!this.isReaderCloned)
     {
         this.reader         = this.reader.GetTableReader(this.tag, this.offset, this.length);
         this.isReaderCloned = true;
     }
 }
Example #4
0
 /// <summary>
 /// Writes the specified reader.
 /// </summary>
 /// <param name="reader">The reader.</param>
 public void Write(OpenTypeFontReader reader)
 {
     if (reader == null)
     {
         throw new PdfArgumentNullException("reader");
     }
     this.stm.Write(reader.ToArray(), 0, (int)reader.Length);
 }
Example #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:OpenTypeFont" /> class.
 /// </summary>
 /// <param name="reader">The reader.</param>
 private OpenTypeFont(OpenTypeFontReader reader)
 {
     if (reader == null)
     {
         throw new PdfArgumentNullException("reader");
     }
     this.reader = reader;
     this.InitFontTables();
 }
Example #6
0
 /// <summary>
 /// Loads the specified reader.
 /// </summary>
 /// <param name="reader">The reader.</param>
 /// <returns></returns>
 public static OpenTypeFont Load(OpenTypeFontReader reader)
 {
     return(Load(reader, 0));
 }
Example #7
0
        /// <summary>
        /// Gets the sub font.
        /// </summary>
        /// <param name="chars">The chars.</param>
        /// <param name="isCFF">if set to <c>true</c> [is CFF].</param>
        /// <returns></returns>
        public override byte[] GetSubFont(Dictionary <char, int> chars, out bool isCFF)
        {
            if (this.IsCFF)
            {
                isCFF = true;
                OpenTypeFontReader reader = this.tables["CFF "].Reader;
                reader.Seek(0L);
                return(reader.ReadBytes((int)reader.Length));
            }
            isCFF = false;
            if (!base.isSubSet)
            {
                return(this.reader.ToArray());
            }
            List <string> list = new List <string> {
                "head", "glyf", "loca"
            };

            if (base.encoding == "WinAnsiEncoding")
            {
                list.Add("cmap");
            }
            list.Add("hhea");
            list.Add("maxp");
            list.Add("hmtx");
            list.Add("cvt ");
            list.Add("fpgm");
            list.Add("prep");
            if (!base.isSubSet)
            {
                list.Add("OS/2");
                if (!list.Contains("cmap"))
                {
                    list.Add("cmap");
                }
                list.Add("name");
            }
            OpenTypeFontWriter writer = new OpenTypeFontWriter();
            int i    = 0;
            int num2 = 0;
            int num3 = 1;

            foreach (string str in list)
            {
                if (this.tables.ContainsKey(str))
                {
                    i++;
                }
            }
            for (int j = 0; j < 0x20; j++)
            {
                if (num3 > i)
                {
                    break;
                }
                num3 = num3 << 1;
                num2++;
            }
            num2--;
            int num5 = (num3 / 2) * 0x10;
            int num6 = (i * 0x10) - num5;

            writer.WriteFixed(1f);
            writer.WriteSHORT(i);
            writer.WriteSHORT(num5);
            writer.WriteSHORT(num2);
            writer.WriteSHORT(num6);
            long position = writer.Position;

            writer.WriteBytes((int)(i * 0x10));
            List <OpenTypeFontTable> list2 = new List <OpenTypeFontTable>();

            foreach (string str2 in list)
            {
                if (this.tables.ContainsKey(str2))
                {
                    OpenTypeFontTable subset = this.tables[str2].GetSubset(chars);
                    long num8 = writer.Position;
                    writer.Write(subset.Reader);
                    list2.Add(subset);
                    subset.Offset = num8;
                }
            }
            writer.Seek(position);
            foreach (OpenTypeFontTable table2 in list2)
            {
                writer.WriteString(table2.Tag);
                writer.WriteLONG(table2.CheckSum);
                writer.WriteLONG(table2.Offset);
                writer.WriteLONG(table2.Length);
            }
            return(writer.ToArray());
        }
Example #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:HorizontalMetricsTable" /> class.
 /// </summary>
 /// <param name="tag">The tag.</param>
 /// <param name="checkSum">The check sum.</param>
 /// <param name="offset">The offset.</param>
 /// <param name="length">The length.</param>
 /// <param name="reader">The reader.</param>
 public HorizontalMetricsTable(string tag, long checkSum, long offset, long length, OpenTypeFontReader reader) : base(tag, checkSum, offset, length, reader)
 {
     this.widths = new Dictionary <int, float>();
 }
Example #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:PostScriptTable" /> class.
 /// </summary>
 /// <param name="tag">The tag.</param>
 /// <param name="checkSum">The check sum.</param>
 /// <param name="offset">The offset.</param>
 /// <param name="length">The length.</param>
 /// <param name="reader">The reader.</param>
 public PostScriptTable(string tag, long checkSum, long offset, long length, OpenTypeFontReader reader) : base(tag, checkSum, offset, length, reader)
 {
     base.Load();
 }
Example #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:NameTable" /> class.
 /// </summary>
 /// <param name="tag">The tag.</param>
 /// <param name="checkSum">The check sum.</param>
 /// <param name="offset">The offset.</param>
 /// <param name="length">The length.</param>
 /// <param name="reader">The reader.</param>
 public NameTable(string tag, long checkSum, long offset, long length, OpenTypeFontReader reader) : base(tag, checkSum, offset, length, reader)
 {
     this.names    = new Dictionary <int, string>();
     this.uniNames = new Dictionary <int, string>();
     base.Load();
 }
Example #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:HorizontalHeaderTable" /> class.
 /// </summary>
 /// <param name="tag">The tag.</param>
 /// <param name="checkSum">The check sum.</param>
 /// <param name="offset">The offset.</param>
 /// <param name="length">The length.</param>
 /// <param name="reader">The reader.</param>
 public HorizontalHeaderTable(string tag, long checkSum, long offset, long length, OpenTypeFontReader reader) : base(tag, checkSum, offset, length, reader)
 {
     base.Load();
 }
Example #12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:CMapTable" /> class.
 /// </summary>
 /// <param name="tag">The tag.</param>
 /// <param name="checkSum">The check sum.</param>
 /// <param name="offset">The offset.</param>
 /// <param name="length">The length.</param>
 /// <param name="reader">The reader.</param>
 public CMapTable(string tag, long checkSum, long offset, long length, OpenTypeFontReader reader) : base(tag, checkSum, offset, length, reader)
 {
 }
Example #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:LocationTable" /> class.
 /// </summary>
 /// <param name="tag">The tag.</param>
 /// <param name="checkSum">The check sum.</param>
 /// <param name="offset">The offset.</param>
 /// <param name="length">The length.</param>
 /// <param name="reader">The reader.</param>
 public LocationTable(string tag, long checkSum, long offset, long length, OpenTypeFontReader reader) : base(tag, checkSum, offset, length, reader)
 {
     this.locaTable = new List <int>();
 }