Go Back   Winamp Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 17th March 2002, 09:55   #1
ghale
Junior Member
 
ghale's Avatar
 
Join Date: Mar 2002
Location: Italy
Posts: 5
Send a message via ICQ to ghale
Unhappy Font

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).
ghale is offline   Reply With Quote
Old 26th March 2002, 01:04   #2
Yathosho
Forum King
 
Yathosho's Avatar
 
Join Date: Jan 2002
Location: AT-DE
Posts: 3,167
Send a message via ICQ to Yathosho
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
code:
WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" \
"Times New Roman (TrueType)" "TIMES.TTF"



Windows 95/98/ME
code:
WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Fonts" \
"Times New Roman (TrueType)" "TIMES.TTF"



you can use the GetWindowsVersion function (see NSIS\functions.htm) to determine the windows version.

hope it works, let us know
Yathosho is online now   Reply With Quote
Old 28th March 2002, 08:27   #3
ghale
Junior Member
 
ghale's Avatar
 
Join Date: Mar 2002
Location: Italy
Posts: 5
Send a message via ICQ to ghale
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!
ghale is offline   Reply With Quote
Old 28th March 2002, 15:46   #4
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,337
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.
kichik is offline   Reply With Quote
Old 28th March 2002, 22:23   #5
ghale
Junior Member
 
ghale's Avatar
 
Join Date: Mar 2002
Location: Italy
Posts: 5
Send a message via ICQ to ghale
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...
ghale is offline   Reply With Quote
Old 29th March 2002, 09:08   #6
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,337
Don't worry, be happy

Attached is the DLL + source.

To use it in your installation add the following code:
PHP 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:
PHP 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
Attached Files
File Type: zip fonts.dll.zip (1.8 KB, 638 views)
kichik is offline   Reply With Quote
Old 3rd May 2002, 03:49   #7
cchian
Member
 
Join Date: Apr 2001
Posts: 73
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
cchian is offline   Reply With Quote
Old 3rd May 2002, 10:43   #8
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,337
Your code should work just fine.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 10th July 2002, 17:29   #9
Yathosho
Forum King
 
Yathosho's Avatar
 
Join Date: Jan 2002
Location: AT-DE
Posts: 3,167
Send a message via ICQ to Yathosho
did not work in nsis 2.0 alpha
Yathosho is online now   Reply With Quote
Old 10th July 2002, 18:34   #10
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,337
Could you be a little bit more specific please?

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius

Last edited by kichik; 10th July 2002 at 21:04.
kichik is offline   Reply With Quote
Old 10th July 2002, 20:26   #11
Smile2Me
Guest
 
Posts: n/a
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.
  Reply With Quote
Old 20th July 2002, 15:41   #12
ParallaxTZ
Junior Member
 
Join Date: Jul 2002
Posts: 14
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.
Attached Files
File Type: zip main menu.zip (2.6 KB, 196 views)
ParallaxTZ is offline   Reply With Quote
Old 20th July 2002, 17:26   #13
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,337
Are you using using about NSIS 2 or 1.98/9?

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 20th July 2002, 17:29   #14
ParallaxTZ
Junior Member
 
Join Date: Jul 2002
Posts: 14
I used both 1.96 and now 1.98.
ParallaxTZ is offline   Reply With Quote
Old 20th July 2002, 17:45   #15
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,337
Please try the attached script and tell me which messages you get.
Don't forget to change the file extension to .nsi.
Attached Files
File Type: txt main menu.txt (8.9 KB, 388 views)

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 20th July 2002, 21:47   #16
Joost Verburg
NSIS MUI Dev
 
Join Date: Nov 2001
Posts: 3,717
Quote:
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.
Quote:
GetTempFileName $R0
File /oname=$R0 G:\windows\system32\fonts.dll
Push "MAEL____.TTF"
CallInstDLL $R0 registerFont
You 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.

You should SetOverwrite On before the File command.

Quote:
GetTempFileName $R0
SetOverwrite On
File /oname=$R0 G:\windows\system32\fonts.dll
SetOverwrite ifnewer
Push "MAEL____.TTF"
CallInstDLL $R0 registerFont
I have not tested this
Joost Verburg is offline   Reply With Quote
Old 21st July 2002, 03:21   #17
ParallaxTZ
Junior Member
 
Join Date: Jul 2002
Posts: 14
Thanks to both of you, but only Joost's fix worked. Thanks again, no more restarts after my installer, YAY!
ParallaxTZ is offline   Reply With Quote
Old 2nd August 2002, 19:51   #18
Yathosho
Forum King
 
