废话少说,看代码
- e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
- GraphicsPath gPath = new GraphicsPath();
- //GraphicsPath gPath2 = new GraphicsPath();
- gPath.AddString("我的字体", Font.FontFamily, 0, 20, new Point(100, 50), new StringFormat());
- e.Graphics.FillPath(new SolidBrush(Color.Blue), gPath);
- float scaleX = 1;
- float scaleY = 2f;
- RectangleF recF = gPath.GetBounds();
- //放大相应的倍数,并回到原字符串的启示位置。
- /*matrix放大了相应的x,y坐标。*/
- Matrix matrix = new Matrix(scaleX, 0, 0, scaleY, recF.X - recF.X * scaleX, recF.Y - recF.Y * scaleY);
- //matrix.Scale(2, 3, MatrixOrder.Append);
- gPath.Transform(matrix);
- e.Graphics.FillPath(new SolidBrush(Color.Red), gPath);
- ScaleExample(e);