Page 1 of 1

Can be used microsoft ttf in the Linux?

Posted: Wed May 20, 2020 5:28 pm
by dibor
Hello.
Have project with Times New Roman font in the forms.

Code: Select all

SetGadgetFont(#Gadget_MainWindow_UTC_Time,LoadFont(#Gadget_MainWindow_UTC_Time,"Times New Roman",18))
In the windows and OSX font looks good, but in the Linux forms shows other font.
Linux has this font and I can see it in the system properties.

I use Suse Desktop 15.1 and PureBasic 5.72
Thank you.

Re: Can be used microsoft ttf in the Linux?

Posted: Fri May 22, 2020 5:55 pm
by Oma
Works perfectly here with the fonts from fonts-liberation package.
But your call is not correct.
Try it like this (and read the help please ;-)) ...

Code: Select all

SetGadgetFont(#Gadget_MainWindow_UTC_Time, FontId(LoadFont(#PB_Any, "Times New Roman", 18)))
Regards, Charly

Re: Can be used microsoft ttf in the Linux?

Posted: Fri May 22, 2020 9:43 pm
by dibor
Thank you Charly.
Code was generated by PureVision without #PV_Any, use constants.
This code is works under Windoz and MacOS.
Will change code and will report to PureVision author about wrong code generation.

Thank you again.

Re: Can be used microsoft ttf in the Linux?

Posted: Fri May 22, 2020 10:42 pm
by IdeasVacuum
... A constant can be used for Font ID, but it must be unique, it cannot be the same constant used for a Gadget ID - that is the fault in the code.

Edit: My statement above is wrong - of course you can use a constant as an ID for different items. Not good practice though because the code can become confusing.

Re: Can be used microsoft ttf in the Linux?

Posted: Sat May 23, 2020 11:13 am
by dibor
IdeasVacuum wrote:, it cannot be the same constant used for a Gadget ID
I am agreed with you, but PureVision author not sure.

Re: Can be used microsoft ttf in the Linux?

Posted: Sat May 23, 2020 7:04 pm
by dibor
Oma wrote:Works perfectly here with the fonts from fonts-liberation package.
But your call is not correct.
Try it like this (and read the help please ;-)) ...

Code: Select all

SetGadgetFont(#Gadget_MainWindow_UTC_Time, FontId(LoadFont(#PB_Any, "Times New Roman", 18)))
Regards, Charly
I did in this way - anyway do not see Times New Roman font under linux Ubuntu 20.04 and Suse Desktop 15.1
Font exist and I can to use it as system font or as font in the Pure Basic editor, but do not see it in the compiled program :(
Looks like I am stupid at all :(

Re: Can be used microsoft ttf in the Linux?

Posted: Sat May 23, 2020 8:24 pm
by dibor
Checked situation with small program

Code: Select all

FontName$ = "Times New Roman"

If OpenWindow(0, 0, 0, 300, 160, "Loading font...", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  Result = FontRequester(FontName$, 14, 0, RGB(0, 0, 0), #PB_Font_Bold)
  If LoadFont(1, SelectedFontName(), SelectedFontSize() )
    SetGadgetFont(#PB_Default, FontID(1))
    TextGadget(0, 10, 10, 300, 40, SelectedFontName()+" "+Str(SelectedFontSize()) )
  EndIf
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
While choosing font font looks as should
https://1drv.ms/u/s!Auurs2F0cQKFgaNmSMeBJ_n2cUYLVA
But after looks not right:
https://1drv.ms/u/s!Auurs2F0cQKFgaNnE63pJP-X6vooLw

Re: Can be used microsoft ttf in the Linux?

Posted: Sat May 23, 2020 8:57 pm
by Paul
IdeasVacuum wrote:... A constant can be used for Font ID, but it must be unique, it cannot be the same constant used for a Gadget ID - that is the fault in the code.
This is an incorrect statement.
Look at this code, both Gadgets and Fonts have a unique constant yet the Gadget shares the same value as the Font.

Code: Select all

OpenWindow(0,0,0,200,100,"Work Form1",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
TextGadget(1,10,10,100,20,"Hello")
LoadFont(1,"Arial",12,#PB_Font_Bold)
SetGadgetFont(1,FontID(1))

TextGadget(2,10,30,100,20,"Hello")
LoadFont(2,"Arial",12,#PB_Font_Italic)
SetGadgetFont(2,FontID(2))
Repeat:Until WaitWindowEvent()=#PB_Event_CloseWindow
The same code can be written as...

Code: Select all

#Constant1=1
#Constant2=2

OpenWindow(0,0,0,200,100,"Work Form1",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
TextGadget(#Constant1,10,10,100,20,"Hello")
SetGadgetFont(#Constant1,LoadFont(#Constant1,"Arial",12,#PB_Font_Bold))

TextGadget(#Constant2,10,30,100,20,"Hello")
SetGadgetFont(#Constant2,LoadFont(#Constant2,"Arial",12,#PB_Font_Italic))
Repeat:Until WaitWindowEvent()=#PB_Event_CloseWindow

Maybe his code snippet seemed wrong because it is out of context, you do not see the code in it's entirety.
You do not want to have duplicate Gadget constants or duplicate Font constants but a Gadget can certainly have the same constant value as a Font.


As for the "Times New Roman" font not showing in Linux, I experience the same issue as dibor when testing on Linux Mint 19 with the code FontRequester code he posted.
The font Previews fine when using the FontRequester but does not display as "Times New Roman" in the Text Gadget. (it subs it with Arial or similar)

Re: Can be used microsoft ttf in the Linux?

Posted: Sun May 24, 2020 4:01 am
by IdeasVacuum
Yes you are right Paul, it's not good practice to use the same constant but there are many circumstances where it can be done.

Re: Can be used microsoft ttf in the Linux?

Posted: Sun May 24, 2020 7:10 am
by Oma
Today I can confirm this behaviour. Got the same problem now.

Apparently the shortened expression "Times" instead of "Times New Roman" is better recognized in Linux (or PB?).

ps:
Maybe a problem with spaces, because "TimesNewRoman" also works better than "Times New Roman"!

Re: Can be used microsoft ttf in the Linux?

Posted: Tue May 26, 2020 2:50 pm
by dibor
Hi.
Needs to open bug report ?