Hello,
I would like to have the option to include a font file without having to write it to disk before loading (if that's possible).
RegisterFontFile from Memory
RegisterFontFile from Memory
Good morning, that's a nice tnetennba!
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
- deeproot
- Enthusiast
- Posts: 284
- Joined: Thu Dec 17, 2009 12:00 pm
- Location: Llangadog, Wales, UK
- Contact:
Re: RegisterFontFile from Memory
See this thread - - https://www.purebasic.fr/english/viewtopic.php?p=455022
For Windows it's quite straightforward, loading direct from a font file embedded in the data section - simple example:
For Windows it's quite straightforward, loading direct from a font file embedded in the data section - simple example:
Code: Select all
;
; Change the font filename and LoadFont as needed !!!
;
EnableExplicit
Enumeration
#Win1
#Text1
#DejaVuSansBold
EndEnumeration
Define myMemFont
Procedure CatchFont(*Memory, myMemSize)
; load font into memory
Protected myParam1 = 1
ProcedureReturn AddFontMemResourceEx_(*Memory, myMemSize, 0, @myParam1)
EndProcedure
If OpenWindow(#Win1, 0, 0, 460,100,"Font test", #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_ScreenCentered)
myMemFont = CatchFont(?dejafont, ?end_dejafont - ?dejafont)
LoadFont(#DejaVuSansBold, "DejaVu Sans", 12, #PB_Font_Bold)
TextGadget(#Text1, 20,40,420,25, "The quick brown fox jumps over the lazy dog")
SetGadgetFont(#Text1, FontID(#DejaVuSansBold))
EndIf
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
DataSection
dejafont:
IncludeBinary "DejaVuSans-Bold.ttf"
end_dejafont:
EndDataSection
Re: RegisterFontFile from Memory
Yes, Windows. My program is meant to run on Windows and Raspi.
Good morning, that's a nice tnetennba!
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
-
- Addict
- Posts: 1520
- Joined: Wed Nov 12, 2008 5:01 pm
- Location: Russia
Re: RegisterFontFile from Memory
It doesn't work with VectorDrawing.AddFontMemResourceEx
Re: RegisterFontFile from Memory
Yes, the help also tells so. But that's not important for me.
It's just that I need a specific font that almost all systems don't have installed. And I wanted to avoid writing it temporarily onto the harddisk.
It's just that I need a specific font that almost all systems don't have installed. And I wanted to avoid writing it temporarily onto the harddisk.
Good morning, that's a nice tnetennba!
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD