Posted: Fri Feb 08, 2002 3:18 pm
				
				Restored from previous forum. Originally posted by tinman.
Hi,
I've playing around trying to use the default font for my GUIs, using the size set in the display properties (is there any other way it can be set?). I've come up with this code, but there seems to be some problem when trying to use the font for gadgets. Can anyone point out what's going wrong? Oh, and if people would be kind enough to test it on an OS other than Win95 and let me know how it goes I'd be very grateful
If InitGadget(10)=0 : End : EndIf
If OpenConsole()=0 : End : EndIf
fnt.l = GetStockObject_(#DEFAULT_GUI_FONT)
If fnt
PrintN("Hey, got the font "+Str(SizeOf(LOGFONT)))
DefType.LOGFONT finfo
GetObject_(fnt, SizeOf(LOGFONT), @finfo)
fname$ = PeekS(@finfo\lfFaceName[0])
fsize.l = finfo\lfHeight
PrintN("Font name is "+PeekS(@finfo\lfFaceName[0])+"/"+Str(fsize))
If fsize<0 : fsize=-fsize : EndIf
LoadFont(1,fname$,8)
UseFont(1)
EndIf
mainwindow.l = OpenWindow(0,600,600,400,300,#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget,"Ty")
If mainwindow
If CreateGadgetList(WindowID())
SetGadgetFont(FontID())
ButtonGadget(1,4,50,200,30,"Ty")
EndIf
If fnt
StartDrawing(WindowOutput())
DrawingMode(1)
DrawingFont(FontID())
Locate(0,0)
FrontColour(0,0,0)
DrawText("Ty Move Size")
StopDrawing()
CloseFont(1)
EndIf
quit.w=0
While quit=0
ev.l=WaitWindowEvent()
Select ev
Case #PB_EventCloseWindow
quit = 1
EndSelect
Wend
CloseWindow(0)
EndIf
CloseConsole()
If fnt : DeleteObject_(fnt) : EndIf
End
			Hi,
I've playing around trying to use the default font for my GUIs, using the size set in the display properties (is there any other way it can be set?). I've come up with this code, but there seems to be some problem when trying to use the font for gadgets. Can anyone point out what's going wrong? Oh, and if people would be kind enough to test it on an OS other than Win95 and let me know how it goes I'd be very grateful
If InitGadget(10)=0 : End : EndIf
If OpenConsole()=0 : End : EndIf
fnt.l = GetStockObject_(#DEFAULT_GUI_FONT)
If fnt
PrintN("Hey, got the font "+Str(SizeOf(LOGFONT)))
DefType.LOGFONT finfo
GetObject_(fnt, SizeOf(LOGFONT), @finfo)
fname$ = PeekS(@finfo\lfFaceName[0])
fsize.l = finfo\lfHeight
PrintN("Font name is "+PeekS(@finfo\lfFaceName[0])+"/"+Str(fsize))
If fsize<0 : fsize=-fsize : EndIf
LoadFont(1,fname$,8)
UseFont(1)
EndIf
mainwindow.l = OpenWindow(0,600,600,400,300,#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget,"Ty")
If mainwindow
If CreateGadgetList(WindowID())
SetGadgetFont(FontID())
ButtonGadget(1,4,50,200,30,"Ty")
EndIf
If fnt
StartDrawing(WindowOutput())
DrawingMode(1)
DrawingFont(FontID())
Locate(0,0)
FrontColour(0,0,0)
DrawText("Ty Move Size")
StopDrawing()
CloseFont(1)
EndIf
quit.w=0
While quit=0
ev.l=WaitWindowEvent()
Select ev
Case #PB_EventCloseWindow
quit = 1
EndSelect
Wend
CloseWindow(0)
EndIf
CloseConsole()
If fnt : DeleteObject_(fnt) : EndIf
End