font size and pixel

 
I am trying to adjust the edit control width to fit the text it contains.  How do I calculate the width (in pixel) for a string of a given font size?
Documentation on MQL5: Standard Constants, Enumerations and Structures / Objects Constants / Object Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Objects Constants / Object Properties - Documentation on MQL5
 
williamwong:
I am trying to adjust the edit control width to fit the text it contains.  How do I calculate the width (in pixel) for a string of a given font size?
Seems like I am the only one encountering this difficulty?  Just need a simple formula to convert 1 character of, say, Courier New font size 10, into pixel in width and height so that I can set the edit control to fix the width.
 
williamwong:
Seems like I am the only one encountering this difficulty?  Just need a simple formula to convert 1 character of, say, Courier New font size 10, into pixel in width and height so that I can set the edit control to fix the width.

1 inch = 96 pixels = 72 points.

10 point character (monospaced) = width of character 'm' = 96/72*10 = 13.33 pixels

 
As far as I know, there's no strict dependance between the font size in points and its actual size in pixels. The ratio can be different for different fonts.
Documentation on MQL5: Standard Constants, Enumerations and Structures / Objects Constants / Object Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Objects Constants / Object Properties - Documentation on MQL5
Reason: