Skip to content
⌘ NSIS Forum Archive

Installing a Font - Help!!

13 posts

gdollard#

Installing a Font - Help!!

Hi All,
I'm really stuck on this one. I have a script that installs two fonts, (Andale Mono and arialUnicode) on XP using InstallTTF from FontRegAdv.nsh.

The odd behavior I get is when adnalemo is not installed on the machine the installer throws up a dialog saying "Invalid File Handle 32" and the font is not installed.

However if I remove the arialUnicode font and run the installer it does install that font no problem!
I'm puzzled as to why it has a problem with the Andale Mono font! Odd.

I'm new to all this as I'm sure you'll realise from my problem!!

here's the code:

strCpy $FONT_DIR $FONTS
!insertmacro InstallTTF "$INSTDIR\Fonts\andalemo.ttf" $FONTS

!insertmacro InstallTTF '$INSTDIR\Fonts\arialUnicode.ttf' $FONTS
SendMessage ${HWND_BROADCAST} ${WM_FONTCHANGE} 0 0 /TIMEOUT=5000

The font files are in the same folder so I don't understand what's going wrong!

Any help would be greatly appreciated!

Thanks.
Ttrebla#
Hi, I'm having exactly the same problem here.

gdollard, do you remember how did you solve it?

Thanks!
gdollard#
hi Ttrebla, it's been a long time since I've looked at this but I think the problem was confined to XP machines and if memory serves I had to check for the existence of the the font on the target machine and remove it before 'installing' it again in the nsis script.
Not very scientific I know but it seemed to work.
PoRtAbLe_StEaLtH#
Originally Posted by gdollard View Post
Hi All,
I'm really stuck on this one. I have a script that installs two fonts, (Andale Mono and arialUnicode) on XP using InstallTTF from FontRegAdv.nsh.

The odd behavior I get is when adnalemo is not installed on the machine the installer throws up a dialog saying "Invalid File Handle 32" and the font is not installed.

However if I remove the arialUnicode font and run the installer it does install that font no problem!
I'm puzzled as to why it has a problem with the Andale Mono font! Odd.

I'm new to all this as I'm sure you'll realise from my problem!!

here's the code:

strCpy $FONT_DIR $FONTS
!insertmacro InstallTTF "$INSTDIR\Fonts\andalemo.ttf" $FONTS

!insertmacro InstallTTF '$INSTDIR\Fonts\arialUnicode.ttf' $FONTS
SendMessage ${HWND_BROADCAST} ${WM_FONTCHANGE} 0 0 /TIMEOUT=5000

The font files are in the same folder so I don't understand what's going wrong!

Any help would be greatly appreciated!

Thanks.


here's what i use:
StrCpy $FontFolder "$INSTDIR\MyApp"
System::Call "gdi32::AddFontResource(t'$FontFolder')i .r2"
SendMessage ${HWND_BROADCAST} ${WM_FONTCHANGE} 0 0 /TIMEOUT=1 
works for me on all systems..
haven't had a problem yet..
if you have more than 1 font..
use "Find" (first,next,close).
sols_HeG#
hey there,
i used the fonts-plugin to install my constum fonts, because INSTALLTTF made too much problems and work for me.

Set the Outputpath to the System-Fontfolder
System::Call 'shell32::SHGetSpecialFolderPathA(i $HWNDPARENT, t .r1, i ${CSIDL_FONTS}, i 0) i r0'
SetOutPath $1

Add the ttf and the Name of the Font to the Registry:
WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" "Play Regular" "Play-Regular.ttf"

Then just use the registerFont Function of the fonts-Plugin:
fonts::registerFont "Play-Regular.ttf"

Hope this helps

Greeting from Munich
HeG


Edit: Corrected the Call of the shell32
Anders#
Don't mix t type and A/W suffix. b is not a type, Windows uses int for BOOL:
System::Call 'shell32::SHGetSpecialFolderPath(i $HWNDPARENT,t.r1,i ${CSIDL_FONTS},i 0) i.r0'
sols_HeG#
OOOk...
just saw my fault....

anyway, I hope that the correct part of my script will work 😉
I'll correct my previous post, just as I correct my script at work.

Greetings from Munich
HeG
ruku320#
Recently ran into this problem while compiling an script that previously never displayed the error on Windows 7. This appears to be a problem with the FontName plug-in. The error occurs on the call to FontName::Name. I would able to work around this by replacing the macro call to FontName with GetFontName from: http://nsis.sourceforge.net/Get_localised_font_name

I made the following edit to FontReg.nsh:
"${Index}-GO:"
  ClearErrors
  push ${FontFileName}
  Call GetFontName
  pop $R2
  IfErrors 0 "${Index}-Add"
    MessageBox MB_OK "$R2"
    goto "${Index}-End" 
Kuppy#
Name "Install Fonts"
Caption "Install Fonts"
OutFile "Install Fonts.exe"
InstallDir "$TEMP\Install Fonts"
SetCompressor lzma
!include "MUI2.nsh"
!include "LogicLib.nsh"
!include "nsDialogs.nsh"
!Include "WinMessages.nsh"
!include "FileFunc.nsh"
SetCompressor lzma
RequestExecutionLevel User
ShowInstDetails hide
ShowInstDetails nevershow
ShowUnInstDetails nevershow
XPStyle off
BrandingText /TRIMRIGHT " "
Page Custom customPage 
Page instfiles
!insertmacro MUI_LANGUAGE 'ENGLISH' 
Function .onInit
  InitPluginsDir
  File '/oname=$PLUGINSDIR\Baar Sophia.ttf' 'Fonts\Baar Sophia.ttf'
  Push "$FONTS\Baar Sophia.ttf"
  System::Call 'GDI32::AddFontResourceEx(t"$PLUGINSDIR\Baar Sophia.ttf",i 0x30,i0)'
  System::Call "Gdi32::AddFontResource(t s) i .s"
  Pop $0
  SendMessage ${HWND_BROADcast} ${WM_FONTCHANGE} 0 0
FunctionEnd
Var dialog 
Var Lbl.Welcome
Function customPage 
  nsDialogs::Create 1018 
  Pop $dialog 
  ${If} $dialog == error 
    Abort 
  ${EndIf} 
  SetCtlColors $dialog 0x0a000a 0xECE6C5
  nsDialogs::CreateControl STATIC 0x40000000|0x10000000|0x04000000|0x00000100 0x00000020 2% 22u 215u 25u ""
  pop $Lbl.Welcome
  SendMessage $Lbl.Welcome ${WM_SETTEXT} 0 "STR:Welcome!"
  CreateFont $0 "Baar Sophia" 15
  SendMessage $Lbl.Welcome ${WM_SETFONT} $0 0 
  SetCtlColors $Lbl.Welcome 0x0a000a 0xECE6C5
  nsDialogs::Show 
FunctionEnd 
Section 
SectionEnd 
Function ".onGUIEnd"
  Push "$FONTS\Baar Sophia.ttf"
  System::Call 'Gdi32::RemoveFontResourceEx(t"$PLUGINSDIR\Baar Sophia.ttf",i 0x30,i0)'
  System::Call "Gdi32::RemoveFontResource(t s) i .s"
  SendMessage ${HWND_BROADcast} ${WM_FONTCHANGE} 0 0
  Delete "$PLUGINSDIR\Baar Sophia.ttf"
FunctionEnd