コード例 #1
0
ファイル: GdiFont.cs プロジェクト: nholik/Fo.Net
        /// <summary>
        ///     Creates a font based on the supplied typeface name and size.
        /// </summary>
        /// <param name="faceName">The typeface name of a font.</param>
        /// <param name="height">
        ///     The height, in logical units, of the font's character 
        ///     cell or character.
        /// </param>
        /// <returns></returns>
        public static GdiFont CreateFont(string faceName, int height, bool bold, bool italic) {
            LogFont lf = new LogFont();
            lf.lfCharSet = 1; // Default charset
            lf.lfFaceName = faceName;
            lf.lfHeight = height;
            lf.lfWeight = (bold) ? 700 : 0;
            lf.lfItalic = Convert.ToByte(italic);

            return new GdiFont(LibWrapper.CreateFontIndirect(lf), faceName, height);
        }