Change gadget font

Linux specific forum
Beach
Enthusiast
Enthusiast
Posts: 677
Joined: Mon Feb 02, 2004 3:16 am
Location: Beyond the sun...

Change gadget font

Post by Beach »

I asked this question in the beginners section but nobody replied. I really would like to know the answer.

The PB document states SetGadgetFont() is available in Linux, but none of the other accompanying functions are supported (LoadFont, UseFont).

How would I go about changing the gadget font?

Just let me know if it is even possible.
freak
PureBasic Team
PureBasic Team
Posts: 5929
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

Sorry for not answering yet.

The docs seem to be wrong here. LoadFont() is supported, and so is UseFone() afaik.
Only thing is that the 'size' and 'style' parameters of loadfont() are ignored,
because on linux you have to specify all that in the font name string.

Just run the FontRequester() and display the string it returns. This is what you
need to pass to loadfont to get the size & style you want.

Timo
quidquid Latine dictum sit altum videtur
Beach
Enthusiast
Enthusiast
Posts: 677
Joined: Mon Feb 02, 2004 3:16 am
Location: Beyond the sun...

Post by Beach »

Thanks so much Timo! That did the trick. There is one small issue, it seems that OptionGadgets do not change to the requested font as the other gadgets do. Is this normal?

Code: Select all

myfont$ = "-misc-fixed-medium-r-semicondensed-*-*-120-*-*-c-*-koi8-r"

if LoadFont(#PB_Any,myfont$,0) = #FALSE
	MessageRequester("Error","Could not load system font")
EndIf

If OpenWindow(0,174,8,170,100,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"Test Fonts")
  If CreateGadgetList(WindowID(0))
    TextGadget(1,10,10,150,25,"This is a test!!")  
    SetGadgetFont(1,FontID())
    ButtonGadget(2,10,40,150,25,"Button Text")
    SetGadgetFont(2,FontID())
    OptionGadget(3,10,70,150,25,"Option gadget") 
    SetGadgetFont(3,FontID())
  EndIf
EndIf

Repeat : Until WaitWindowEvent() = #PB_EventCloseWindow
Fred
Administrator
Administrator
Posts: 16623
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

No, there something wrong which need to be corrected. Thanks to point it out !
Post Reply