Jump to content

Recommended Posts

Posted

InstallFontsTool x86
tabdownload.png Update (24 October 2013)
tabdownload.png Update (24 October 2013)
tabdownload.png Update (24 October 2013)
tabdownload.png Update (24 October 2013)
tabdownload.png Update (24 October 2013)
tabdownload.png Update (24 October 2013)
tabdownload.png Update (24 October 2013)
Hash MD5 BDB73A5921AB06BD9F6C3B56A46C218D
Filesize: 412 KB (421888 bytes)


InstallFontsTool x64
tabdownload.png Update (24 October 2013)
tabdownload.png Update (24 October 2013)
tabdownload.png Update (24 October 2013)
tabdownload.png Update (24 October 2013)
tabdownload.png Update (24 October 2013)
tabdownload.png Update (24 October 2013)
tabdownload.png Update (24 October 2013)
Hash MD5 D41D375A2EC052250FAEDD6DFC194CC1
Filesize: 444 KB (455168 bytes)


This tool allows you to easily install in your Windows NT6.x image (Vista/7/8/8.1) in unattended mode your personal fonts

Regline examples:
"InstallFontsTool.exe" "lokicola.ttf" "Loki Cola (TrueType)"
"InstallFontsTool.exe" "lokicola.ttf"
"InstallFontsTool.exe" "*.ttf"
With the following command line the tool searches for font files in FontDir directory and all subdirectories:
"InstallFontsTool.exe" "FontDir"

All file and directory path shown in command line must be present in same directory of InstallFontsTool.exe, as it serches for "File\Folder" inside its working directory. Otherwise you must use a command like this:
"InstallFontsTool.exe" "%UserProfile%\Desktop\FontDir"
or
"InstallFontsTool.exe" "%UserProfile%\Desktop\lokicola\lokicola.ttf"
Source code:
 
