Hi!
Ok, I create an installer that include a font.
I install font to target machine.
But!😱
The font is not "registered(?)" in Windows automatically.
I have to manually open and close Fonts Dir with Control Panel.
What can I do to install a font and "register" it with Windows automagically?
Sorry for my english,
I speak only Italiano (and not so very well).
Font
58 posts
i'm not 100% sure since i didn't test it, but try the following (i used example Time New Roman):
Windows NT/2000/XP
hope it works, let us know 😛
Windows NT/2000/XP
Windows 95/98/MEWriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" \
"Times New Roman (TrueType)" "TIMES.TTF"
you can use the GetWindowsVersion function (see NSIS\functions.htm) to determine the windows version.WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Fonts" \
"Times New Roman (TrueType)" "TIMES.TTF"
hope it works, let us know 😛
Yes, yes. It works!!!🙂
Thank you.
After writing keys in registry, I need to reboot machine.
After, I find all fonts ready for applications!!!
Thank you!
Thank you.
After writing keys in registry, I need to reboot machine.
After, I find all fonts ready for applications!!!
Thank you!
There is a way of doing this without requiring a reboot.
This way involves Windows' API calls so you will need an external DLL or EXE.
First you need to call AddFontResource(lpszFilename) with the font's file name (for example: AddFontResource("TIMES.TTF"). Next you need to broadcast a message so all of the runnint applications will reload the system font table. To do so, you should use PostMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0).
If you need any help writing the DLL/EXE let me know.
KiCHiK
EDIT: If you are building an uninstaller too you will need to use RemoveFontResource(lpszFilename), and manually delete the registry entry. You will also need to send another WM_FONTCHANGE message.
This way involves Windows' API calls so you will need an external DLL or EXE.
First you need to call AddFontResource(lpszFilename) with the font's file name (for example: AddFontResource("TIMES.TTF"). Next you need to broadcast a message so all of the runnint applications will reload the system font table. To do so, you should use PostMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0).
If you need any help writing the DLL/EXE let me know.
KiCHiK
EDIT: If you are building an uninstaller too you will need to use RemoveFontResource(lpszFilename), and manually delete the registry entry. You will also need to send another WM_FONTCHANGE message.
Font
🤪 I need a DLL to call AddFontResource("TIMES.TTF") and PostMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0).
Ok.
I can use some NSIS function to do the same thing?
Sorry, but I have no idea on writing a DLL making this...😢
🤪 I need a DLL to call AddFontResource("TIMES.TTF") and PostMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0).
Ok.
I can use some NSIS function to do the same thing?
Sorry, but I have no idea on writing a DLL making this...😢
Don't worry, be happy 😁
Attached is the DLL + source.
To use it in your installation add the following code:
KiCHiK
Attached is the DLL + source.
To use it in your installation add the following code:
GetTempFileName $R0
File /oname=$R0 fonts.dll
; Change this line to your real font name.
; If it is not in the default Windows' directory wirte it's full path!
Push "MyFontName.TTF"
CallInstDLL $R0 registerFont To use it in your uninstallation add the following code:GetTempFileName $R0
File /oname=$R0 fonts.dll
; Change this line to your real font name.
; If it is not in the default Windows' directory wirte it's full path!
Push "MyFontName.TTF"
CallInstDLL $R0 unregisterFont These functions only call AddFontResource/RemoveFontResource and PostMessage so don't forget to copy/delete the font yourself and add/remove it from the registry.KiCHiK
Kichik,
Your code and dll works great, but how do you make it register more than one font? Will this work?:
GetTempFileName $R0
File /oname=$R0 fonts.dll
; Change this line to your real font name.
; If it is not in the default Windows' directory write it's full path!
Push "Font1.TTF"
CallInstDLL $R0 registerFont
Push "Font2.TTF"
CallInstDLL $R0 registerFont
Push "Font3.TTF"
CallInstDLL $R0 registerFont
Push "Font4.TTF"
CallInstDLL $R0 registerFont
Your code and dll works great, but how do you make it register more than one font? Will this work?:
GetTempFileName $R0
File /oname=$R0 fonts.dll
; Change this line to your real font name.
; If it is not in the default Windows' directory write it's full path!
Push "Font1.TTF"
CallInstDLL $R0 registerFont
Push "Font2.TTF"
CallInstDLL $R0 registerFont
Push "Font3.TTF"
CallInstDLL $R0 registerFont
Push "Font4.TTF"
CallInstDLL $R0 registerFont
Your code should work just fine.
did not work in nsis 2.0 alpha 🙁
Could you be a little bit more specific please?
Just to remind you: NSIS 2.0a0 is not free of bugs! The latest supported and official version is NSIS 1.98. I suggest that you use that one for compiling your scripts.
-Hendri.
-Hendri.
I followed all the instructions above, but when I run the installer, this happens:
rosInst.exe - Bad Image
The application or DLL G:\Documen~1\Markri~Locals~1\Tempnst964.tmp is not a valid Windows image. Please check this against your installation disk.
my script file is attached.
Any help would be most appreciated.
[edit]
I'm on an XP Pro system.
rosInst.exe - Bad Image
The application or DLL G:\Documen~1\Markri~Locals~1\Tempnst964.tmp is not a valid Windows image. Please check this against your installation disk.
my script file is attached.
Any help would be most appreciated.
[edit]
I'm on an XP Pro system.
Are you using using about NSIS 2 or 1.98/9?
I used both 1.96 and now 1.98.
Please try the attached script and tell me which messages you get.
Don't forget to change the file extension to .nsi.
Don't forget to change the file extension to .nsi.
Originally posted by ParallaxTZ
I followed all the instructions above, but when I run the installer, this happens:
rosInst.exe - Bad Image
The application or DLL G:\Documen~1\Markri~Locals~1\Tempnst964.tmp is not a valid Windows image. Please check this against your installation disk.
my script file is attached.
Any help would be most appreciated.
I'm on an XP Pro system.
GetTempFileName $R0You are using GetTempFileName. This creates the temp file. The File command does not overwrite the file created by GetTempFileName, that's why the DLL does not work.
File /oname=$R0 G:\windows\system32\fonts.dll
Push "MAEL____.TTF"
CallInstDLL $R0 registerFont
You should SetOverwrite On before the File command.
GetTempFileName $R0I have not tested this 😉
SetOverwrite On
File /oname=$R0 G:\windows\system32\fonts.dll
SetOverwrite ifnewer
Push "MAEL____.TTF"
CallInstDLL $R0 registerFont
Thanks to both of you, but only Joost's fix worked. Thanks again, no more restarts after my installer, YAY! 😁
i had no errors during the compilation, but it just didnt install or copy the fonts. maybe i am stupid, could you please paste some code doing this with a common windows font, so it will work in my code only copy+pasted? pleeease 😉
All of the code you need to copy+paste it up there 👍
Attached is my .nsi file (.zipped since you can't upload .nsi files), it appears to work perfectly for both 9x based and NT based systems. Hopefully you can follow it.
can i use the same .dll to uninstall the font again? it would surely be better -even for testing purposes- to remove the font everytime for the system i'm testing on. so far i had to send all installers to friends, which consumes quite some time. uninstalling would be a great help!
You can use the same DLL for uninstalling... Please check the code above...
is it necessary to use that .dll for old .fon fonts, or can i just copy them without registering them?
As far as I know you should register them too.
Reminder
Just a little reminder that since NSIS 2.0a4 you can make this kinda thing:-
Just a little reminder that since NSIS 2.0a4 you can make this kinda thing:-
GetTempFileName $R0
File /oname=$R0 fonts.dll
Push "Font1.TTF"
CallInstDLL $R0 registerFont
Push "Font2.TTF"
CallInstDLL $R0 registerFont
Push "Font3.TTF"
CallInstDLL $R0 registerFont
Push "Font4.TTF"
CallInstDLL $R0 registerFont much simpler:-fonts::registerFont "Font1.TTF"
fonts::registerFont "Font2.TTF"
fonts::registerFont "Font3.TTF"
fonts::registerFont "Font4.TTF" Sorry to bring up and old topic, but...
I'm still not clear on how to register a font without rebooting... 😕
I'm still not clear on how to register a font without rebooting... 😕
Put Fonts.dll in your Plugins directory.
After you copy the font over and write the registry entries, just call Fonts::registerFont "FontName"
If you have installed the font in the Windows font folder, just use its name (times.ttf for example), if not use its full path ($INSTDIR\times.ttf for example).
That's it, the font is then registered, and you don't need a reboot.
For the uninstaller, remove the registry entries, call Fonts::unregisterFont "FontName" and delete the font.
After you copy the font over and write the registry entries, just call Fonts::registerFont "FontName"
If you have installed the font in the Windows font folder, just use its name (times.ttf for example), if not use its full path ($INSTDIR\times.ttf for example).
That's it, the font is then registered, and you don't need a reboot.
For the uninstaller, remove the registry entries, call Fonts::unregisterFont "FontName" and delete the font.
I can't find Fonts.dll, is fontreg.exe the same thing? It seems to work okay compiling...
fyi I'm running Win98 SE.
Am I right in assuming that I need to put the GetWindowsVersion function at the top of the script, and use something along the lines of ParalaxTZ's script:
fyi I'm running Win98 SE.
Am I right in assuming that I need to put the GetWindowsVersion function at the top of the script, and use something along the lines of ParalaxTZ's script:
Section "Adolescense font"
SectionIn 4
RegisterFonts:
StrCmp $0 '95' lbl_95_98_me
StrCmp $0 '98' lbl_95_98_me
StrCmp $0 'ME' lbl_95_98_me
lbl_nt_2k_xp:
WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" "Adolescense" "Adolesce.TTF"
lbl_95_98_me:
WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Fonts" "Adolescense" "Adolesce.TTF" Never heard of font reg... A zip file containing fonts.dll is attached above in one of my posts...
To add the registry writing you must call GetWindowsVersion (find it in the useful functions section in the docs), Pop and compare like in the script you just wrote. Then call registerFont like I said in the earlier post.
To add the registry writing you must call GetWindowsVersion (find it in the useful functions section in the docs), Pop and compare like in the script you just wrote. Then call registerFont like I said in the earlier post.
Thanx, didn't see that.
Now I'm getting an error message:
WriteRegStr: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts\Adolescense=Adolesce.TTF
WriteRegStr: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Fonts\Adolescense=Adolesce.TTF
Invalid command: fonts::registerfont
Error in script "C:\NSIS\tff2.0\custom.nsi" on line 229 -- aborting creation process
This is the end of my script:
Now I'm getting an error message:
WriteRegStr: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts\Adolescense=Adolesce.TTF
WriteRegStr: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Fonts\Adolescense=Adolesce.TTF
Invalid command: fonts::registerfont
Error in script "C:\NSIS\tff2.0\custom.nsi" on line 229 -- aborting creation process
This is the end of my script:
lbl_nt_2k_xp:
WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" "Adolescense" "Adolesce.TTF"
lbl_95_98_me:
WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Fonts" "Adolescense" "Adolesce.TTF"
fonts::registerfont "Adolesce.TTF"
SectionEnd