Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get exact character font width 1

Status
Not open for further replies.

sin1965

Programmer
Nov 6, 2005
46
GB
I’m building a currency edit user control. This is to be completely owner drawn. The problem is getting the exact widths of each numeral irrespective of font and size etc. I want the developer to decide this. I’ve tried Graphics.MeasureString and Graphics.MeasureCharacterRanges. The output of each, using Graphics.DrawString, is different. MeasureString gives quite a lot of lead and trailing space. MeasureCharacterRanges tend to bunch up on top of each other or chops off the end. Is a DrawString RectangleF problem or is it a unit of measurement problem. My input Font is in Points and the Output unit I hope is Pixels. I’ve tried to convert the MeasureCharacterRanges width to pixels but then it ends up like MeasureString. I’m totally stumped! I want to able to set co-ordinates for individual digits and use reverse video for mouse selection and drag and drop etc but with what I’ve found so far the output is going to look to wide spaced. I also want it to be generic without resorting to manual code tweaks to get it looking ok…this will lead to disaster on differing fonts etc. All ideas re GDI & GDI+ are welcome.
 
Many Thanks for the info. most helpful. Font typography is certainly a complex yet fascinating area of programming. we all take it a bit too much for granted I guess. :)
regards
steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top