Jump to content
Sign in to follow this  
Jex

Fonts Fetcher

Recommended Posts

Jex

That script downloads all fonts in www.dafonts.com or http://cooltext.com/Fonts links, extracts zip files and moves fonts to Windows/Fonts folder.

Posted Image

Download ( $Link, $Downloadtype, $Directorytype, $Directoryname )

$Link examples :

http://www.dafont.com/top.php?page=1&nb_ppp=50

http://www.dafont.com/top.php?page=2&nb_ppp=50

http://cooltext.com/Fonts-3D

http://cooltext.com/Fonts-Modern

$Downloadtype examples :

1 = Download fonts and automatic extract zip files or copy tff files to Windows/Fonts/ folder.

2 = Just download fonts. ( Not extract or copy. )

$Directorytype examples :

1 = Installing all fonts in "Fonts" directory.

2 = Installing dafonts fonts in "Fonts" directory and cooltext fonts in "Fonts2" directory.

3 = Installing fonts in your choiced directory. ( $Directoryname )

Example : Download ("http://cooltext.com/Fonts-3D", 1, 2)

#include <GUIConstants.au3>
#include <GuiEdit.au3>
#include <INet.au3>
#include <String.au3>
#include <_ZipPlugin.au3>
PluginOpen(@ScriptDir & "\Au3Zip.dll")

