Change font size of gadgets
Change font size of gadgets
How I can change the font size only? I can reset the default gadget font for all gadgets. But I do not want to change the default font of the operating system (I don't know which font is used), only the size...
- RSBasic
- Moderator
- Posts: 1228
- Joined: Thu Dec 31, 2009 11:05 pm
- Location: Gernsbach (Germany)
- Contact:
Re: Change font size of gadgets
Code: Select all
EnableExplicit
Define NONCLIENTMETRICS.NONCLIENTMETRICS
NONCLIENTMETRICS\cbSize = SizeOf(NONCLIENTMETRICS)
SystemParametersInfo_(#SPI_GETNONCLIENTMETRICS, 0, NONCLIENTMETRICS, 0)
LoadFont(1, PeekS(@NONCLIENTMETRICS\lfCaptionFont\lfFaceName[0]), 20)
If OpenWindow(0, 0, 0, 500, 400, "Window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
SetGadgetFont(#PB_Default, FontID(1))
ButtonGadget(1, 10, 10, 100, 30, "Button")
TextGadget(2, 10, 50, 100, 30, "Hello")
CheckBoxGadget(3, 10, 100, 100, 30, "Checkbox")
Repeat
Select WaitWindowEvent()
Case #PB_Event_Gadget
Select EventGadget()
Case 1
EndSelect
Case #PB_Event_CloseWindow
End
EndSelect
ForEver
EndIf
Re: Change font size of gadgets
Windows only
Code: Select all
LoadFont(0, "MS Shell Dlg", 8)
SetGadgetFont(#PB_Default, FontID(0))
OpenWindow(0, 0, 0, 320, 200, "", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
ButtonGadget(0, 10, 10, 100, 30, "Button")
TextGadget(1, 10, 50, 100, 30, "Hello")
CheckBoxGadget(2, 10, 100, 100, 30, "Checkbox")
While WaitWindowEvent() <> #PB_Event_CloseWindow : Wend
Code: Select all
GetObject_(GetStockObject_(#DEFAULT_GUI_FONT), SizeOf(LOGFONT), @lf.LOGFONT)
Debug PeekS(@lf\lfFaceName[0])
Et cetera is my worst enemy
Re: Change font size of gadgets
Code: Select all
FID = GetGadgetFont(#PB_Default)
fnt.LOGFONT
GetObject_(FID,SizeOf(fnt),@fnt)
FName$ = PeekS(@fnt\lfFaceName[0])
LoadFont(0,Fname$,18)
SetGadgetFont(#PB_Default,FontID(0))
If OpenWindow(0, 0, 0, 500, 400, "Window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ButtonGadget(1, 10, 10, 100, 30, "Button")
TextGadget(2, 10, 50, 100, 30, "Hello")
CheckBoxGadget(3, 10, 100, 140, 30, "Checkbox")
Repeat
Select WaitWindowEvent()
Case #PB_Event_Gadget
Select EventGadget()
Case 1
EndSelect
Case #PB_Event_CloseWindow
End
EndSelect
ForEver
EndIf
Egypt my love
Re: Change font size of gadgets
Thanks, it seems there is no solution with PB possible, only for Windows with API functions...
Re: Change font size of gadgets
8 years later, a pb solution:
Code: Select all
; FID = GetGadgetFont(#PB_Default)
; fnt.LOGFONT
; GetObject_(FID,SizeOf(fnt),@fnt)
; FName$ = PeekS(@fnt\lfFaceName[0]):Debug FName$
LoadFont(0,"",18)
SetGadgetFont(#PB_Default,FontID(0))
If OpenWindow(0, 0, 0, 500, 400, "Window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ButtonGadget(1, 10, 10, 100, 30, "Button")
TextGadget(2, 10, 50, 100, 30, "Hello")
CheckBoxGadget(3, 10, 100, 140, 30, "Checkbox")
Repeat
Select WaitWindowEvent()
Case #PB_Event_Gadget
Select EventGadget()
Case 1
EndSelect
Case #PB_Event_CloseWindow
End
EndSelect
ForEver
EndIf
Re: Change font size of gadgets
Yes with PB >= v6.xx
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: Change font size of gadgets
Cool.
Is this documented anywhere?
Couldn't find anything in the help.
Is this documented anywhere?
Couldn't find anything in the help.
Just because it worked doesn't mean it works.
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
- Mindphazer
- Enthusiast
- Posts: 456
- Joined: Mon Sep 10, 2012 10:41 am
- Location: Savoie
Re: Change font size of gadgets
Works on MacOS at leastOlli wrote: Sun Jun 01, 2025 12:39 am @mesa
Hello, and thank you for this tip.Is this cross platform ?Code: Select all
LoadFont(0,"",18)
MacBook Pro 16" M4 Pro - 24 Gb - MacOS 15.4.1 - Iphone 15 Pro Max - iPad at home
...and unfortunately... Windows at work...
...and unfortunately... Windows at work...
- Mindphazer
- Enthusiast
- Posts: 456
- Joined: Mon Sep 10, 2012 10:41 am
- Location: Savoie
Re: Change font size of gadgets
I guess "" is considered as an unexisting font, so the system font is used.
Try
Code: Select all
LoadFont(0,"***",18)
MacBook Pro 16" M4 Pro - 24 Gb - MacOS 15.4.1 - Iphone 15 Pro Max - iPad at home
...and unfortunately... Windows at work...
...and unfortunately... Windows at work...