#RequireAdminGlobal Const $HWND_BROADCAST = 0xFFFFGlobal Const $WM_FONTCHANGE = 0x1DGlobal $aRet, $hGdi32 = DllOpen("gdi32.dll")Global $SourceFile, $FontDescript, $sDir, $sFilter, $aDirFilter;_InstallFontEx(@DesktopDir & "\SourceCodePro-ExtraLight.otf");_InstallFontEx(@DesktopDir & "\lokicola\lokicola.ttf", "Loki Cola (TrueType)")If $CmdLine[0] > 0 Then   For $Count = 1 To $CmdLine[0]      $sDir = $CmdLine[$Count]      If StringInStr($sDir, "*", 1) Then         $sFilter = StringRegExpReplace($sDir, ".*[\/\\]+", "")         $aDirFilter = StringRegExp($sDir, "(.+[^\/\\])([^\/\\]+)", 1)         If Not @Error Then            $sDir = $aDirFilter[0]            $sFilter = $aDirFilter[1]            If Not StringRegExp($aDirFilter[0], "^\h*(?:\\\\\?\\)*(\\\\[^\?\/\\]+|[A-Za-z]:)") Then $sDir = @ScriptDir & "\" & $aDirFilter[0]         Else            $sDir = @ScriptDir         EndIf         $SourceFile = _FileListToArrayEx($sDir, $sFilter, 13)         If Not @Error Then            For $y = 1 To $SourceFile[0]               _InstallFontEx($SourceFile[$y])            Next         EndIf      Else         If Not StringRegExp($sDir, "^\h*(?:\\\\\?\\)*(\\\\[^\?\/\\]+|[A-Za-z]:)") Then $sDir = @ScriptDir & "\" & $CmdLine[$Count]         If StringInStr(FileGetAttrib($sDir), "D", 1) Then            $SourceFile = _FileListToArrayEx($sDir, "(?:\.fon$|\.ttf$|\.ttc$|\.fot$|\.otf$|\.mmm$|\.pfb$|\.pfm$|\.pfb$)", 77)            If Not @Error Then               For $y = 1 To $SourceFile[0]                  _InstallFontEx($SourceFile[$y])               Next            EndIf         Else            If $CmdLine[0] > $Count And StringRegExp($CmdLine[$Count + 1], "\(.+\)") Then               $FontDescript = $CmdLine[$Count + 1]               $Count += 1            EndIf            _InstallFontEx($sDir, $FontDescript)         EndIf      EndIf   NextElse   MsgBox(0, "Error", "Please drop files to this script to run it!" & @LF & 'example : InstallFontsTool.exe "FontsName.ttf" "Fonts Desc"')EndIfDllClose($hGdi32); #FUNCTION# ====================================================================================================================; Name...........: _InstallFontEx; Description ...: Install a Font file; Syntax.........: _InstallFontEx($sFilePath); Parameters ....: $sFilePath     - The full path file;                  $sFontDescript - Optional, Font Description;                  $sFontsPath    - Optional, Font Path Destination; Return values .: Success - Title Property; Author ........: DXRW4E; ===============================================================================================================================Func _InstallFontEx($sFilePath, $sFontDescript = "", $sFontsPath = "")    If Not $sFontsPath Then $sFontsPath = @WindowsDir & "\Fonts"   Local $sFontsName = StringRegExpReplace($sFilePath, "\A.+[\/\\]+", "")    If Not FileCopy($sFilePath, $sFontsPath & "\" & $sFontsName, 1) Then Return SetError(1, 0, 0)   $aGdi32 = DllCall($hGdi32, "Int", "AddFontResource", "str", $sFontsPath & "\" & $sFontsName)   If @Error Or Not $aGdi32[0] Then Return SetError(1, 0, 0)   If Not $sFontDescript Then      ;;$aGdi32 = DllCall($hGdi32, "int", "GetFontResourceInfoW", "wstr", $sFontsPath & "\" & $sFontsName, "dword*", 4096, "wstr", "", "dword", 1)      ;;$sFontDescript = $aGdi32[3] & _FontGetProperty($sFilePath, 1)      $sFontDescript &= _FontGetProperty($sFilePath)   EndIf   RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts", $sFontDescript, "REG_SZ", $sFontsName)    DllCall("user32.dll", "Int", "SendMessage", "hwnd", $HWND_BROADCAST, "int", $WM_FONTCHANGE, "int", 0, "int", 0)    Return 1EndFunc; #FUNCTION# ====================================================================================================================; Name...........: _FontGetProperty; Description ...: Returns a property for a Font file; Syntax.........: _FontGetProperty($sFilePath); Parameters ....: $sFilePath  - The full path file; Return values .: Success - Title Property; Author ........: DXRW4E; ===============================================================================================================================Func _FontGetProperty($sFilePath, $iFlags = 0)    ;$sFilePath = StringRegExpReplace($sFilePath, '["' & "]", "")    If Not FileExists($sFilePath) Then Return SetError(1, 0, "")    Local $sTitle, $objFolder, $objFolderItem, $objShell = ObjCreate("Shell.Application")    If @Error Then Return SetError(3, 0, "")   $objFolder = $objShell.NameSpace(StringRegExpReplace($sFilePath, "\A.+\K[\/\\][^\/\\]*$", ""))    $objFolderItem = $objFolder.Parsename(StringRegExpReplace($sFilePath, "\A.+[\/\\]+", ""))   If Not $iFlags Then      $sTitle = $objFolder.GetDetailsOf($objFolderItem, 21)      If Not $sTitle Then Return SetError(2, 0, 0)   EndIf   If StringRegExp($objFolder.GetDetailsOf($objFolderItem, 187), "(?:True|Open)Type") Then $sTitle &= " (TrueType)"    Return $sTitleEndFunc   ;==>_FontGetProperty; #FUNCTION# =======================================================================================================================================================; Name...........: _FileListToArrayEx; Description ...: Lists files and\or folders in a specified path (Similar to using Dir with the /B Switch); Syntax.........: _FileListToArrayEx($sPath[, $sFilter = "*"[, $iFlag = 0]]); Parameters ....: $sPath   - Path to generate filelist for.;                  $sFilter - Optional the filter to use, default is *. (Multiple filter groups such as "All "*.png|*.jpg|*.bmp") Search the Autoit3 helpfile for the word "WildCards" For details.;                  $iFlag   - Optional: specifies whether to return files folders or both Or Full Path (add the flags together for multiple operations):;                  |$iFlag = 0 (Default) Return both files and folders;                  |$iFlag = 1 Return files only;                  |$iFlag = 2 Return Folders only;                  |$iFlag = 4 Search SubDirectory;                  |$iFlag = 8 Return Full Path;                  |$iFlag = 16 $sFilter do Case-Sensitive matching (By Default $sFilter do Case-Insensitive matching);                  |$iFlag = 32 Disable the return the count in the first element - effectively makes the array 0-based (must use UBound() to get the size in this case).;                    By Default the first element ($array[0]) contains the number of file found, the remaining elements ($array[1], $array[2], etc.);                  |$iFlag = 64 $sFilter is REGEXP Mod, See Pattern Parameters in StringRegExp (Can not be combined with flag 16);                  |$iFlag = 128 Return Backslash at the beginning of the file name, example Return "\Filename1.xxx" (Can not be combined with flag 8); Return values .: Failure - @Error;                  |1 = Path not found or invalid;                  |2 = Invalid $sFilter;                  |3 = No File(s) Found; Author ........: DXRW4E; Modified.......:; Remarks .......: The array returned is one-dimensional and is made up as follows:;                                $array[0] = Number of Files\Folders returned;                                $array[1] = 1st File\Folder;                                $array[2] = 2nd File\Folder;                                $array[3] = 3rd File\Folder;                                $array[n] = nth File\Folder; Related .......:; Link ..........:; Example .......: Yes; Note ..........: Special Thanks to SolidSnake & Tlem; ==================================================================================================================================================================Func _FileListToArrayEx($sPath, $sFilter = "*", $iFlag = 0)    $sPath = StringRegExpReplace($sPath & "\", "(?!\A)[\\/]+\h*", "\\")    If Not FileExists($sPath) Then Return SetError(1, 1, "")   If StringRegExp($sFilter, StringReplace('^\s*$|\v|[\\/:><"]|^\||\|\||\|$', "[" & Chr(BitAND($iFlag, 64) + 28) & '\/:><"]|^\||\|\||\|$', "\\\\")) Then Return SetError(2, 2, "")   Local $hSearch, $sFile, $sFileList, $sSubDir = BitAND($iFlag, 4), $sDelim = "|", $sDirFilter = StringReplace($sFilter, "*", "")    $hSearch = FileFindFirstFile($sPath & "*")    If @Error Then Return SetError(3, 3, "")   Local $hWSearch = $hSearch, $hWSTMP, $SearchWD, $Extended, $iFlags = StringReplace(BitAND($iFlag, 1) + BitAND($iFlag, 2), "3", "0")   If BitAND($iFlag, 8) Then $sDelim &= $sPath   If BitAND($iFlag, 128) Then $sDelim = "|\"   If Not BitAND($iFlag, 64) Then $sFilter = StringRegExpReplace(BitAND($iFlag, 16) & "(?i)(", "16\(\?\i\)|\d+", "") & StringRegExpReplace(StringRegExpReplace(StringRegExpReplace(StringRegExpReplace($sFilter, "[^*?|]+", "\\Q$0\\E"), "\\E(?=\||$)", "$0\$"), "(?<=^|\|)\\Q", "^$0"), "\*+", ".*") & ")"   While 1        $sFile = FileFindNextFile($hWSearch)        If @Error Then            If $hWSearch = $hSearch Then ExitLoop            FileClose($hWSearch)            $hWSearch -= 1            $SearchWD = StringLeft($SearchWD, StringInStr($SearchWD, "\", 1, -2))        ElseIf $sSubDir Then            $Extended = @Extended            If ($iFlags + $Extended <> 2) Then                If $sDirFilter Then                    If StringRegExp($sFile, $sFilter) Then $sFileList &= $sDelim & $SearchWD & $sFile                Else                    $sFileList &= $sDelim & $SearchWD & $sFile                EndIf            EndIf            If Not $Extended Then ContinueLoop            $hWSTMP = FileFindFirstFile($sPath & $SearchWD & $sFile & "\*")            If $hWSTMP = -1 Then ContinueLoop            $hWSearch = $hWSTMP            $SearchWD &= $sFile & "\"        Else            If ($iFlags + @Extended = 2) Or StringRegExp($sFile, $sFilter) = 0 Then ContinueLoop            $sFileList &= $sDelim & $sFile        EndIf    WEnd    FileClose($hSearch)    If Not $sFileList Then Return SetError(3, 3, "")   Return StringSplit(StringTrimLeft($sFileList, 1), "|", StringReplace(BitAND($iFlag, 32), "32", 2))EndFunc   ;==>_FileListToArrayEx 
  • 1 year later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...