本人用的是.net framework 1.1版本。原先的MFC有CFont可以实现文字的倾斜绘制,就是说用一定角度写文字,但是这几天用GDI+我怎么找也找不到对应的函数,是不是GDI+不支持斜绘文字啊??
高手们,给个解决方案吧~~~~~

解决方案 »

  1.   

    System.Drawing.Graphicspublic Void DrawString(
            String s,
            Font font,               // FontStyle.Italic 就是斜体字
            Brush brush,
            PointF point)
      

  2.   

    使用Graphics.RotateTransform 方法,参数为你要旋转的角度,绘制完成后,再把Graphics的变换恢复为原来的值
      

  3.   

    同意楼上。在 .net 下要转变思路,不是改变字体,而是对 Graphics 作变换。Graphics g = this.CreateGraphics();
    g.RotateTransform(30f);
    g.DrawString("倾斜ABCabc", this.Font, SystemBrushes.WindowText, 10f, 10f);
    g.ResetTransform();
    g.Dispose();
    g = null;试试看。
      

  4.   

    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;
    using System.Data;
    using System.Drawing.Drawing2D;
    using System.Drawing.Text;namespace RotateText
    {
    /// <summary>
    /// Form1 的摘要说明。
    /// </summary>
    public class Form1 : System.Windows.Forms.Form
    {
    /// <summary>
    /// 必需的设计器变量。
    /// </summary>
    private System.ComponentModel.Container components = null; public Form1()
    {
    //
    // Windows 窗体设计器支持所必需的
    //
    InitializeComponent(); //
    // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
    //
    } /// <summary>
    /// 清理所有正在使用的资源。
    /// </summary>
    protected override void Dispose( bool disposing )
    {
    if( disposing )
    {
    if (components != null) 
    {
    components.Dispose();
    }
    }
    base.Dispose( disposing );
    } #region Windows 窗体设计器生成的代码
    /// <summary>
    /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    /// 此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {
    // 
    // Form1
    // 
    this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
    this.ClientSize = new System.Drawing.Size(292, 266);
    this.Name = "Form1";
    this.Text = "Form1";
    this.Paint += new System.Windows.Forms.PaintEventHandler(this.Form1_Paint); }
    #endregion /// <summary>
    /// 应用程序的主入口点。
    /// </summary>
    [STAThread]
    static void Main() 
    {
    Application.Run(new Form1());
    } private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
    {
    // 声明并初始化Graphics对象g
    Graphics g = e.Graphics;
    g.SmoothingMode = SmoothingMode.AntiAlias;
    string tempStr = "Hello,C#";//取得要显示的文字
    for(int i=0;i<361;i+=10){
    //将指定的平移添加到g的变换矩阵前
    g.TranslateTransform(150,150);
    // 将指定的旋转用于g的变换矩阵
    g.RotateTransform(i);
    // 定义自己的画刷
    Brush myBrush = Brushes.Blue;
    //显示旋转文字
    g.DrawString(tempStr,this.Font,myBrush,60,0);
    // 将g的全局变换矩阵重置为单位矩阵
    g.ResetTransform();
    }
      }
    }
    }
      

  5.   

                g.RotateTransform(90);
                g.DrawString("车载合格证", new Font("宋体", 20, FontStyle.Regular), Brushes.Black, 100, 300);
                g.ResetTransform();我这样怎么不旋转呢?