Maybe the problem was not explained good enough. My EA deals with full scalable vector graphics, with system fonts as well as with text generated in memory bitmaps. As soon as the system fonts get scaled, these elements don´t fit together anymore. And this is why I need this font scaling factor and the question was - is there something available in MQL which I´ve overlooked or do I really have to access User32.dll which will make it impossible to release this at the MQL market, because everything is dveloped with pure MQL5.
Here are the examples. The black one is correct (Windows 8), the white one is the problem (Windows 10 with scaled fonts on UHD).
Doerk
I didn't use it yet, but I suppose that should help you.
29. MQL5: Added TERMINAL_SCREEN_DPI value to the ENUM_TERMINAL_INFO_INTEGER client terminal property enumeration — data display resolution is measured in dots per inch (DPI). Knowledge of this parameter allows specifying the size of graphical objects, so that they look the same on monitors with different resolution.
- www.mql5.com
I didn't use it yet, but I suppose that should help you.
And to complete this: It´s a bug in MQL5. The documentation says:
The font size is set using positive or negative values. This fact defines the dependence of the text size from the operating system settings (size scale).
If the size is specified by a positive number, this size is transformed into physical measurement units of a device (pixels) when changing a logical font into a physical one, and this size corresponds to the height of the symbol glyphs picked from the available fonts. This case is not recommended when the texts displayed by TextOut() function and the ones displayed by OBJ_LABEL ("Label") graphical object are to be used together on the chart.
If the size is specified by a negative number, this number is supposed to be set in tenths of a logical point (-350 is equal to 35 logical points) and is divided by 10. An obtained value is then transformed into physical measurement units of a device (pixels) and corresponds to the absolute value of the height of a symbol picked from the available fonts. Multiply the font size specified in the object properties by -10 to make the size of a text on the screen similar to the one in OBJ_LABEL object.
And I verified my code. I was already using these negative values and never had problems. The interpretation/calculation goes wrong under specific circumstances at least with UHD displays and Windows 10.
Doerk
I didn't use it yet, but I suppose that should help you.
29. MQL5: Added TERMINAL_SCREEN_DPI value to the ENUM_TERMINAL_INFO_INTEGER client terminal property enumeration —
Yes, this is the enhancement request I raised for MQL4 back in January. The Metaquotes overlords have implemented it in MQL4 and MQL5 but the code has yet to be released on MQL4.
Please be aware that you will likely have to scale quite a few of your screen assets to cope with this change
int desktopScreenDpi = TerminalInfoInteger(TERMINAL_SCREEN_DPI); double DesktopScaling = desktopScreenDpi > 96.0 ? desktopScreenDpi / 96.0 : 1.0; double xppc = xPixPerChar(TextSize) * DesktopScaling; double yppc = yPixPerChar(TextSize) * DesktopScaling; double xMargin = 2 * DesktopScaling + TextSpaces * xppc; double xPos = xMargin; double yPos = 1 * DesktopScaling + TextStartRow * yppc;
As you may see the pixel per character calculations and any character spacing calculations (for panel sizes etc) all have to be multiplied by the DesktopScaling variable
While I wait for the TERMINAL_SCREEN_DPI to become available on MQL4 I have implemented an input parameter that sets the DesktopScaling variable above manually.
Yes, thanks, thats what I did too but I just see it as a workaround. Isnt there a way to do it automatically?
Edit: But didnt know about that value with TerminalInfoInteger, thank you for that, guys.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi there,
does anybody how it is possible to obtain the scaling factor of system fonts? Especially with Windows 10 I have weird behaviour with the font sizes and especially with UHD displays. A normal fontsize of 9 or 10 results in huge texts which do not fit into any bitmap objects anymore. Furthermore, the scaling factor between fontsizes that I use for graphical output with TextOut() seems to deviate as well. Normally the factor is 1.7 (Label-fontsize x 1.7 = size in pixels), but with Windows 10 this does not work too - sometimes.
Do I have to search within User32.dll (which will make it impossible to put the EA into the market place) or is there a similar function in MQL or within one of the MQL5-standard libs?
Thank you in advance
Doerk