Sign in to follow this  
devronious

[.net] help with font's char width please

Recommended Posts

How can I determine the width of a particular character within a font? I'm not wanting to use the measureString method as it doesn't seem to return the actual width of the character but rather a padded version of it. Or is there something I'm doing wrong? -Devin

Share this post


Link to post
Share on other sites
MeasureString has always returned the visible width of the string for me. That of course leads to some gotchas when whitespace is at the end of the string, but better than nothing.

Share this post


Link to post
Share on other sites

for each character{
make string(character);
measure.
}


Though IIRC that won't help much, as variable width fonts can have character widths change depending on what's next to them.

Perhaps you want to explain what you're trying to do? Odds are someone has had to deal with it before.

Share this post


Link to post
Share on other sites
I'm creating my own directx font class so that I can have more indepth control over how it behaves. I would have liked to capture the width and height of every character for creating drawn sentances and such.

Share this post


Link to post
Share on other sites
If you're using bitmap fonts, you might want to check this out. It'll create your font texture automatically, and spit out a file that includes all of the character widths :)

Share this post


Link to post
Share on other sites
That's an interesting approach. I finally got it figured out. I had to use a format flag in MeasureString in the Graphics object.

Thanks for your guys help!!!

much appreciated :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this