Yathosho's Avatar
 
Join Date: Jan 2002
Location: AT-DE
Posts: 3,167
Send a message via ICQ to Yathosho
Wink

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
Yathosho is online now   Reply With Quote
Old 2nd August 2002, 19:56   #19
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,337
All of the code you need to copy+paste it up there

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 4th August 2002, 15:08   #20
ParallaxTZ
Junior Member
 
Join Date: Jul 2002
Posts: 14
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.
Attached Files
File Type: zip main menu.zip (2.6 KB, 281 views)
ParallaxTZ is offline   Reply With Quote
Old 4th August 2002, 15:51   #21
Yathosho
Forum King
 
Yathosho's Avatar
 
Join Date: Jan 2002
Location: AT-DE
Posts: 3,167
Send a message via ICQ to Yathosho
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!
Yathosho is online now   Reply With Quote
Old 4th August 2002, 15:53   #22
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,337
You can use the same DLL for uninstalling... Please check the code above...

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 6th September 2002, 12:23   #23
Yathosho
Forum King
 
Yathosho's Avatar
 
Join Date: Jan 2002
Location: AT-DE
Posts: 3,167
Send a message via ICQ to Yathosho
is it necessary to use that .dll for old .fon fonts, or can i just copy them without registering them?
Yathosho is online now   Reply With Quote
Old 6th September 2002, 13:18   #24
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,337
As far as I know you should register them too.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 6th September 2002, 17:00   #25
Sunjammer
Major Dude
 
Join Date: Jun 2002
Location: Swindon, UK
Posts: 559
Reminder

Just a little reminder that since NSIS 2.0a4 you can make this kinda thing:-
PHP Code:
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:-
PHP Code:
fonts::registerFont "Font1.TTF"
fonts::registerFont "Font2.TTF"
fonts::registerFont "Font3.TTF"
fonts::registerFont "Font4.TTF" 
Sunjammer is offline   Reply With Quote
Old 9th December 2002, 17:55   #26
dirkdeftly
Forum King
 
dirkdeftly's Avatar
 
Join Date: Jun 2001
Location: Cydonia, Mars
Posts: 2,651
Send a message via AIM to dirkdeftly
Sorry to bring up and old topic, but...

I'm still not clear on how to register a font without rebooting...

"guilt is the cause of more disauders
than history's most obscene marorders" --E. E. Cummings
dirkdeftly is offline   Reply With Quote
Old 9th December 2002, 18:08   #27
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,337
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.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 9th December 2002, 18:25   #28
dirkdeftly
Forum King
 
dirkdeftly's Avatar
 
Join Date: Jun 2001
Location: Cydonia, Mars
Posts: 2,651
Send a message via AIM to dirkdeftly
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:
PHP Code:
Section "Adolescense font"
SectionIn 4
RegisterFonts
:
StrCmp $'95' lbl_95_98_me
StrCmp 
$'98' lbl_95_98_me
StrCmp 
$'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" 

"guilt is the cause of more disauders
than history's most obscene marorders" --E. E. Cummings
dirkdeftly is offline   Reply With Quote
Old 9th December 2002, 18:31   #29
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,337
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.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 9th December 2002, 18:44   #30
dirkdeftly
Forum King
 
dirkdeftly's Avatar
 
Join Date: Jun 2001
Location: Cydonia, Mars
Posts: 2,651
Send a message via AIM to dirkdeftly
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:

PHP Code:
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 

"guilt is the cause of more disauders
than history's most obscene marorders" --E. E. Cummings
dirkdeftly is offline   Reply With Quote
Old 9th December 2002, 19:09   #31
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,337
Quote:
Put Fonts.dll in your Plugins directory.
If you don't have a plugins directory you either installed a minimal version of NSIS or you are not using NSIS 2.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 9th December 2002, 19:59   #32
dirkdeftly
Forum King
 
dirkdeftly's Avatar
 
Join Date: Jun 2001
Location: Cydonia, Mars
Posts: 2,651
Send a message via AIM to dirkdeftly
Oops. I thought you were talking about the Winamp plugins directory

But I'm still getting the same error message. Is this code wrong?

SetOutPath "$WINDIR\system32\"
File "c:\nsis\plugins\Fonts.dll"

"guilt is the cause of more disauders
than history's most obscene marorders" --E. E. Cummings
dirkdeftly is offline   Reply With Quote
Old 9th December 2002, 20:47   #33
Joost Verburg
NSIS MUI Dev
 
