|
-
June 14th, 2011, 11:10 AM
#1
GDI+ MeasureString and character width
Hey Gurus,
I'm currently writing a subtitle editor for cinemas. I have touched on the problem I have below in another thread previously, but I thought it best to now start its own thread.
I have run into a problem I can't seem to find a solution for, even though I have trawled this forum quite heavily.
When a subtitle is generated, each character can have differing attributes, therefore I can't just DrawString the subtitle, I have to do it a character at a time.
To do this, I need to track the width of the previous character. If I use MeasureString, the resultant value returned has a significant amount of space around it and nothing I do seems to change this. The text appears with large spacing between the letters, as if it had a lot of kerning applied.
I am currently using GetTextExtent, which seems to be far more accurate, but it is still not correct, even though I set the font, size, weight etc to match my GDI+ font (nor would I expect it to be, it's just a work-around atm).
Is there an accurate way of calculating the width of a character in GDI+ which returns the pixel accurate size of the character only?
Is proving to be quite a pain, especially when underlined is enabled, as the line is broken between some (most) of the characters.
Any help/suggestions would be greatly appreciated.
Thanks heaps,
Steve Q.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|