Download MetaTrader 5

font size and pixel

To add comments, please log in or register
Develop trading robots to order. Make profit with Freelance service!
williamwong
632
williamwong 2011.09.13 09:21 
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
632
williamwong 2011.09.23 05:35  
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.
Jimmy
490
Jimmy 2011.09.23 08:45  
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

Andriy Moraru
1160
Andriy Moraru 2011.09.24 17:50  
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
To add comments, please log in or register