Archive: Font Install


Font Install
My nsis installer needs to install a font. I use CopyFile the .ttf file to fonts folder in windows xp and then executing this ::

System::Call "GDI32::AddFontResourceA(t) i ('BIRDMAN_.TTF') .s"
Pop $0
SendMessage ${HWND_BROADCAST} ${WM_FONTCHANGE} 0 0

but still my application doesnt catch the font at first time after install.. If I open fonts folder manually after installation it works fine.


When I look at the Register Fonts entry in the wiki (google~~) I see that it also writes a registry key. Maybe that's what you're missing?


Im trying with FontName plugin.


Please check this method..

http://nsis.sourceforge.net/Register_Fonts

Im trying this. Lets see. Have anyone tried it before and got success..??


!include "FontReg.nsh"
!include "FontName.nsh"

..... Main Section here

Section "Fonts"
StrCpy $FONT_DIR $FONTS
!insertmacro InstallTTFFont 'BIRDMAN_.TTF'
SendMessage ${HWND_BROADCAST} ${WM_FONTCHANGE} 0 0 /TIMEOUT=5000
SectionEnd

Is it okay for installing and registering the specified font with windows. I put BIRDMAN_.TTF file in the same directory of my nsi script file. Is it Okay ?


No one tried FontName plugin before ??


Looks fine to me. Why don't you test it?

Stu


the matter is.. fro testing it in my system i need to remove that font manually and deleting the windows FNTCACHE.DAT file.. moreover i tried this but not so sure. have to check in other system. thats why I asked here if anyone use this method and got a success..


Are you saying you are having to manually uninstall the font before you install it? In other words - the font is already installed? If so, how about using RemoveTTFFont first?

Stu


See, I did manually what RemoveTTFFont used to do with codes. ie: removing .ttf file from fonts folder and deleting its entry from registry. Moreover if you follow this process to delete a font it'll be deleted but next time if you only copy .ttf file to the fonts folders it'll be activated in all application, note this time you didnt register it with window, so it was previously registered with windows, for this I have to delete FNTCACHE.dat file from system. This should be done now, but still I cant be sure that the script works for registering fonts with windows until i use my installer to a system that has never registered the font before..


That is the whole point - if it's a brand new font then why should it already exist on the system? If the installation is being run again then you should detect this and either run the uninstall first or use RemoveTTFFont directly before InstallTTFFont. InstallTTFFont probably has not been written to cope with the issue of the font already existing because this is not usually the case.

Stu


In previously build of my installer I was aware of this fact and I just coded to put .ttf file to fonts folder by CopyFiles method. That works well in my system as I opens fonts folders most of the time and thus installing that .ttf file. But when I tried my installer in other systems the application did not detect it though installer has copied the .ttf file in the system's font directory. In this case it only copied the file but not registering .ttf. There after I tried new installer with InstallTTF method in my system where .ttf file has already registered. So here lies the problem. Anyways I'll check my new installer in other system in few days and will get back here.