It is currently Sun May 31, 2020 12:30 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: Can be used microsoft ttf in the Linux?
PostPosted: Wed May 20, 2020 5:28 pm 
Offline
User
User

Joined: Wed May 20, 2020 5:19 pm
Posts: 11
Hello.
Have project with Times New Roman font in the forms.
Code:
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: Can be used microsoft ttf in the Linux?
PostPosted: Fri May 22, 2020 5:55 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu Jun 26, 2014 9:17 am
Posts: 312
Location: Germany
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:
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


Top
 Profile  
Reply with quote  
 Post subject: Re: Can be used microsoft ttf in the Linux?
PostPosted: Fri May 22, 2020 9:43 pm 
Offline
User
User

Joined: Wed May 20, 2020 5:19 pm
Posts: 11
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: Can be used microsoft ttf in the Linux?
PostPosted: Fri May 22, 2020 10:42 pm 
Offline
Always Here
Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 6179
Location: Wales, UK
... 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.

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Last edited by IdeasVacuum on Sun May 24, 2020 4:04 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Can be used microsoft ttf in the Linux?
PostPosted: Sat May 23, 2020 11:13 am 
Offline
User
User

Joined: Wed May 20, 2020 5:19 pm
Posts: 11
IdeasVacuum wrote:
, it cannot be the same constant used for a Gadget ID

I am agreed with you, but PureVision author not sure.


Top
 Profile  
Reply with quote  
 Post subject: Re: Can be used microsoft ttf in the Linux?
PostPosted: Sat May 23, 2020 7:04 pm 
Offline
User
User

Joined: Wed May 20, 2020 5:19 pm
Posts: 11
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:
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 :(


Top
 Profile  
Reply with quote  
 Post subject: Re: Can be used microsoft ttf in the Linux?
PostPosted: Sat May 23, 2020 8:24 pm 
Offline
User
User

Joined: Wed May 20, 2020 5:19 pm
Posts: 11
Checked situation with small program
Code:
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


Top
 Profile  
Reply with quote  
 Post subject: Re: Can be used microsoft ttf in the Linux?
PostPosted: Sat May 23, 2020 8:57 pm 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Fri Apr 25, 2003 4:34 pm
Posts: 958
Location: Canada
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:
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:
#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


Top
 Profile  
Reply with quote  
 Post subject: Re: Can be used microsoft ttf in the Linux?
PostPosted: Sun May 24, 2020 4:01 am 
Offline
Always Here
Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 6179
Location: Wales, UK
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: Can be used microsoft ttf in the Linux?
PostPosted: Sun May 24, 2020 7:10 am 
Offline
Enthusiast
Enthusiast

Joined: Thu Jun 26, 2014 9:17 am
Posts: 312
Location: Germany
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


Top
 Profile  
Reply with quote  
 Post subject: Re: Can be used microsoft ttf in the Linux?
PostPosted: Tue May 26, 2020 2:50 pm 
Offline
User
User

Joined: Wed May 20, 2020 5:19 pm
Posts: 11
Hi.
Needs to open bug report ?


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye