Archive: When to register locked font?


When to register locked font?
If a font file is locked and you have to do a reboot to update it, when do you call RegisterFont? Is it ok to call RegisterFont right after the Rename call, like this...

SetOutPath $TEMP
GetTempFileName $R1
file /oname=$R1 "${FilesDir}${FONT_NAME}"
Rename /REBOOTOK $R1 $WINDIR\Fonts\${FONT_NAME}
fonts::registerFont "$WINDIR\Fonts\${FONT_NAME}"

It seems like it should work, since the old font file is there still. The reason I ask is because it seems like half the time my installation works fine, but the other half the fonts aren't right. I am having a really hard time with the font installation for some reason.


Have you tried unregistering the old font first?

Registering/unregistering is only for the current session, for the font to be loaded everytime you need to write some registry entries as you already know. You also need to send WM_FONTCHANGE using SendMessageTimeour. With NSIS just write SendMessage ${HWND_BROADCAST} ${WM_FONTCHANGE} 0 0 /TIMEOUT=5000. This is only possible with the newest version of NSIS from the CVS. Maybe after you unregister the font and send this message you will be able to replace the font without a reboot.

If this doesn't work and you do replace the file after reboot, you don't need to call registerFont at all because the registry entries are already there after a reboot.


Registering/unregistering is only for the current session, for the font to be loaded everytime you need to write some registry entries as you already know.
I didn't already know :eek:. It seems to me like you would almost always want the fonts to be loaded everytime - not just for the current session. In fact, I can't think of a time when you wouldn't. Of course, I am not entirely sure what a "session" is either. So what registry keys do I need to add/adjust?

Have you tried unregistering the old font first?
No, but I'll try that. It looks almost like I don't have to call registerfont/unregisterfont in the font.dll at all. Is that the case? These fonts I am trying to install are for my app and I want them to be used permanently.

So it looks like I need to...

- unregister the old one
- copy the font file
- write some registry keys (think I saw this in another post somewhere)
- send the system font message

Is that right? Sorry for being a pain, but I am about to pull all my hair out over this. Seems like I am getting closer though.

Registering and unregistering is done so you can use it the font without a reboot. If you don't write the registry keys, which are mentioned in that other thread called "Font", the font won't be loaded after reboot.

- unregister the old one
- copy the font file
- write some registry keys (think I saw this in another post somewhere)
- send the system font message
You have to register the font after you copy it so you will be able to use it without a reboot. Then you send the message.

OK, I think I got it. Thanks again.