I'm trying to migrate my Graphics.DrawString
calls (.NET1) to TextRenderer.DrawText
(new in .NET 2.0) to get the advantages of the ClearType rendering.
The problem is that TextRenderer does not print occidental characters correctly (korean, japanese, etc...)
Here is an example that shows the issue:
- Do you know why the korean chars are not seen when using TextRenderer.DrawText?
- Do you know how fix this issue?
I'm drawing the strings using the following two methods:
private void DrawGraphicsString(
Graphics g, string text, Font font, Point p)
{
g.DrawString(
text, font, text_brush, p.X, p.Y, mStringFormat);
// mStringFormat is
// StringFormat.GenericTypographic |
// StringFormatFlags.MeasureTrailingSpaces
}
private void DrawTextRendererString(
Graphics g, string text, Font font, int x, int y)
{
TextRenderer.DrawText(
g, text, font, p, this.ForeColor, this.BackColor, mTextFormatFlags);
// mTextFormatFlags are
// StringFormat.GenericTypographic + StringFormatFlags.MeasureTrailingSpaces
// mTextFormatFlags =
// TextFormatFlags.NoPrefix |
// TextFormatFlags.NoPadding |
// TextFormatFlags.WordBreak |
// TextFormatFlags.TextBoxControl |
// TextFormatFlags.NoClipping |
// TextFormatFlags.ExpandTabs;
}
EDIT: Using other font it works correctly (used font Malgun Gothic)
So now my questions are:
- Why Graphics.Drawtext draws korean chars even if the font does not support them?
- I pasted the corean text in the Visual Studio editor, that uses "Consolas" font and it is drawn correctly. So, why Visual Studio editor can show korean characters, and a textbox cannot?