Confusing Graphics.MeasureString returns
Hi,
I am confused by some values returned by graphics.MeasureString method
g.MeasureString(Convert.ToString(sb), PrintFont).Width is following:
g-valid graphics object, PrintFont is constant for both calls and value of Convert.ToString(sb) is as follows
" Item "
width returned is 177.soemthingsomething
" Item l"
width returned is 333.something.
How does adding one extra character make such a huge difference?
Also if i add this extra character the string is printed what it should be printed as, but if I omit l at the end all the trailing spaces are truncated and the string is printed!!!!!!!
What is going on over here?
Help will be highly appreciated. Thank You
Re: Confusing Graphics.MeasureString returns
Oops the string dind't appear right in the post, the spaces got ommited. It is suppsed to be liek this
"23leadingspaces Item 23trailing spaces"
"23leadingspaces Item 23trailing spaces l"
Someoen help please.
Re: Confusing Graphics.MeasureString returns
If your font is a proportional font, the leading spaces (and trailing spaces on your first item) will amount to nothing as they take no space to print.
Re: Confusing Graphics.MeasureString returns
What's a propotional font and how do I tell?
thanks for reply.
Re: Confusing Graphics.MeasureString returns
In proportional fonts, each letter has it's own size, in non-proportional fonts, each letter is the same. An I for example is the same size as a W. In proportional, an I is much skinner than a W.
Re: Confusing Graphics.MeasureString returns
DSJ:
Could you give examples of oft-used proportional and non-proportional fonts. Thanks.
Re: Confusing Graphics.MeasureString returns
I think I have my descriptions reversed above. Courier is about the only fixed size font used anymore. Go into Word and choose Times new Roman and type spacebar spacebar spacebar 123456789 [Enter]. Now, change the font to Courier and type the same thing. You'll see what I'm talking about.
Re: Confusing Graphics.MeasureString returns
Okie i got teh meanign of propotional and np font, but it still dosn't explain the problem I have.
Am not using Courier font, infact am using one of the default fonts represented by
FontFamily.GenericSansSerif
But I willt ry changing to arial or even times new roman.
Thanks for help.