$Form = GUICreate("Fonts Fetcher", 305, 385, 358, 329, BitOR($WS_SYSMENU, $WS_CAPTION, $WS_POPUP, $WS_POPUPWINDOW, $WS_BORDER, $WS_CLIPSIBLINGS))
$Input1 = GUICtrlCreateInput("www.dafont.com/top.php?page=1&nb_ppp=50", 48, 16, 241, 21)
$Radio1 = GUICtrlCreateRadio("Download and install fonts.", 16, 48, 145, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlSetTip(-1, "Download fonts and automatic extract zip files or copy tff files to Windows/Fonts/ folder.")
$Radio2 = GUICtrlCreateRadio("Just download fonts.", 176, 48, 113, 17)
GUICtrlSetTip(-1, "Just download fonts. ( Not extract or copy. )")
$Input2 = GUICtrlCreateInput("Fonts", 88, 96, 201, 21)
GUICtrlSetState(-1, $GUI_DISABLE)
$Button = GUICtrlCreateButton("Start", 8, 128, 289, 25)
GUIStartGroup()
$Label1 = GUICtrlCreateLabel("Link :", 16, 24, 30, 17)
$Label2 = GUICtrlCreateLabel("Folder name :", 16, 104, 68, 17)
GUIStartGroup()
$Radio3 = GUICtrlCreateRadio("Dir type 1", 16, 72, 65, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlSetTip(-1, 'Installing all fonts in "Fonts" directory.')
$Radio4 = GUICtrlCreateRadio("Dir type 2", 96, 72, 65, 17)
GUICtrlSetTip(-1, 'Installing dafonts fonts in "Fonts" directory and cooltext fonts in "Fonts2" directory.')
$Radio5 = GUICtrlCreateRadio("Dir type 3", 176, 72, 65, 17)
GUICtrlSetTip(-1, 'Installing fonts in your choiced directory.')
$Progress1 = GUICtrlCreateProgress(8, 360, 289, 17)
$Edit = GUICtrlCreateEdit("", 8, 160, 289, 169)
$Label3 = GUICtrlCreateLabel("", 8, 336, 289, 17)
GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button
            GUICtrlSetState($Button, $GUI_DISABLE)
            $Par3 = ""
            If GUICtrlRead($Radio1) = $GUI_CHECKED Then
                $Par1 = 1
            Else
                $Par1 = 2
            EndIf
            If GUICtrlRead($Radio3) = $GUI_CHECKED Then
                $Par2 = 1
            ElseIf GUICtrlRead($Radio4) = $GUI_CHECKED Then
                $Par2 = 2
            Else
                $Par2 = 3
                $Par3 = GUICtrlRead($Input2)
            EndIf
            $Var = Download(GUICtrlRead($Input1), $Par1, $Par2, $Par3)
            Write($Var[0] & " Fonts downloaded and installed in " & $Var[1] & " seconds.")
            GUICtrlSetState($Button, $GUI_ENABLE)
        Case $Radio3
            GUICtrlSetState($Input2, $GUI_DISABLE)
        Case $Radio4
            GUICtrlSetState($Input2, $GUI_DISABLE)
        Case $Radio5
            GUICtrlSetState($Input2, $GUI_ENABLE)
    EndSwitch
WEnd

Func Download($Url, $Method = 1, $Dirtype = 1, $Dirtype3 = "")
    If $Dirtype = 3 Then $Dir = "\" & $Dirtype3 & "\" 
    GUICtrlSetData($Label3, "Download starting...")
    Write("Download starting from " & $Url)
    $Timer = TimerInit()
    $Source = _INetGetSource($Url)
    If StringInStr($Url, "dafont.com") Then
        $String = _StringBetween($Source, 'href="http://img.dafont.com/download/?file=', '">Download<br>')
        $Urltype = 1
        If $Dirtype <> 3 Then $Dir = "\Fonts\" 
    ElseIf StringInStr($Url, "cooltext.com") Then
        $String = _StringBetween($Source, 'Download:<a href=Download/Font/', '>Click Here</a><br />')
        $Urltype = 2
        If $Dirtype = 1 Then
            $Dir = "\Fonts\" 
        ElseIf $Dirtype = 2 Then
            $Dir = "\Fonts2\" 
        EndIf
    EndIf
    If Not FileExists(@ScriptDir & $Dir) Then DirCreate(@ScriptDir & $Dir)
    Dim $Var[UBound($String) + 1]
    For $i = 0 To UBound($String) - 1
        If $Urltype = 1 Then
            If Not FileExists(@ScriptDir & $Dir & $String[$i] & ".zip") Then
                $Download = 'http://img.dafont.com/download/?file=' & $String[$i]
                InetGet($Download, @ScriptDir & $Dir & $String[$i] & ".zip")
                Write(@ScriptDir & $Dir & $String[$i] & ".zip downloaded.")
            EndIf
        ElseIf $Urltype = 2 Then
            If Not FileExists(@ScriptDir & $Dir & $String[$i]) Then
                $Download = 'http://cooltext.com/Download/Font/' & $String[$i]
                InetGet($Download, @ScriptDir & $Dir & $String[$i])
                Write(@ScriptDir & $Dir & $String[$i] & " downloaded.")
            EndIf
        EndIf
        $Var[$i + 1] = $String[$i]
        $Calculate = Round((($i + 1) / UBound($String)) * 100, 0)
        GUICtrlSetData($Label3, "Downloading fonts (" & $i + 1 & " / " & UBound($String) & ") " & $Calculate & "%")
        GUICtrlSetData($Progress1, $Calculate)
    Next
    If $Method = 1 Then
        For $i = 1 To UBound($String)
            If $Urltype = 1 Then
                _ZipUnZip (@ScriptDir & $Dir & $Var[$i] & ".zip", @WindowsDir & "\Fonts\")
            ElseIf $Urltype = 2 Then
                If StringInStr($Var[$i], ".zip") Then
                    _ZipUnZip (@ScriptDir & $Dir & $Var[$i], @WindowsDir & "\Fonts\")
                ElseIf StringInStr($Var[$i], ".ttf") Then
                    FileCopy(@ScriptDir & $Dir & $Var[$i], @WindowsDir & "\Fonts\" & $Var[$i])
                EndIf
            EndIf
        Next
    EndIf
    $Timerdiff = TimerDiff($Timer)
    GUICtrlSetData($Label3, "Download completed (" & UBound($String) & " / " & UBound($String) & ") " & $Calculate & "%")
    Dim $Var[2] = [UBound($String), Round($Timerdiff, 0) / 1000 ]
    Return $Var
EndFunc   ;==>Download

Func Write($Data)
    If GUICtrlRead($Edit) = "" Then
        GUICtrlSetData($Edit, $Data)
    Else
        GUICtrlSetData($Edit, GUICtrlRead($Edit) & @CRLF & $Data)
    EndIf
    _GUICtrlEdit_LineScroll ($Edit, 0, _GUICtrlEdit_GetLineCount ($Edit))
EndFunc   ;==>Write

Need _ZipPlugin.au3 and Au3Zip.dll for extract zip files. http://www.autoitscript.com/forum/index.ph...p;hl=_zipplugin

_ZipPlugin.au3

Au3Zip.dll

Edited by Jex

Share this post


Link to post
Share on other sites
BrettF

Trying it now... Not to bad :P The progress is good. Easy to keep an eye on it. Overall, good job!

@Ashley- If your not gonna try it, then why say anything? Sure its a nice idea, why not see how nice an idea it actually is?

Share this post


Link to post
Share on other sites
Jex
BrettF

You could easily add a GUI to say, I want this font and not that one... You could also poll the font folder to see if there are duplicates, as not to download the same one. There is endless possibilities with this :P

Share this post


Link to post
Share on other sites
Kreatorul

Also you could preview it in the GUI :P Wow this has a lot of potential as I'm too lazy to search for fonts on the net...

Share this post


Link to post
Share on other sites
Jex

You could also poll the font folder to see if there are duplicates, as not to download the same one.

Now script check for if that font downloaded before or not.

By the way im suggest that 2 links fonts for download ( Top 100 )

Download("http://www.dafont.com/top.php?page=1&nb_ppp=50")

Download("http://www.dafont.com/top.php?page=2&nb_ppp=50")

Edit : I'm added that 2 links in script.

Edited by Jex

Share this post


Link to post
Share on other sites
gamepin126

Couldn't you just do

For $n = 1 to 2
     Download("http://www.dafont.com/top.php?page=" & $n & "&nb_ppp=50")
Next

?

Very nice script by the way :P

Edited by gamepin126

Share this post


Link to post
Share on other sites
MadBoy

Very thanks for your comment Bert :P

Jex i am wondering will just copying the fonts into fonts directory install them in a system aswell? I've been reading somewhere you still have to go and install them from the windows explorer gui?


My little company: Evotec (PL version: Evotec)

Share this post


Link to post
Share on other sites
gamepin126

Yea, you can just drag n drop them into the fonts folder to install them.

Share this post


Link to post
Share on other sites
Jex

Jex i am wondering will just copying the fonts into fonts directory install them in a system aswell? I've been reading somewhere you still have to go and install them from the windows explorer gui?

I'm dont understand what you are asking but script extracting fonts in Windows/Fonts folder. That mean not need go and install them from the windows explorer gui.

@Gamepin126

Not need drag n drop. Script installing fonts automaticly.

Edited by Jex

Share this post


Link to post
Share on other sites
gamepin126

I know, I was just answering his question.

Jex i am wondering will just copying the fonts into fonts directory install them in a system aswell?

Share this post


Link to post
Share on other sites
gseller

Nice! I'm Lovin' it! JEX, you keep adding great scripts to the forum.. Thanks!

Share this post


Link to post
Share on other sites
Gif

interesting, with many potentials for future use.

Share this post


Link to post
Share on other sites
Jex
BrettF
Jex

If i'm add fonts pictures in gui that will increase fonts download speed because first need install fonts images and that not good idea i think.

But i will create gui for write fonts links there or select parameters and that gui will be have progressbar etc?

Share this post


Link to post
Share on other sites
Jex
BrettF

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×