Archive: Fonts installation Win9x/WinNT


Fonts installation Win9x/WinNT
Hello @all,
i have some problems with fonts installation and uninstall on Win98.
On Windows XP everything is ok. After the installation process on Win98 the fonts were not shown in the fontstable. After a reboot they are shown, but it should work without a reboot. Should i use CreateScalableFontResource before calling AddFontResourceA? I have the same problem using fonts.dll and i would prefer to do it without the plugin.

Can anyone help me (using NSIS 2.24)?


!define FONT2 "tt0856m_.ttf"
...

Win9x:
StrCpy $RegKey2Fonts "SOFTWARE\Microsoft\Windows\CurrentVersion\Fonts"
StrCpy $FontsDirectory "C:\Windows\Fonts"
StrCpy $OSBasis "Win9x"
Goto OSVersionEnd


WinNT:
StrCpy $RegKey2Fonts "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts"
StrCpy $FontsDirectory $FONTS
StrCpy $OSBasis "WinNT"
Goto OSVersionEnd

...

Section "${ProductName} ${DISPLAY_VERSION}"

SetOutPath $FontsDirectory

File ..\Fonts\Fonts-V1.1\${FONT2}

System::Call "GDI32::AddFontResourceA(t) i ('${FONT2}') .s"
Pop $0
# $0 is zero if the function failed
StrCmp $0 "0" 0 +3
DetailPrint "Fehler beim registrieren von ${FONT2} ($0) ..."
Goto NewFont3
DetailPrint "${FONT2} erfolgreich registriert ($0) ..."
WriteRegStr HKLM "$RegKey2Fonts" "${FONT2_NAME}" "${FONT2}"

DetailPrint "Nachricht an alle Anwendungen bzgl. neuer Fontlist ..."
SendMessage ${HWND_BROADCAST} ${WM_FONTCHANGE} 0 0

...

SectionEnd


Section Uninstall

System::Call "GDI32::RemoveFontResourceA(t) i ('${FONT2}') .s"
Pop $0
DetailPrint "${FONT2} aus Fonttable löschen ..."
${If} $0 != "0"
DetailPrint "Löschen aus Fonttable erfolgreich ($0) ..."
DetailPrint "${FONT2} aus $FontsDirectory löschen ..."
ClearErrors
Delete $FontsDirectory\${FONT2}
IfErrors 0 +3
DetailPrint "Löschen aus Filesystem fehlgeschlagen ..."
Goto +4
DetailPrint "Löschen aus Filesystem erfolgreich ..."
DetailPrint "HKLM\$RegKey2Fonts\${FONT2_NAME} löschen ..."
DeleteRegValue HKLM "$RegKey2Fonts" "${FONT2_NAME}"
${Else}
DetailPrint "Löschen aus Fonttable fehlgeschlagen ($0) ..."
${EndIf}

...

SectionEnd


Your code looks like it should work. The only thing that might go around that I can see is C:\Windows\Fonts on 9x. Why not use $FONTS or at least $WINDIR\Fonts?

Also, why not use one of the available solutions?

http://nsis.sourceforge.net/Register_Fonts


most of my scripts didn't work on win 9x, when i didn't use quotes throughout the entire script. i don't know if that changed with later nsis versions, but it's worth a try to put quotes around each file/directory.