开发者

How to draw unicode string using C# graphics.DrawString

I'm trying to send khmer script(unicode) string to printer using PrintDocument provided by the .NET framework.

Unfortunately it seems to me that the Graphics.DrawString() does not render khmer script correctly.

Platform: Windows 7 Ultimate

IDE: VS 2010 Ultimate

Here is the sample code:

void printDoc_PrintPage(object sender, PrintPageEventArgs e)
{
  var font = new Font("Khmer UI", 12);
  var text = "សួស្តី"; // "Hello"
  e.Graphics.DrawString(text, f开发者_如何学Pythonont, Brushes.Black, 100, 100);
}


mann,
I tested your code on a Form_Paint() handler, and I got exactly what you said.
But when I used this instead:

TextRenderer.DrawText(e.Graphics, text, font, new Point(100, 100), Color.Black);  

It gave me the text the way you wanted it.
Try that on your printDoc_PrintPage().

How to draw unicode string using C# graphics.DrawString


Thanks Albin and Beemer for your active response.

After a few posts in c# google group. It's been confirmed that there is a bug in GDI+ that incorrectly show certain script ("Khmer" in this case) to a different wording.

A native win32 test application was created to verify the issue with GDI+ DrawString().

A bug report has been submitted to Microsoft Connect: http://connect.microsoft.com/VisualStudio/feedback/details/620081/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