Join Date: Nov 2001
Posts: 3,717
First, make sure you got the latest NSIS 2 version, beta 0. You can download it from http://prdownloads.sourceforge.net/n....exe?download.

Now copy fonts.dll to the Plugins dir of NSIS (that is a directory on the system where NSIS is installed). Usually the path is C:\Program Files\NSIS\Plugins.

NSIS will detect your plugin and you can use fonts::registerFont in your NSIS script. NSIS handles the extracting, deleting etc. of the file. There is nothing else where you have to worry about.
Joost Verburg is offline   Reply With Quote
Old 9th December 2002, 21:09   #34
dirkdeftly
Forum King
 
dirkdeftly's Avatar
 
Join Date: Jun 2001
Location: Cydonia, Mars
Posts: 2,651
Send a message via AIM to dirkdeftly
I have the latest NSIS2. I'm still getting an error message when I compile that says fonts::registerfont is an invalid function.

I'll try rebooting...

"guilt is the cause of more disauders
than history's most obscene marorders" --E. E. Cummings
dirkdeftly is offline   Reply With Quote
Old 9th December 2002, 21:29   #35
dirkdeftly
Forum King
 
dirkdeftly's Avatar
 
Join Date: Jun 2001
Location: Cydonia, Mars
Posts: 2,651
Send a message via AIM to dirkdeftly
Didn't work. Where does the DLL have to be in relation to the .NSI file, and where does the .NSI file have to be in relation to the NSIS installation path?

"guilt is the cause of more disauders
than history's most obscene marorders" --E. E. Cummings
dirkdeftly is offline   Reply With Quote
Old 9th December 2002, 21:47   #36
Joost Verburg
NSIS MUI Dev
 
Join Date: Nov 2001
Posts: 3,717
The DLL should be copied to the NSIS Plugins directory of YOUR system. That is the subdirectory 'Plugins' in the directory of the NSIS installation. You don't have to worry about extracting it on the user's system, NSIS does everything for you.

At the beginning of the NSIS compiler output, you can see a list of all detected plugins.
Joost Verburg is offline   Reply With Quote
Old 10th December 2002, 05:49   #37
dirkdeftly
Forum King
 
dirkdeftly's Avatar
 
Join Date: Jun 2001
Location: Cydonia, Mars
Posts: 2,651
Send a message via AIM to dirkdeftly
Okay, so it doesn't matter where the .NSI file is, I take it...?

I'm gonna post my script here. I'm also having troubles with the instdir page not having the default path...
Attached Files
File Type: zip tff2.0.zip (1.5 KB, 192 views)

"guilt is the cause of more disauders
than history's most obscene marorders" --E. E. Cummings
dirkdeftly is offline   Reply With Quote
Old 10th December 2002, 13:31   #38
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,337
That's not a NSIS 2.0b0 script, it has .onNextPage and .onPrevPage in it. If you are sure it is supposed to work with b0 notify Jheriko that it is highly out of date.

When you compile the script do you see on the top of the output after the credits stuff a list that starts with:

Processing plugin dlls: "<nsis dir>\plugins\*.dll"

?

If you don't see that line and a list after it you are not using NSIS 2.0b0. If you do, do you see fonts::registerFont there? If it is there, try copying the line exactly as it is and paste into the script, then see if you get errors (don't forget to add the font name if it works). If there is a list and fonts::registerFont is not there you didn't put fonts.dll in the right directory (use !error "${NSISDIR}\Plugins" in any script to see what it is).

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 10th December 2002, 17:11   #39
dirkdeftly
Forum King
 
dirkdeftly's Avatar
 
Join Date: Jun 2001
Location: Cydonia, Mars
Posts: 2,651
Send a message via AIM to dirkdeftly
Ooookay...I'm gonna tell Jheriko that, after I smack the fuckin shit out of him.

The script compiles to fast for me to read anything at the top, so I wouldn't know


Anyway, thanx, sorry for all the trouble

"guilt is the cause of more disauders
than history's most obscene marorders" --E. E. Cummings
dirkdeftly is offline   Reply With Quote
Old 10th December 2002, 17:20   #40
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,337
Aren't you using MakeNSISw? It's a windows wrapper for NSIS that comes with NSIS. Just right click a script and choose Compile NSI. If you still get a DOS box you are not using NSIS 2 for sure.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Reply
Go Back   Winamp Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump