Old 31st August 2011, 13:25   #1
gdollard
Junior Member
 
Join Date: Aug 2011
Posts: 4
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.
gdollard is offline   Reply With Quote
Old 31st August 2011, 15:13   #2
gdollard
Junior Member
 
Join Date: Aug 2011
Posts: 4
any help at all folks? I'm at a loss here
gdollard is offline   Reply With Quote
Old 1st September 2011, 12:44   #3
gdollard
Junior Member
 
Join Date: Aug 2011
Posts: 4
thankfully I've managed to sort this myself...I'd be a long time waiting for it here.
gdollard is offline   Reply With Quote
Old 1st September 2011, 19:47   #4
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
You're welcome for nothing.
MSG is offline   Reply With Quote
Old 29th November 2012, 08:14   #5
Ttrebla
Junior Member
 
Join Date: Nov 2012
Posts: 1
Hi, I'm having exactly the same problem here.

gdollard, do you remember how did you solve it?

Thanks!
Ttrebla is offline   Reply With Quote
Old 29th November 2012, 09:58   #6
gdollard
Junior Member
 
Join Date: Aug 2011
Posts: 4
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.
gdollard is offline   Reply With Quote
Old 6th December 2012, 03:08   #7
PoRtAbLe_StEaLtH
Junior Member
 
Join Date: Jul 2011
Posts: 49
Quote:
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:
PHP Code:
StrCpy $FontFolder "$INSTDIR\MyApp"
System::Call "gdi32::AddFontResource(t'$FontFolder')i .r2"
SendMessage ${HWND_BROADCAST} ${WM_FONTCHANGE0 0 /TIMEOUT=
works for me on all systems..
haven't had a problem yet..
if you have more than 1 font..
use "Find" (first,next,close).
PoRtAbLe_StEaLtH is offline   Reply With Quote
Old 6th December 2012, 08:10   #8
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,216
Timeout=1 seems a little short IMHO...

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 11th December 2012, 14:01   #9
sols_HeG
Junior Member
 
Join Date: Aug 2011
Posts: 5
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
sols_HeG is offline   Reply With Quote
Old 11th December 2012, 14:17   #10
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,216
Don't mix t type and A/W suffix. b is not a type, Windows uses int for BOOL:
code:
System::Call 'shell32::SHGetSpecialFolderPath(i $HWNDPARENT,t.r1,i ${CSIDL_FONTS},i 0) i.r0'

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 11th December 2012, 14:44   #11
sols_HeG
Junior Member
 
Join Date: Aug 2011
Posts: 5
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
sols_HeG is offline   Reply With Quote
Old 30th October 2016, 12:36   #12
ruku320
Junior Member
 
Join Date: Oct 2016
Posts: 1
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:
PHP Code:
"${Index}-GO:"
  
ClearErrors
  push 
${FontFileName}
  
Call GetFontName
  pop $R2
  IfErrors 0 
"${Index}-Add"
    
MessageBox MB_OK "$R2"
    
goto "${Index}-End" 
ruku320 is offline   Reply With Quote
Old 31st October 2016, 07:25   #13
Kuppy
Junior Member
 
Join Date: Sep 2016
Posts: 34
PHP Code:
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_FONTCHANGE0 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 222u 215u 25u ""
  
pop $Lbl.Welcome

  SendMessage $Lbl
.Welcome ${WM_SETTEXT"STR:Welcome!"

  
CreateFont $"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_FONTCHANGE0 0
  Delete 
"$PLUGINSDIR\Baar Sophia.ttf"
FunctionEnd 
Kuppy is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Tags
font

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump