Wrong font size in controls

 

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. 

Files:
Normal.JPG  30 kb
incorrect.JPG  55 kb
 
mytradertools :

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).
 
barabashkakvn:
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.

 
mytradertools :

Hi -thanks for the reply. Do you know which window setting he could be using to replicate this?

Kind regards Dan. 

These settings must be in the "Screen".
 
barabashkakvn:
Your client uses a scale greater than 100%. MQL5 can not determine the scale, which is used by the system (without calling WinAPI).
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.
Documentation on MQL5: Object Functions / TextGetSize
Documentation on MQL5: Object Functions / TextGetSize
  • www.mql5.com
Object Functions / TextGetSize - Reference on algorithmic/automated trading language for MetaTrader 5
 
angevoyageur :
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.
 
barabashkakvn:
Interesting option.

Thanks for your feedback - Ill try this out. Regards Dan. 

 
Alain Verleyen:
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)
 
Alain Verleyen:
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?

 
Hello friends
I wrote an expert but the buttons and labels are not displayed well on other computers,
Can anyone help me with TerminalInfoInteger (TERMINAL_SCREEN_DPI) use ?

I read the document but I did not understand the meaning of button_width and base_width. Can anyone help?
Reason: