【发布时间】:2013-03-07 06:29:43
【问题描述】:
我的表单中有一个文本框,我正在向其中绘制一个字符串,如下所示。
Font myFont = new Font("Arial",18F,FontStyle.Regular,GraphicsUnit.Point,128);
Graphics g = myTextBox.CreateGraphics();
Brush b = new SolidBrush(Color.Red);
g.DrawString("Item Drawn with DrawString",myFont ,b,new PointF(1,1));
文本框中显示的字符串。然后我尝试了下面的代码
Font myFont = new Font("Arial",18F,FontStyle.Regular,GraphicsUnit.Point,128);
Graphics g = myTextBox.CreateGraphics();
TextRenderer.DrawText(g,"Item Drawn with DrawText",myFont,new Point(1,1),Color.Red);
问题来了。尽管g.DrawString() 和TextRenderer.DrawText() 两种方法使用相同的字体,但字体样式存在差异。那就是某些字符的呈现方式不同。如果我在字体中使用“1”而不是“128”,这两种方法都会将字符呈现为唯一的。
如果我更改字体中的GdiCharSet(128) 值,而使用g.DrawString() 方法将没有效果。我的问题是为什么g.DrawString() 方法不包括GdiCharSet 值?
【问题讨论】:
标签: c# fonts textbox customization