Page 1 of 1

TextGadget colours in Ubuntu 18.04

Posted: Tue Jul 31, 2018 7:07 pm
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

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

Posted: Wed Aug 01, 2018 7:39 am
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

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

Posted: Wed Aug 01, 2018 9:31 am
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.

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

Posted: Wed Aug 01, 2018 9:58 am
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).

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

Posted: Wed Aug 01, 2018 10:24 pm
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)

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

Posted: Wed Aug 01, 2018 10:40 pm
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