Dispose() public method

public Dispose ( ) : void
return void
Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Creates a font whose height is equal to the negative value
        ///     of the EM Square
        /// </summary>
        /// <param name="faceName">The typeface name of a font.</param>
        /// <returns></returns>
        public static GdiFont CreateDesignFont(string faceName, bool bold, bool italic, GdiDeviceContent dc)
        {
            GdiFont tempFont = GdiFont.CreateFont(faceName, 2048, bold, italic);

            dc.SelectFont(tempFont);
            GdiFontMetrics metrics = tempFont.GetMetrics(dc);

            tempFont.Dispose();

            return(CreateFont(faceName, -Math.Abs(metrics.EmSquare), bold, italic));
        }
Exemplo n.º 3
0
        /// <summary>
        ///     Creates a font whose height is equal to the negative value
        ///     of the EM Square
        /// </summary>
        /// <param name="faceName">The typeface name of a font.</param>
        /// <returns></returns>
        public static GdiFont CreateDesignFont(string faceName, bool bold, bool italic, GdiDeviceContent dc)
        {
            // TODO: Is there a simpler method of obtaining the em-sqaure?
            GdiFont tempFont = GdiFont.CreateFont(faceName, 2048, bold, italic);

            dc.SelectFont(tempFont);
            GdiFontMetrics metrics = tempFont.GetMetrics(dc);

            tempFont.Dispose();

            return(CreateFont(faceName, -Math.Abs(metrics.EmSquare), bold, italic));
        }
Exemplo n.º 4
0
        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();
        }