winform font字体编程续

//学习同种字形以不同磅值在不同行显示的多种效果
        const string fontstr = "Times New Roman";//time new roman字形
        public keytest()
        {
            //学习字体类FONT的相关属性 这可以查出当前窗体的字体及fontfamily,用于程序其它地方
            string str1 = Font.Name;
            string str2=Font.FontFamily.ToString();
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            Brush br = new SolidBrush(Color.Blue);
            float y = 0;//不同行,故x坐标是一样的,仅变换y坐标即可,由font.getheight(graphics)计算而来
            //字体磅值以1/4递增自6磅到最大12磅
            for (float fontsize = 6; fontsize <= 12;fontsize+=0.25f)
            {
                //drawstring输出受graphics.scaletransform的影响
                e.Graphics.ScaleTransform(0.5f, 0.5f);//graphics.scaletransform(x,y)图形在X,Y坐标上放大或缩小的比例,比如2就是扩大一倍,原来是1吗
                e.Graphics.DrawString(fontstr, new Font(fontstr, fontsize), br, 0, y);
                y += Font.GetHeight(e.Graphics);//这样就会在不同行显示同样的文字了
            }

            Font f = new Font(FontFamily.GenericSansSerif, 10, GraphicsUnit.Document);//字体构造另一种函数,参数graphicsunit


            
        }
请使用浏览器的分享功能分享到微信等