Can be used microsoft ttf in the Linux?

Linux specific forum
dibor
Enthusiast
Enthusiast
Posts: 125
Joined: Wed May 20, 2020 5:19 pm
Location: The 3rd planet in the Solar System
Contact:

Can be used microsoft ttf in the Linux?

Post 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.
Mac Studio M1Max, PB 6.03Arm64 and x64.
Macbook Air M2, PB 6.03Arm64 and x64.
Windows 10, PB 6.03 x64 and x86.
Oma
Enthusiast
Enthusiast
Posts: 312
Joined: Thu Jun 26, 2014 9:17 am
Location: Germany

Re: Can be used microsoft ttf in the Linux?

Post 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
PureBasic 5.4-5.7, Linux: (X/L/K)Ubuntus+Mint - Windows XP (32Bit)
PureBasic Linux-API-Library & Viewer: http://www.chabba.de
dibor
Enthusiast
Enthusiast
Posts: 125
Joined: Wed May 20, 2020 5:19 pm
Location: The 3rd planet in the Solar System
Contact:

Re: Can be used microsoft ttf in the Linux?

Post 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.
Mac Studio M1Max, PB 6.03Arm64 and x64.
Macbook Air M2, PB 6.03Arm64 and x64.
Windows 10, PB 6.03 x64 and x86.
IdeasVacuum
Always Here
Always Here
Posts: 6425
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Can be used microsoft ttf in the Linux?

Post 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.
Last edited by IdeasVacuum on Sun May 24, 2020 4:04 am, edited 1 time in total.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
dibor
Enthusiast
Enthusiast
Posts: 125
Joined: Wed May 20, 2020 5:19 pm
Location: The 3rd planet in the Solar System
Contact:

Re: Can be used microsoft ttf in the Linux?

Post 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.
Mac Studio M1Max, PB 6.03Arm64 and x64.
Macbook Air M2, PB 6.03Arm64 and x64.
Windows 10, PB 6.03 x64 and x86.
dibor
Enthusiast
Enthusiast
Posts: 125
Joined: Wed May 20, 2020 5:19 pm
Location: The 3rd planet in the Solar System
Contact:

Re: Can be used microsoft ttf in the Linux?

Post 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 :(
Mac Studio M1Max, PB 6.03Arm64 and x64.
Macbook Air M2, PB 6.03Arm64 and x64.
Windows 10, PB 6.03 x64 and x86.
dibor
Enthusiast
Enthusiast
Posts: 125
Joined: Wed May 20, 2020 5:19 pm
Location: The 3rd planet in the Solar System
Contact:

Re: Can be used microsoft ttf in the Linux?

Post 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
Mac Studio M1Max, PB 6.03Arm64 and x64.
Macbook Air M2, PB 6.03Arm64 and x64.
Windows 10, PB 6.03 x64 and x86.
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1243
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Re: Can be used microsoft ttf in the Linux?

Post 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)
Image Image
IdeasVacuum
Always Here
Always Here
Posts: 6425
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Can be used microsoft ttf in the Linux?

Post 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.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Oma
Enthusiast
Enthusiast
Posts: 312
Joined: Thu Jun 26, 2014 9:17 am
Location: Germany

Re: Can be used microsoft ttf in the Linux?

Post 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"!
PureBasic 5.4-5.7, Linux: (X/L/K)Ubuntus+Mint - Windows XP (32Bit)
PureBasic Linux-API-Library & Viewer: http://www.chabba.de
dibor
Enthusiast
Enthusiast
Posts: 125
Joined: Wed May 20, 2020 5:19 pm
Location: The 3rd planet in the Solar System
Contact:

Re: Can be used microsoft ttf in the Linux?

Post by dibor »

Hi.
Needs to open bug report ?
Mac Studio M1Max, PB 6.03Arm64 and x64.
Macbook Air M2, PB 6.03Arm64 and x64.
Windows 10, PB 6.03 x64 and x86.
Post Reply