WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: jimklein on October 14, 2013, 08:53:51 AM

Title: Installing fonts - template .wbt needed
Post by: jimklein on October 14, 2013, 08:53:51 AM

I have a c:\fonts\... directory that I need to install fonts. (.ttf & .otf)

Does someone have a template "install fonts" script I can use ?

Thanks
Title: Re: Installing fonts - template .wbt needed
Post by: kdmoyers on October 15, 2013, 06:15:38 AM
No, but it is my perception that if you use the shell extender function afilecopy to copy the files into the windows fonts folder, then windows will automatically "install" them.  is that true Deana?
Title: Re: Installing fonts - template .wbt needed
Post by: DirkM on October 15, 2013, 07:51:47 AM
I install fonts using this script

      objShell = CreateObject("Shell.Application")
      objFolder = objShell.Namespace(SourcePath)
      objFolderItem = objFolder.ParseName(FontFileName)
      colVerbs = objFolderItem.Verbs
      ForEach objVerb in colVerbs
         If StrIndexNC(objVerb.name,'&I',1,@FWDSCAN) != 0 || StrIndexNC(objVerb.name,'Install',1,@FWDSCAN) != 0
            objVerb.DoIt
            Break
          EndIf
      Next
Title: Re: Installing fonts - template .wbt needed
Post by: Deana on October 15, 2013, 09:28:01 AM
Quote from: kdmoyers on October 15, 2013, 06:15:38 AM
No, but it is my perception that if you use the shell extender function afilecopy to copy the files into the windows fonts folder, then windows will automatically "install" them.  is that true Deana?
Not sure the Shell Op extender is even required. You might be able to simply use FileCopy to copy the files to C:\Windows\Fonts. However you are going to need administrative privileges.  As i understand it, once they are copied to C:\Windows\Fonts, applications will be able to find and use them.  You may need to Inform running apps about the new font using a sendmessage: IntControl(22,-1,29,0,0).

I found an old code sample that calls AddFontResource using DllCall: http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/tsleft.web+WinBatch/How~To+Install~a~font.txt.

Title: Re: Installing fonts - template .wbt needed
Post by: Deana on October 15, 2013, 09:30:50 AM
Quote from: DirkM on October 15, 2013, 07:51:47 AM
I install fonts using this script

      objShell = CreateObject("Shell.Application")
      objFolder = objShell.Namespace(SourcePath)
      objFolderItem = objFolder.ParseName(FontFileName)
      colVerbs = objFolderItem.Verbs
      ForEach objVerb in colVerbs
         If StrIndexNC(objVerb.name,'&I',1,@FWDSCAN) != 0 || StrIndexNC(objVerb.name,'Install',1,@FWDSCAN) != 0
            objVerb.DoIt
            Break
          EndIf
      Next

Nice Solution. I will add to the tech database.
Title: Re: Installing fonts - template .wbt needed
Post by: Deana on October 15, 2013, 09:51:14 AM
Quote from: Deana on October 15, 2013, 09:28:01 AM
Quote from: kdmoyers on October 15, 2013, 06:15:38 AM
No, but it is my perception that if you use the shell extender function afilecopy to copy the files into the windows fonts folder, then windows will automatically "install" them.  is that true Deana?
Not sure the Shell Op extender is even required. You might be able to simply use FileCopy to copy the files to C:\Windows\Fonts. However you are going to need administrative privileges.  As i understand it, once they are copied to C:\Windows\Fonts, applications will be able to find and use them.  You may need to Inform running apps about the new font using a sendmessage: IntControl(22,-1,29,0,0).

I found an old code sample that calls AddFontResource using DllCall: http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/tsleft.web+WinBatch/How~To+Install~a~font.txt.

It appears that copying the file using FileCopy to the Windows Font directory is not sufficient on Windows 7:  http://blogs.technet.com/b/rspitz/archive/2010/09/25/how-to-install-a-font-from-the-command-line-on-windows-7.aspx