Unicode not fully supported? - page 2

 
Alain Verleyen:
What font is that ?

Segoe UI Emoji (one of the download links : http://legionfonts.com/fonts/segoe-ui-emoji )

Segoe ui emoji Font
Segoe ui emoji Font
  • OleGik (by_OleGik@mail.ru)
  • legionfonts.com
For Windows: FontForge, CorelDRAW Graphics Suite X5-X7, CorelDRAW Graphics Suite 2017, FontCreator, Microsoft Windows Font Viewer, AMP Font Viewer. For Mac OS: FontForge, Apple Font Book...
 
Mladen Rakic:

Segoe UI Emoji (one of the download links : http://legionfonts.com/fonts/segoe-ui-emoji )

Doesn't work for me (with the one installed on my computer).

Do you have a code (can be ex4 if you want) to run to see if it's something about code (I don't think so).

 
William Roeder:
Do you really expect an answer? We can't see your broken code. There are no mind readers here and our crystal balls are cracked.

My post with the code was here.

Here is a full code:

//+------------------------------------------------------------------+
//|                                                      ProjectName |
//|                                      Copyright 2018, CompanyName |
//|                                       http://www.companyname.net |
//+------------------------------------------------------------------+
#property copyright ""
#property link      ""
#property version   "1.00"
#property strict


//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   string s1=ShortToString((uchar)0xAE);   //®
   string s2=ShortToString((uchar)0x263A); //☺
   string s3=ShortToString((uchar)0x2602); //☂

   if(!LabelCreate(0,"Label1",0,50,50,0,s1,"Verdana",20,clrCornflowerBlue))
     {
      Print("Failed.");
     }

   if(!LabelCreate(0,"Label2",0,50,80,0,s2,"Verdana",20,clrCornflowerBlue))
     {
      Print("Failed.");
     }

   if(!LabelCreate(0,"Label3",0,50,110,0,s3,"Verdana",20,clrCornflowerBlue))
     {
      Print("Failed.");
     }

  }
//+------------------------------------------------------------------+
bool LabelCreate(const long              chart_ID=0,               // chart's ID
                 const string            name="Label",             // label name
                 const int               sub_window=0,             // subwindow index
                 const int               x=0,                      // X coordinate
                 const int               y=0,                      // Y coordinate
                 const ENUM_BASE_CORNER  corner=CORNER_LEFT_UPPER, // chart corner for anchoring
                 const string            text="Label",             // text
                 const string            font="Arial",             // font
                 const int               font_size=10,             // font size
                 const color             clr=clrRed,               // color
                 const double            angle=0.0,                // text slope
                 const ENUM_ANCHOR_POINT anchor=ANCHOR_LEFT_UPPER, // anchor type
                 const bool              back=false,               // in the background
                 const bool              selection=false,          // highlight to move
                 const bool              hidden=true,              // hidden in the object list
                 const long              z_order=0)                // priority for mouse click
  {
   ResetLastError();
   if(!ObjectCreate(chart_ID,name,OBJ_LABEL,sub_window,0,0))
     {
      Print(__FUNCTION__,
            ": failed to create text label! Error code = ",GetLastError());
      return(false);
     }
   ObjectSetInteger(chart_ID,name,OBJPROP_XDISTANCE,x);
   ObjectSetInteger(chart_ID,name,OBJPROP_YDISTANCE,y);
   ObjectSetInteger(chart_ID,name,OBJPROP_CORNER,corner);
   ObjectSetString(chart_ID,name,OBJPROP_TEXT,text);
   ObjectSetString(chart_ID,name,OBJPROP_FONT,font);
   ObjectSetInteger(chart_ID,name,OBJPROP_FONTSIZE,font_size);
   ObjectSetDouble(chart_ID,name,OBJPROP_ANGLE,angle);
   ObjectSetInteger(chart_ID,name,OBJPROP_ANCHOR,anchor);
   ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr);
   ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);
   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection);
   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection);
   ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden);
   ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order);
   return(true);
  }
//+------------------------------------------------------------------+

The result is:

unicode

