Hi,
A customer has reported that the fonts in this purchased product are the wrong size. I have no idea how this has occurred. I do not set the font size explicitly the code, I just let it use the defaults.
Are there any suggestions what may be causing this.
I have attached 2 pictures. Normal.jpg is what it should be and incorrect.jpg is my clients version.
Kind regards
Dan.
Your client uses a scale greater than 100%. MQL5 can not determine the scale, which is used by the system (without calling WinAPI).
Hi -thanks for the reply. Do you know which window setting he could be using to replicate this?
Kind regards Dan.
Hi -thanks for the reply. Do you know which window setting he could be using to replicate this?
Kind regards Dan.
Your client uses a scale greater than 100%. MQL5 can not determine the scale, which is used by the system (without calling WinAPI).
- www.mql5.com
While you don't have a function in mql5 to determine the Windows settings, it's perfectly doable to get it using TextGetSize and TextSetFont.
Interesting option.
Thanks for your feedback - Ill try this out. Regards Dan.
While you don't have a function in mql5 to determine the Windows settings, it's perfectly doable to get it using TextGetSize and TextSetFont.
I don't see it, how this is doable with TextSetFont? I'm running W10 scale layout set 100% and swill from .NET side i get completely different results.
C# method:
[DllExport("MeasureTextDotNet", CallingConvention = CallingConvention.StdCall)] public static bool MeasureTextDotNet([MarshalAs(UnmanagedType.LPWStr)] string text, [MarshalAs(UnmanagedType.LPWStr)] string font, int size, int fontStyleFlags, ref int width, ref int height) { try { var point = TextRenderer.MeasureText(text, new Font(font, size, (FontStyle)fontStyleFlags)); width = point.Width; height = point.Height; return true; } catch (Exception ex) { return false; } }
Mql script:
// System.Drawing.FontStyle enum FontStyleFlags { Regular = 0, Bold = 1, Italic = 2, Underline = 4, Strikeout = 8 }; #import "TM.dll" bool MeasureTextDotNet(string text, string font, int size, FontStyleFlags flags, int &width, int &height); #import void OnStart() { string text = "test"; string font = "Arial"; int size = 14; if(!TextSetFont(font, size, FW_REGULAR)) Print("TextSetFont error="+(string)_LastError); uint w, h; if(!TextGetSize(text, w, h)) Print("TextGetSize error="+(string)_LastError); Print("TextGetSize: width=", w, " height=", h); int wn, hn; if(!MeasureTextDotNet(text, font, size, Regular, wn, hn)) Print("MeasureTextDotNet error."); Print("MeasureTextDotNet: width=", wn, " height=", hn); Print("Width ratio=", wn/(double)w, " height ratio=", hn/(double)h); }
Prints:
2018.03.01 06:32:13.188 FontSizeTest (GBPUSD,M15) TextGetSize: width=18 height=14
2018.03.01 06:32:13.289 FontSizeTest (GBPUSD,M15) MeasureTextDotNet: width=41 height=22
2018.03.01 06:32:13.289 FontSizeTest (GBPUSD,M15) Width ratio=2.277777777777778 height ratio=1.571428571428571
Old topic. You now have TerminalInfoInteger(TERMINAL_SCREEN_DPI)
But how does it help me to measure existing text size? Say, if i want to measure the [Symbol,period] description on the upper left corner of a chart?
- 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,
A customer has reported that the fonts in this purchased product are the wrong size. I have no idea how this has occurred. I do not set the font size explicitly the code, I just let it use the defaults.
Are there any suggestions what may be causing this.
I have attached 2 pictures. Normal.jpg is what it should be and incorrect.jpg is my clients version.
Kind regards
Dan.