graphics 的DrawText 与graphicspath 的addstring的区别

 graphicspath 的addstring() 表示向此路径添加文本字符串。

然后用graphics的Drawpath()生成字体,发现是空心的。而用graphics的fillpath()生成的字体是实心的。

而这两个生成的字体不如用drawtext生成的字体看着好。必竟前者相当于填充画图。

            Pen pen = new Pen(Color);
            Brush b = new SolidBrush(Color);
            StringFormat sf = new StringFormat();
            sf.Trimming = StringTrimming.Word;


            GraphicsPath gp = new GraphicsPath();

            //gp.AddString(_theText, _font.FontFamily, (int)_font.Style, _font.SizeInPoints,
            // new PointF(Rectangle.X, Rectangle.Y), StringFormat.GenericDefault);
            gp.AddString(_theText, _font.FontFamily, (int)_font.Style, _font.SizeInPoints,
                       new RectangleF(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height), sf);


            // Rotate the path about it's center if necessary

            if (Rotation != 0)
            {
                RectangleF pathBounds = gp.GetBounds();
                Matrix m = new Matrix();
                m.RotateAt(Rotation, new PointF(pathBounds.Left + (pathBounds.Width / 2), pathBounds.Top + (pathBounds.Height / 2)),
                           MatrixOrder.Append);
                // gp.Transform(m);
               g.Transform = m;
            }

          

            //g.DrawString(_theText, _font, b, new PointF(Rectangle.X, Rectangle.Y),sf);
            g.DrawString(_theText, _font, b, new RectangleF(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height), sf);

           // g.DrawPath(pen, gp);
          //  g.FillPath(b, gp);
            // rectangle.Size = g.MeasureString(_theText, _font).ToSize();

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值