- NSIS Discussion
- Font Install
Archive: Font Install
hypheni9
23rd June 2010 09:14 UTC
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.
MSG
23rd June 2010 09:56 UTC
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?
hypheni9
23rd June 2010 11:23 UTC
Im trying with FontName plugin.
hypheni9
23rd June 2010 14:41 UTC
Please check this method..
http://nsis.sourceforge.net/Register_Fonts
Im trying this. Lets see. Have anyone tried it before and got success..??
hypheni9
23rd June 2010 16:46 UTC
!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 ?
hypheni9
25th June 2010 15:53 UTC
No one tried FontName plugin before ??
Afrow UK
25th June 2010 17:04 UTC
Looks fine to me. Why don't you test it?
Stu
hypheni9
25th June 2010 17:18 UTC
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..
Afrow UK
26th June 2010 13:40 UTC
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
hypheni9
26th June 2010 15:53 UTC
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..
Afrow UK
26th June 2010 17:00 UTC
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
hypheni9
26th June 2010 19:10 UTC
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.