CreateFont() public static method

Creates a font based on the supplied typeface name and size.
public static CreateFont ( string faceName, int height, bool bold, bool italic ) : GdiFont
faceName string The typeface name of a font.
height int /// The height, in logical units, of the font's character /// cell or character. ///
bold bool
italic bool
return GdiFont
Esempio n. 1
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));
        }
Esempio 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)
        {
            // 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));
        }