Help, I'm lost trying to automatically install fonts to WinXP.
It is easy enough to copy the fonts in to the proper directory using my installation routine. For Win98SE, all that was needed was a reboot for the fonts to be installed.
On WinXP, the fonts don't become active until they are "installed" using the Fonts dialog. (at least, I can't get them installed automatically.)
Can anyone give me a clue how to do this automatically? Either using a PB program or some command I am missing in an InnoSetup process?
TIA,
Terry
WinXP Font Installation Help Needed
-
- Enthusiast
- Posts: 781
- Joined: Fri Apr 25, 2003 6:51 pm
- Location: NC, USA
- Contact:
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
http://windowssdk.msdn.microsoft.com/en ... 33960.aspx
From what I can gather reading this, you would drop the .ttf file in the %windows%/fonts folder and then call AddFontResource and do the SendMessage_(), which should install it permanently and make it immediately available to all currently running programs. You'd want to avoid AddFontResourceEx as it seems to be tailored to installing fonts as private to an application.
Hm. Further reading under AddFontResource indicates that it won't be permanent until you put the font info in the registry. I have no idea where.
From what I can gather reading this, you would drop the .ttf file in the %windows%/fonts folder and then call AddFontResource and do the SendMessage_(), which should install it permanently and make it immediately available to all currently running programs. You'd want to avoid AddFontResourceEx as it seems to be tailored to installing fonts as private to an application.
Hm. Further reading under AddFontResource indicates that it won't be permanent until you put the font info in the registry. I have no idea where.
BERESHEIT
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
OK, a bit of further research and testing produced a working procedure to accomplish the task. I downloaded a free ttf font called "Trashed" and tested it with the procedure. It was immediately available to programs system-wide, and remained persistent after a reboot. So - success. (I hope
)

Code: Select all
Procedure.l WriteRegKey(OpenKey.l, SubKey$, KeySet$, KeyValue$)
hKey.l = 0
If RegCreateKey_(OpenKey, SubKey$, @hKey) = 0
Result = 1
Datasize.l = Len(KeyValue$)
If RegSetValueEx_(hKey, KeySet$, 0, #REG_SZ, @KeyValue$, Datasize) = 0
Result = 2
EndIf
RegCloseKey_(hKey)
EndIf
ProcedureReturn Result
EndProcedure
Procedure InstallFont(Fontname$,FontFilename$)
Protected Fontdir$,key$
If AddFontResource_(FontFilename$)
Fontdir$ = GetEnvironmentVariable("windir")+ "\Fonts\"
If CopyFile(FontFilename$,Fontdir$ + FontFilename$)
SendMessage_(#HWND_BROADCAST, #WM_FONTCHANGE, 0, 0)
Select OSVersion()
Case #PB_OS_Windows_95,#PB_OS_Windows_98,#PB_OS_Windows_ME
key$ = "SOFTWARE\Microsoft\Windows\CurrentVersion\Fonts"
Default
key$ = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts"
EndSelect
If WriteRegKey(#HKEY_LOCAL_MACHINE, key$, Fontname$, FontFilename$)
ProcedureReturn 1
Else
ProcedureReturn 0
EndIf
Else
ProcedureReturn 0
EndIf
Else
ProcedureReturn 0
EndIf
EndProcedure
Debug InstallFont("TRASHED","Trashed.ttf")
BERESHEIT
-
- Enthusiast
- Posts: 781
- Joined: Fri Apr 25, 2003 6:51 pm
- Location: NC, USA
- Contact:
HELL YA!rsts wrote:This forum is an amazing resource.
cheers
ya... netmaestro you rock!
Repeat this sequence out loud:
*say hare krishna twice
*then say krishna twice
*then say hare twice
*then do the whole thing with rama instead of krishna
if you do this correctly, a representative will appear with further instructions
*say hare krishna twice
*then say krishna twice
*then say hare twice
*then do the whole thing with rama instead of krishna
if you do this correctly, a representative will appear with further instructions
- NoahPhense
- Addict
- Posts: 1999
- Joined: Thu Oct 16, 2003 8:30 pm
- Location: North Florida
netmaestro,
sorry to bother you sir. do you know what i can change in your code to make it work with Type1 fonts (*.pfm & *.pfb pairs)?
:roll:
sorry to bother you sir. do you know what i can change in your code to make it work with Type1 fonts (*.pfm & *.pfb pairs)?
:roll:
Repeat this sequence out loud:
*say hare krishna twice
*then say krishna twice
*then say hare twice
*then do the whole thing with rama instead of krishna
if you do this correctly, a representative will appear with further instructions
*say hare krishna twice
*then say krishna twice
*then say hare twice
*then do the whole thing with rama instead of krishna
if you do this correctly, a representative will appear with further instructions