如题,在拉伸、扭曲label控件时,怎么才能让字体随着一起变形?

解决方案 »

  1.   

    how to twist label control?? 
      

  2.   

    LZ说的“拉伸、扭曲label控件”,应该是指设计的时候吧,运行的时候好像没法拉伸的。
    这个思路不知道行不行……
    先把AutoSize改成false,然后在InitializeComponent()里写一行:
    this.Font.Size = f( this.Height, this.Width );
    比如
    this.Font.Size = 0.5 * this.Height
      

  3.   

    不是设计的时候,是在程序运行的时候。控件的拉伸等操作我已经实现了。只是text内容不会跟着控件变化而变化。希望大家帮忙
      

  4.   

    处理Label的SizeChanged事件,或者继承Label,重写SizeChanged事件
      

  5.   

    maybe you need draw text by yourself, before draw text using Graphics.MultiplyTransform ..
      

  6.   

    我用了9楼haiwangstar兄弟的方法。并且使用了以下方法重绘(在label拉伸的时候发生):
                Font stringFont = new Font(this.Font.FontFamily, this.Height - 3);
                SizeF stringSize = new SizeF();
                stringSize = this.CreateGraphics().MeasureString(this.Text, stringFont);
                GraphicsPath path = new GraphicsPath();
                path.AddString(this.Text, stringFont.FontFamily, (int)FontStyle.Regular, stringFont.Size, new Point(0, 0), new StringFormat());
                PointF[] dataPoints = path.PathPoints;
                byte[] pTypes = path.PathTypes;
                Matrix matrix = new Matrix(this.Width / stringSize.Width, 0.0f, 0.0f, 1f, 0.0f, 0.0f);
                matrix.TransformPoints(dataPoints);
                GraphicsPath newpath = new GraphicsPath(dataPoints, pTypes);
                e.Graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
                //e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;(注释掉这一句后,拉伸的情况下字体看不清楚)
                SolidBrush brush = new SolidBrush(this.ForeColor);
                e.Graphics.FillPath(brush, newpath);
                brush.Dispose();
                stringFont.Dispose();
                path.Dispose();
                matrix.Dispose();
    结果是重绘后的字体比较模糊,特别是字体小的时候。不知道大家重绘的时候是不是也这样?vs本身控件的绘制怎么就那么清晰呢?