I used the Verdana font, is it problem? Maybe should I use something else?

(I tried the same thing by using the Print function, and got the same result, so I don't think it is a font type problem.)

 
linux80s:

My post with the code was here.

Here is a full code:

The result is:


I used the Verdana font, is it problem? Maybe should I use something else?

(I tried the same thing by using the Print function, and got the same result, so I don't think it is a font type problem.)

Of course it's font related (Print() is also using a font don't you think ?). But not only.

Verdana doesn't include a representation for U+2602 and U+263A.

Did you try with "Segoe ui emoji" as suggested by Mladen ?

 
linux80s:

My post with the code was here.

Here is a full code:

The result is:


I used the Verdana font, is it problem? Maybe should I use something else?

(I tried the same thing by using the Print function, and got the same result, so I don't think it is a font type problem.)

By the way using your code (unchanged) with MT4 Build 1220 (Windows 10), I don't get the same result :


As you can see the third character is "empty" on my side.

And what works for Mladen doesn't work for me. Still trying to find a logic.

EDIT: There is a bug in your code :

   string s1=ShortToString((uchar)0xAE);   //®
   string s2=ShortToString((uchar)0x263A); //☺
   string s3=ShortToString((uchar)0x2602); //☂
Must be 'ushort' or no casting at all as these literals are correct ushort constants.
 

As far as I have checked it, it seems that using objects that are aimed to display text in any form (since objects are using "regular" strings as "buffers" for the text that needs to be displayed) will not work (that can be checked if we try to paste any unicode character above code 255 into its text property)

I am using bitmap label and creating a resource using TextOut() - it works as expected because it bypasses the internal string buffers of objects. Even for verdana - the same "message" from a few posts ago using Verdana


 
Mladen Rakic:

As far as I have checked it, it seems that using objects that are aimed to display text in any form (since objects are using "regular" strings as "buffers" for the text that needs to be displayed) will not work (that can be checked if we try to paste any unicode character above code 255 into its text property)

I am using bitmap label and creating a resource using TextOut() - it works as expected because it bypasses the internal string buffers of objects. Even for verdana - the same "message" from a few posts ago using Verdana


Aahh that's it.

It confirms my first hypothesis, Unicode is well managed by mql4 (TextOut() get the correct character(s) and after that it's a bitmap so nothing related to Unicode any more); but MT4 GUI (LABEL/TEXT object or even Print() statement) don't manage Unicode correctly (or fully ?).

Thanks for the enlightenment Mladen.

 
Mladen Rakic:

As far as I have checked it, it seems that using objects that are aimed to display text in any form (since objects are using "regular" strings as "buffers" for the text that needs to be displayed) will not work (that can be checked if we try to paste any unicode character above code 255 into its text property)

I am using bitmap label and creating a resource using TextOut() - it works as expected because it bypasses the internal string buffers of objects. Even for verdana - the same "message" from a few posts ago using Verdana


Actually it works with Verdana too, BUT as U+263A or U+2602 doesn't exist in Verdana font, they are represented with an OTHER font (apparently Segoe UI Emoji (not sure it's systematic ?).


Files:
151202-AV.mq4  5 kb
 
Alain Verleyen:

Actually it works with Verdana too, BUT as U+263A or U+2602 doesn't exist in Verdana font, they are represented with an OTHER font (apparently Segoe UI Emoji (not sure it's systematic ?).


Thank you Alain, I tried your code, my result is "interesting" in the case of Verdana. I don't know why? My system MT4 Build 1220 (Ubuntu 16.04 + Wine).

BTW, is it possible to embed the font as a resource into the ex4? If yes, can I get a sample code?

unicode

 
linux80s:

Thank you Alain, I tried your code, my result is "interesting" in the case of Verdana. I don't know why? My system MT4 Build 1220 (Ubuntu 16.04 + Wine).

I don't know why either, maybe it's related to the font version available with Wine ? Only Metaquotes could answer I suppose.

BTW, is it possible to embed the font as a resource into the ex4? If yes, can I get a sample code?

No it's not possible.