internal GdiFontMetrics(GdiDeviceContent dc, GdiFont currentFont)
        {
            if (dc.Handle == IntPtr.Zero)
            {
                throw new ArgumentNullException("dc", "Handle to device context cannot be null");
            }
            if (dc.GetCurrentObject(GdiDcObject.Font) == IntPtr.Zero)
            {
                throw new ArgumentException("dc", "No font selected into supplied device context");
            }
            this.dc          = dc;
            this.currentFont = currentFont;

            // FontFileReader requires the font facename because the font may exist in
            // a TrueType collection.
            StringBuilder builder = new StringBuilder(255);

            LibWrapper.GetTextFace(dc.Handle, builder.Capacity, builder);
            faceName = builder.ToString();

            ranges    = new GdiUnicodeRanges(dc);
            reader    = new FontFileReader(new MemoryStream(GetFontData()), faceName);
            converter = new PdfUnitConverter(EmSquare);

            // After we have cached the font data, we can safely delete the resource
            currentFont.Dispose();
        }
示例#2
0
 /// <summary>
 ///     Reads the contents of the "cvt" table from the current position
 ///     in the supplied stream.
 /// </summary>
 /// <param name="reader"></param>
 protected internal override void Read(FontFileReader reader)
 {
     values = new short[Entry.Length / PrimitiveSizes.FWord];
     for (int i = 0; i < values.Length; i++)
     {
         values[i] = reader.Stream.ReadFWord();
     }
 }
 /// <summary>
 ///     Reads the contents of the "fpgm" table from the current position
 ///     in the supplied stream.
 /// </summary>
 /// <param name="reader"></param>
 protected internal override void Read(FontFileReader reader)
 {
     instructions = new byte[Entry.Length];
     reader.Stream.Read(instructions, 0, instructions.Length);
 }
示例#4
0
 public GlyphReader(FontFileReader reader)
 {
     this.reader    = reader;
     this.glyfEntry = reader.GetDictionaryEntry(TableNames.Glyf);
     this.loca      = reader.GetIndexToLocationTable();
 }
示例#5
0
 /// <summary>
 ///     Reads the contents of the "cvt" table from the current position 
 ///     in the supplied stream.
 /// </summary>
 /// <param name="reader"></param>
 protected internal override void Read(FontFileReader reader) {
     values = new short[Entry.Length/PrimitiveSizes.FWord];
     for (int i = 0; i < values.Length; i++) {
         values[i] = reader.Stream.ReadFWord();
     }
 }
示例#6
0
 public GlyphReader(FontFileReader reader) {
     this.reader = reader;
     this.glyfEntry = reader.GetDictionaryEntry(TableNames.Glyf);
     this.loca = reader.GetIndexToLocationTable();
 }
示例#7
0
 /// <summary>
 ///     Reads the contents of the "fpgm" table from the current position 
 ///     in the supplied stream.
 /// </summary>
 /// <param name="reader"></param>
 protected internal override void Read(FontFileReader reader) {
     instructions = new byte[Entry.Length];
     reader.Stream.Read(instructions, 0, instructions.Length);
 }