Page 1 of 1

emojis in webgadget showing without colors

Posted: Sat May 23, 2020 10:23 pm
by ricardo
Hi,

Following this:

https://www.w3schools.com/charsets/ref_emoji.asp

If i put the code inside a string

HTML$ = "about:<span style='font-size:100px;'>&#129409;</span><p>i will display &#129409;</p><p>i will display &#x1F981;</p>"

and the load it in the webgadget, the emoji shows in black and white, no colors.

Anybody can help?

I need to load fro a string becuse im polanning to create the html with my code, im not trying to load the w3school.com pge

Thanks in advance

Re: emojis in webgadget showing without colors

Posted: Sun May 24, 2020 1:14 am
by IdeasVacuum
Hi ricardo

...the emojis are displayed in black and white on the w3schools site too when viewed on my PC - they are font based and so they won't be shown in colour unless the host (your PC) already has a colour version of the font installed.

See: http://classic.getemoji.com

Edit: Different platforms, different results: https://emojipedia.org/smiling-face-with-smiling-eyes

Re: emojis in webgadget showing without colors

Posted: Sun May 24, 2020 6:55 am
by firace
Works here:

Code: Select all

OpenWindow(1, 0, 0, 822, 450, "", #PB_Window_ScreenCentered | #PB_Window_SystemMenu )

coloremoji$ = "<body><center><font style='font-family:segoe ui emoji;font-size:188pt'>&#129409</font></body>"

WebGadget (10, 0, 0, 822, 450, "about:" + coloremoji$) 

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow  
The key is using the "Segoe UI Emoji" font (part of a default Windows 10 installation - not sure about earlier versions).

Re: emojis in webgadget showing without colors

Posted: Sun May 24, 2020 4:55 pm
by IdeasVacuum
If consistency is required, you either have to deliver the coloured font with your program or use images instead.

Re: emojis in webgadget showing without colors

Posted: Sun May 24, 2020 9:03 pm
by ricardo
IdeasVacuum wrote: See: http://classic.getemoji.com
Anybody see this in black and white??

Re: emojis in webgadget showing without colors

Posted: Sun May 24, 2020 9:09 pm
by ricardo
firace wrote:Works here:

Code: Select all

OpenWindow(1, 0, 0, 822, 450, "", #PB_Window_ScreenCentered | #PB_Window_SystemMenu )

coloremoji$ = "<body><center><font style='font-family:segoe ui emoji;font-size:188pt'>&#129409</font></body>"

WebGadget (10, 0, 0, 822, 450, "about:" + coloremoji$) 

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow  
The key is using the "Segoe UI Emoji" font (part of a default Windows 10 installation - not sure about earlier versions).
Great!! Thanks !!

Re: emojis in webgadget showing without colors

Posted: Mon Apr 14, 2025 1:15 pm
by Little John
Hi, I stumbled across this old thread.
Very interesting, and thanks once more to firace for instructive code!

What I want to do is, showing the glyph of a red heart.

It works fine here with firace's above code (PB 6.20 on Windows 11):

Code: Select all

OpenWindow(1, 0, 0, 822, 450, "", #PB_Window_ScreenCentered | #PB_Window_SystemMenu )

coloremoji$ = "<body><center><font style='font-family:segoe ui emoji;font-size:188pt'>&#x2764;&#xFE0F;</font></body>"

WebGadget (10, 0, 0, 822, 450, "about:" + coloremoji$) 

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow 

However, I actually want to show the red heart as part of a string in a textgadget.
I believed the following code should do it, because the font “Segoe UI Emoji” does contain the colored glyph.
So why does this code show a black heart, rather than a red one?

Code: Select all

Define font$

If OpenWindow(0, 100, 100, 150, 100, "Heart") = 0
   MessageRequester("Fatal error", "Can't open main window.", #PB_MessageRequester_Error)
   End
EndIf   

font$ = "Segoe UI Emoji"
If LoadFont(0, font$, 9)
   SetGadgetFont(#PB_Default, FontID(0))
Else
   Debug "Can't load font: " + font$
EndIf

TextGadget  (0, 15, 10, 120, 20, "Made with " + Chr($2764) + Chr($FE0F))
StringGadget(1, 10, 40, 120, 20, "Made with " + Chr($2764) + Chr($FE0F))

Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow

Re: emojis in webgadget showing without colors

Posted: Mon Apr 14, 2025 4:22 pm
by breeze4me
@Little John

The common controls in Windows don't support emoji colors, regardless of font, because the GDI string output functions don't support them. As far as I know, to output the colors of emoji characters, you have to draw a string using DirectWrite.

For example:
https://gist.github.com/nickav/ed3428fb ... 88956a7b22

Re: emojis in webgadget showing without colors

Posted: Mon Apr 14, 2025 7:22 pm
by Little John
@breeze4me:
I see. Many thanks for the information!