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
I second this query.
Not sure if it is W10 related, though. I suspect it depends on the monitor resolution.
Indirectly. Of course, when a 4k display is used instead of 2k while both have approximately 24 inches, the fonts must be scaled to another pixel resolution because otherwise any text would become unreadable. And this scaling factor is what I need.
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).
I actually do not know what the real reason is, but I am very interested in finding a solution for well-defined font size.
I asked in mql5 forum, but apparently without success. I have no limits to winapi DLLs (I do not sell to the MQL5 Market), do you think there is a simple way for getting the factor?
I remember old times when I was developing for Windows to a function called GetDeviceCaps() where you at least can obtain the resolution per Inch (dpi) and I assume, that we should start somewhere there.
I still do also not sell at the market place here, because it seems simply impossible to publish well designed and complex EAs due to the DLL restrictions. And design is not only about visuals.
Totally agree. I believe they have two good reasons for excluding DLLs from the market - to avoid accusation for supporting the system level harm, and protecting their pseudo-VPS from users interference.
I will try to match the topic in C++ discussions, they should have it similar, unless the MQ made some "improvements" which would add to the problem. Anyway, it has rather low priority for me, so probably not earlier than the next week.
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.
To add comments, please log in or register