Label with monospaced font unable to change font size

 
//+------------------------------------------------------------------+
//|                                                     DrawUtil.mqh |
//|                                             Copyright 2024, Ting |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2024, Ting"
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
class DrawUtil
  {//behavior are async
private:

public:
                     DrawUtil(void);
                    ~DrawUtil();
                    
      static long currentChartID;
      static int window;
      
      static string objectName;
      static int numbering;
      static string labelName;
      static int lblNumbering;
      
      static void writeZone(datetime time, double price, string text, color clr, double angle=0){
         string realObjName = (objectName+IntegerToString(numbering));
         if(!ObjectCreate(currentChartID,realObjName,OBJ_TEXT,window,time,price)){
            Print("Error: can't create text! code #",GetLastError());
         }else{//continue set up text
            ObjectSetString(currentChartID,realObjName,OBJPROP_TEXT,text);
            ObjectSetInteger(currentChartID,realObjName,OBJPROP_COLOR,clr);
            ObjectSetDouble(currentChartID,realObjName,OBJPROP_ANGLE,angle);
            numbering++;
         }
      }
      
      static void drawZone(){
         
      }
      
      static void putStaticWords(int lblUniqueNumber, string lblText, color clr=clrAqua){
         string realLblName = (labelName+IntegerToString(lblUniqueNumber));
         if(!ObjectCreate(currentChartID,realLblName,OBJ_LABEL,window,0,0)){
            Print("Error: can't create label! code #",GetLastError());
         }else{//continue set up label
            ObjectSetInteger(currentChartID,realLblName,OBJPROP_XDISTANCE,150);
            ObjectSetInteger(currentChartID,realLblName,OBJPROP_YDISTANCE,15*lblNumbering);
            ObjectSetInteger(currentChartID,realLblName,OBJPROP_CORNER,CORNER_RIGHT_UPPER);
            
            ObjectSetString(currentChartID,realLblName,OBJPROP_TEXT,lblText);
            ObjectSetString(currentChartID,realLblName,OBJPROP_FONT,"Courier");//monospaced font
            ObjectSetInteger(currentChartID,realLblName,OBJPROP_COLOR,clr);
            ObjectSetInteger(currentChartID,realLblName,OBJPROP_FONTSIZE,8);
            
            //nor enlisted nor selectable nor prioritized
            ObjectSetInteger(currentChartID,realLblName,OBJPROP_HIDDEN,true);
            ObjectSetInteger(currentChartID,realLblName,OBJPROP_SELECTABLE,false);
            ObjectSetInteger(currentChartID,realLblName,OBJPROP_SELECTED,false);
            ObjectSetInteger(currentChartID,realLblName,OBJPROP_ZORDER,0);
            
            ChartRedraw();
            lblNumbering++;
         }
      }
      static void updateStaticWords(int lblUniqueNumber, string lblText, color clr=clrAqua){
         string realLblName = (labelName+IntegerToString(lblUniqueNumber));
         ObjectSetString(currentChartID,realLblName,OBJPROP_TEXT,lblText);
         ObjectSetInteger(currentChartID,realLblName,OBJPROP_COLOR,clr);
      }
  };
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
DrawUtil::DrawUtil(void)
  {
  


  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
DrawUtil::~DrawUtil()
  {
  }
//+------------------------------------------------------------------+
   long DrawUtil::currentChartID = ChartID();
   int DrawUtil::window = 0;
   string DrawUtil::objectName = "text_";
   int DrawUtil::numbering = 0;
   string DrawUtil::labelName = "label_";
   int DrawUtil::lblNumbering = 1;

When I use Times-New-Roman or a default Arial as label text's font, it works fine and adapt to the font size given. But when Courier is used, it fallback to a default font size. Anyone using MT4 knows why?

Entdecken Sie neue Möglichkeiten des MetaTrader 5 mit MQL5 Gemeinschaft und Services
Entdecken Sie neue Möglichkeiten des MetaTrader 5 mit MQL5 Gemeinschaft und Services
  • 2024.05.24
  • www.mql5.com
MQL5: eine Sprache von Handelsstrategien, eingebaut in die Handelsplattform MetaTrader 5, mit der man eigene Handelsroboter, technische Indikatoren, Skripte und Funktionsbibliotheken
 
Ting: But when Courier is used, it fallback to a default font size. Anyone using MT4 knows why?

On my machine (Win11) I don't have Courier, only Courier New (Bold, Bold Italic, italic, Regular) and Courier Regular.

 
William Roeder #:

On my machine (Win11) I don't have Courier, only Courier New (Bold, Bold Italic, italic, Regular) and Courier Regular.

Much thanks William, I now switched to Cascadia Mono that comes along with my Win10 and it works great