Works on Windows 7 x86, Windows 8 x64
Code:
EnableExplicit
Procedure CatchFont(*Memory, lMemSize)
Protected lParam1 = 1
ProcedureReturn AddFontMemResourceEx_(*Memory, lMemSize, 0, @lParam1)
EndProcedure
Procedure FreeCatchFont(lMemFont)
ProcedureReturn RemoveFontMemResourceEx_(lMemFont)
EndProcedure
Procedure Main()
Protected lMemFont = CatchFont(?cf1s, ?cf1e - ?cf1s)
Protected lGuiFont = LoadFont(#PB_Any, "DOSEGA", 16) ; <<< Customize
If lMemFont And lGuiFont
If OpenWindow(0, #PB_Ignore, #PB_Ignore, 440, 80,"CatchFont Demo", #PB_Window_SystemMenu)
SetGadgetFont(#PB_Default, FontID(lGuiFont))
TextGadget(0,10,10,400,20,"CatchFont Demo")
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
CloseWindow(0)
Else
MessageRequester("CatchFont Demo Error", "Couldn't open main window.", #MB_OK | #MB_ICONERROR)
EndIf
Else
MessageRequester("CatchFont Demo Error", "Couldn't load font from memory.", #MB_OK | #MB_ICONERROR)
EndIf
FreeCatchFont(lMemFont)
FreeFont(lGuiFont)
EndProcedure
Main() : End
DataSection
cf1s:
IncludeBinary "DOSEGA.ttf" ; <<< Customize
cf1e:
EndDataSection