Emojis work in StringGadget + List but not in EditorGadget

Just starting out? Need help? Post your questions and find answers here.
User avatar
marcoagpinto
Addict
Addict
Posts: 940
Joined: Sun Mar 10, 2013 3:01 pm
Location: Portugal
Contact:

Emojis work in StringGadget + List but not in EditorGadget

Post by marcoagpinto »

Emojis > 65535 work in StringGadget and ListIconGadget but not in EditorGadget.

I know that PB had a limitation of Emoji up to ASCII 65535.

But, if I paste one of them into a StringGadget or ListIconGadget, it shows okay.

But in an EditorGadget, I get a corrupted character.

Is it fixable in the next beta?

Thank you!
User avatar
STARGÅTE
Addict
Addict
Posts: 2067
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: Emojis work in StringGadget + List but not in EditorGadg

Post by STARGÅTE »

You are correct, but please add an example code.
For example, here the different h's:

Code: Select all

Procedure.s UnicodeChr(Number.i)
   Protected Buffer.l
   If Number <= $FFFF
      ProcedureReturn Chr(Number)
   Else
      Buffer = (Number&$3FF)<<16 | (Number-$10000)>>10 | $DC00D800
      ProcedureReturn PeekS(@Buffer, 2, #PB_Unicode)
   EndIf
EndProcedure


Enumeration
   #Window
   #StringGadget
   #ListIconGadget
   #EditorGadget
   #ButtonGadget
   #Font
EndEnumeration

LoadFont(#Font, "Cambria", 16)

Define Text.s = "H"+UnicodeChr($1D4D7)+"ℍ"+UnicodeChr($1D573)

OpenWindow(#Window, 0, 0, 330, 160, "WindowTitle", #PB_Window_MinimizeGadget|#PB_Window_ScreenCentered)
SetGadgetFont(#PB_Default, FontID(#Font))

StringGadget(#StringGadget, 10, 10, 150, 30, Text)

ListIconGadget(#ListIconGadget, 10, 50, 150, 100, "", 100)
AddGadgetItem(#ListIconGadget, -1, Text)

EditorGadget(#EditorGadget, 170, 10, 150, 100)
SetGadgetText(#EditorGadget, Text)

ButtonGadget(#ButtonGadget, 170, 120, 150, 30, Text)

Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
Which font supports the emoji characters?
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
User avatar
marcoagpinto
Addict
Addict
Posts: 940
Joined: Sun Mar 10, 2013 3:01 pm
Location: Portugal
Contact:

Re: Emojis work in StringGadget + List but not in EditorGadg

Post by marcoagpinto »

@Stargate:

Code: Select all

    t=LoadFont(1,"Arial",10,#PB_Font_HighQuality) ;Load Arial Font, Size 10 - 6/FEB/2014 + High Quality 8/FEB/2014
    If t=#False : MessageRequester("Error", "Can't load Arial font.",#PB_MessageRequester_Error) : EndIf

    SetGadgetFont(#PB_Default,FontID(1))
You can test it with the Emoji from LibreOffice:
:warning:
using the GB speller.

Just copy it from the document and paste in a StringGadget or ListIconGadget and it appears correct.

If you paste it into an EditorGadget you get no character.
User avatar
marcoagpinto
Addict
Addict
Posts: 940
Joined: Sun Mar 10, 2013 3:01 pm
Location: Portugal
Contact:

Re: Emojis work in StringGadget + List but not in EditorGadg

Post by marcoagpinto »

The warning sign is chr(9888).

I have just tested your code and it only gets corrupted in the EditorGadget.

EDIT: "in the EditorGadget"
User avatar
STARGÅTE
Addict
Addict
Posts: 2067
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: Emojis work in StringGadget + List but not in EditorGadg

Post by STARGÅTE »

Arial does not support these characters!
One font that supports the emoji is "Segoe UI Symbol".

Here the emojis work, but not the h's:

Code: Select all

Procedure.s UnicodeChr(Number.i)
   Protected Buffer.l
   If Number <= $FFFF
      ProcedureReturn Chr(Number)
   Else
      Buffer = (Number&$3FF)<<16 | (Number-$10000)>>10 | $DC00D800
      ProcedureReturn PeekS(@Buffer, 2, #PB_Unicode)
   EndIf
EndProcedure


Enumeration
   #Window
   #StringGadget
   #ListIconGadget
   #EditorGadget
   #ButtonGadget
   #Font
EndEnumeration

LoadFont(#Font, "Segoe UI Symbol", 16)

Define Text.s = UnicodeChr($1F603)+UnicodeChr(9888)+UnicodeChr($1F61E)+"H"+UnicodeChr($1D4D7)+"ℍ"+UnicodeChr($1D573)

OpenWindow(#Window, 0, 0, 330, 160, "WindowTitle", #PB_Window_MinimizeGadget|#PB_Window_ScreenCentered)
SetGadgetFont(#PB_Default, FontID(#Font))

StringGadget(#StringGadget, 10, 10, 150, 30, Text)

ListIconGadget(#ListIconGadget, 10, 50, 150, 100, "", 150)
AddGadgetItem(#ListIconGadget, -1, Text)

EditorGadget(#EditorGadget, 170, 10, 150, 100)
SetGadgetText(#EditorGadget, Text)

ButtonGadget(#ButtonGadget, 170, 120, 150, 30, Text)

Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
User avatar
marcoagpinto
Addict
Addict
Posts: 940
Joined: Sun Mar 10, 2013 3:01 pm
Location: Portugal
Contact:

Re: Emojis work in StringGadget + List but not in EditorGadg

Post by marcoagpinto »

STARGÅTE wrote:Arial does not support these characters!
One font that supports the emoji is "Segoe UI Symbol".
Arial DOES seem to work.

Try your first code with:

Code: Select all

LoadFont(#Font, "Arial", 16)

Define Text.s = Chr(9888)
Only the EditorGadget shows a corrupted character.
dcr3
Enthusiast
Enthusiast
Posts: 165
Joined: Fri Aug 04, 2017 11:03 pm

Re: Emojis work in StringGadget + List but not in EditorGadg

Post by dcr3 »

Try. Work's on editor as well.

LoadFont(#Font, "Segoe UI Symbol", 16)
Define Text.s = Chr($26A0)


debug Chr($26A0
User avatar
marcoagpinto
Addict
Addict
Posts: 940
Joined: Sun Mar 10, 2013 3:01 pm
Location: Portugal
Contact:

Re: Emojis work in StringGadget + List but not in EditorGadg

Post by marcoagpinto »

dcr3 wrote:Try. Work's on editor as well.

LoadFont(#Font, "Segoe UI Symbol", 16)
Define Text.s = Chr($26A0)


debug Chr($26A0
Ahhhh... I forgot to mention this: the original idea was to have normal text with some emojis, so, using the font you suggested doesn't work in my case.

For example: in the GB speller page of Mozilla I have the warning emoji twice and I works with a normal font, so I wanted to be able to use it also in PB.
User avatar
STARGÅTE
Addict
Addict
Posts: 2067
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: Emojis work in StringGadget + List but not in EditorGadg

Post by STARGÅTE »

PB Gadgets supports only one font for the whole text.
So you cant insert styled text (multiple fonts).
You have to decide for one font which supports the character you want.
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
User avatar
marcoagpinto
Addict
Addict
Posts: 940
Joined: Sun Mar 10, 2013 3:01 pm
Location: Portugal
Contact:

Re: Emojis work in StringGadget + List but not in EditorGadg

Post by marcoagpinto »

STARGÅTE wrote:PB Gadgets supports only one font for the whole text.
So you cant insert styled text (multiple fonts).
You have to decide for one font which supports the character you want.
Hello!

See:
https://addons.mozilla.org/en-US/firefo ... ctionary-2

It is only one font in the description, right?

I copied and pasted into a .txt document and the warning signs appear well.

Scroll down in Mozilla to:

Code: Select all

To make sure the words I add are the correct ones, I have been looking for them in credible sources:
1) Oxford Dictionaries;
2) Collins Dictionary;
3) Macmillan Dictionary;
4) Wiktionary (used with caution ⚠);
5) Wikipedia (used with caution ⚠);
6) Physical dictionaries.
In 4) and 5) you can see the emoji.

I don't know more what to say... :cry:
breeze4me
Enthusiast
Enthusiast
Posts: 511
Joined: Thu Mar 09, 2006 9:24 am
Location: S. Kor

Re: Emojis work in StringGadget + List but not in EditorGadg

Post by breeze4me »

It seems that using a newer version of the rich edit is a solution.
On Windows 10, the emojis are displayed normally.

But it's not working on Windows 7. An appropriate font is needed.
In addition to the edit version, it seems to support the emojis very poorly on Windows 7.

Code: Select all

Procedure.s UnicodeChr(Number.i)
  Protected Buffer.l
  If Number <= $FFFF
    ProcedureReturn Chr(Number)
  Else
    Buffer = (Number&$3FF)<<16 | (Number-$10000)>>10 | $DC00D800
    ProcedureReturn PeekS(@Buffer, 2, #PB_Unicode)
  EndIf
EndProcedure


Enumeration
  #Window
  #StringGadget
  #ListIconGadget
  #EditorGadget
  #ButtonGadget
  #Font
EndEnumeration

Procedure CreateRichEdit(ParentID, x, y, w, h)
  OpenLibrary(0, "MSFTEDIT.dll")
  ;OpenLibrary(1,"riched32.dll")
  ProcedureReturn CreateWindowEx_(#WS_EX_CLIENTEDGE, "RichEdit50W", 0, #WS_CHILD | #WS_VISIBLE | #ES_MULTILINE | #WS_VSCROLL | #ES_AUTOVSCROLL, x, y, w, h, ParentID, 0, 0, 0)
EndProcedure

Procedure DestroyRichEdit(hRichEdit)
  DestroyWindow_(hRichEdit)
  CloseLibrary(0)
  ;CloseLibrary(1)
EndProcedure


LoadFont(#Font, "Arial", 16)


Define Text.s = "H"+UnicodeChr($1D4D7)+"ℍ"+UnicodeChr($1D573) + Chr($26A0)

OpenWindow(#Window, 0, 0, 330, 160, "WindowTitle", #PB_Window_MinimizeGadget|#PB_Window_ScreenCentered)
SetGadgetFont(#PB_Default, FontID(#Font))

StringGadget(#StringGadget, 10, 10, 150, 30, Text)

ListIconGadget(#ListIconGadget, 10, 50, 150, 100, "", 100)
AddGadgetItem(#ListIconGadget, -1, Text)

hRichEdit = CreateRichEdit(WindowID(#Window), 170, 10, 150, 100)
SendMessage_(hRichEdit, #WM_SETFONT, FontID(#font), 1)
SetWindowText_(hRichEdit, Text)

ButtonGadget(#ButtonGadget, 170, 120, 150, 30, Text)

Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow

DestroyRichEdit(hRichEdit)
User avatar
STARGÅTE
Addict
Addict
Posts: 2067
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: Emojis work in StringGadget + List but not in EditorGadg

Post by STARGÅTE »

marcoagpinto wrote: It is only one font in the description, right?
No it isn't!
When you analyze the page (the description part) you can read:
Rendered Fonts wrote: Fira Sans—Network resource(5005 glyphs)
Segoe UI Symbol—Local file(2 glyphs)
So the two ⚠ are loaded from the Segoe UI Symbol font.
It is the same here in the forum:

You can see the ⚠ in your posted code section, but the fonts are:
Rendered Fonts wrote: Trebuchet MS—Local file(429 glyphs)
Courier New—Local file(225 glyphs)
Segoe UI Symbol—Local file(2 glyphs)
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
Post Reply