It's because of the way GDI+ renders text. The aim was to have text
rendering functions that would render the text with the same proportions
regardless of the scaling. With small DPI, though, it results in characters
being moved in a strange way. To see what exactly is going on, try setting
the Graphics.TextRenderingHint to the following values:
TextRenderingHint.AntiAlias - You lose readability for small font
sizes, but this is the exact representation how the text is meant to look
like. Note that two characters may not look the same in different positions.
TextRenderingHint.AntiAliasGridFit - This is the default (unless you
have ClearType turned on). The characters look always the same (start of
every character is aligned to the displaying device's grid), and the
character kerning is adjusted so that the size of the string is roughly the
same as with the previous. This is what you see when rendering the
iiiiiiiiiiiiiiii string. Because each character starts at an approximate
position to match the display grid, the space between characters may vary.
Also, for much more information on GDI+ see Bob Powell's GDI+ FAQ at
http://www.bobpowell.net/gdiplus_faq.htm
HTH,
Stefan
"Sam Sungshik Kong" <ss*@chol.nospam.net> wrote in message
news:eI**************@TK2MSFTNGP15.phx.gbl...
Hello!
I'm testing Graphics.DrawString and it's very strange.
I created an event handler for the form.s Paint event.
(There's no other code in the form.)
private void Form1_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
string str =
"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii iiiiiiiiiiiiii";
using (SolidBrush b = new SolidBrush(Color.Black))
{
using (Font f = new Font("Microsoft Sans Serif", 8.25f))
{
g.DrawString(str, f, b, 10.0f, 10.0f);
}
}
}
Actually it draws like the following kind(I can't show it in text):
iiiiiiiiiiiiiiiiiiiiiiiiiiiii i i i i i i i i i i i i i i i i i i i i i i
i i i i i i i i i i i i
Can anybody explain why it's like that?
TIA.
Sam