TextGadget colours in Ubuntu 18.04

Linux specific forum
User avatar
marcoagpinto
Addict
Addict
Posts: 940
Joined: Sun Mar 10, 2013 3:01 pm
Location: Portugal
Contact:

TextGadget colours in Ubuntu 18.04

Post by marcoagpinto »

Hello!

Using sublibrary "gtk2" and Ubuntu 18.04:

I use a TextGadget with some text and an emoji and I change the colour of the gadget to #Red.

In Windows the gadget becomes all red, in Ubuntu 18.04 it gets the text red and the emoji black.

See screenshot:
Ubuntu 18.04:
Image

Windows 10:
Image
#NULL
Addict
Addict
Posts: 1440
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Re: [PB5.62] TextGadget colours in Ubuntu 18.04

Post by #NULL »

<edit>: I don't have Ubuntu 18 at hand.

I can't confirm that, and that would be weird! What character is it? Are you sure there are not multiple TextGadgets? In the Windows screenshot there is a colon ':' in black too!
Works:

Code: Select all

win = OpenWindow(#PB_Any, 50,100, 800, 600, "window")

t = TextGadget(#PB_Any, 10, 10, 100, 30, "button " + Chr(9872))
SetGadgetColor(t, #PB_Gadget_FrontColor, #Red)

t = TextGadget(#PB_Any, 10, 30, 100, 30, "button " + Chr(9873))
SetGadgetColor(t, #PB_Gadget_FrontColor, #Red)

Repeat
  WaitWindowEvent()
Until Event() = #PB_Event_CloseWindow
User avatar
marcoagpinto
Addict
Addict
Posts: 940
Joined: Sun Mar 10, 2013 3:01 pm
Location: Portugal
Contact:

Re: [PB5.62] TextGadget colours in Ubuntu 18.04

Post by marcoagpinto »

#NULL wrote:<edit>: I don't have Ubuntu 18 at hand.

I can't confirm that, and that would be weird! What character is it? Are you sure there are not multiple TextGadgets? In the Windows screenshot there is a colon ':' in black too!
Works:

Code: Select all

win = OpenWindow(#PB_Any, 50,100, 800, 600, "window")

t = TextGadget(#PB_Any, 10, 10, 100, 30, "button " + Chr(9872))
SetGadgetColor(t, #PB_Gadget_FrontColor, #Red)

t = TextGadget(#PB_Any, 10, 30, 100, 30, "button " + Chr(9873))
SetGadgetColor(t, #PB_Gadget_FrontColor, #Red)

Repeat
  WaitWindowEvent()
Until Event() = #PB_Event_CloseWindow
Hello!

The forums don't accept emoji, so here is the chr:
https://pastebin.com/7ND2jPCv

I tried a DEBUG ASC("symbol above here") and it gets 55356.

But if I try:

Code: Select all

win = OpenWindow(#PB_Any, 50,100, 800, 600, "window")

t = TextGadget(#PB_Any, 10, 10, 100, 30, "button " + Chr(55356))
SetGadgetColor(t, #PB_Gadget_FrontColor, #Red)

t = TextGadget(#PB_Any, 10, 30, 100, 30, "button " + Chr(9873))
SetGadgetColor(t, #PB_Gadget_FrontColor, #Red)

Repeat
  WaitWindowEvent()
Until Event() = #PB_Event_CloseWindow
I get a blank gadget in Ubuntu and two corrupted characters in Windows 10.
It is strange, because if I paste the emoji directly into the IDE, it appears a flag.
#NULL
Addict
Addict
Posts: 1440
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Re: [PB5.62] TextGadget colours in Ubuntu 18.04

Post by #NULL »

Maybe its a multibyte/multichar sequence and works only as string but not as single character. Any problem with using a string literal? (can't post it, getting forum sql error).
IdeasVacuum
Always Here
Always Here
Posts: 6425
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: [PB5.62] TextGadget colours in Ubuntu 18.04

Post by IdeasVacuum »

Hi Marco

The character number is outside of the ASCII range, into Unicode, so prefix the number thus:

Code: Select all

Chr($55356)
... but another issue is, everyone that uses your app must have the font you use that contains that character. Most fonts do not. If you have a license for the font to distribute, all is well, otherwise I would suggest using a tiny PNG on a tiny Canvas instead.

Edit: I just noticed that the debugger window, using the DejaVu font, gives a different symbol...... (Win 7)
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
marcoagpinto
Addict
Addict
Posts: 940
Joined: Sun Mar 10, 2013 3:01 pm
Location: Portugal
Contact:

Re: [PB5.62] TextGadget colours in Ubuntu 18.04

Post by marcoagpinto »

IdeasVacuum wrote:Hi Marco

The character number is outside of the ASCII range, into Unicode, so prefix the number thus:

Code: Select all

Chr($55356)
... but another issue is, everyone that uses your app must have the font you use that contains that character. Most fonts do not. If you have a license for the font to distribute, all is well, otherwise I would suggest using a tiny PNG on a tiny Canvas instead.

Edit: I just noticed that the debugger window, using the DejaVu font, gives a different symbol...... (Win 7)
I am using a font compatible with all OSes:

Code: Select all

  Procedure load_fonts()
    
    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
    
    
    t=LoadFont(2,"Arial",8,#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))
    
  EndProcedure
Post Reply