Jump to content

Font Previewer


KaFu
 Share

Recommended Posts

Simple little script to preview Fonts size and weight on labels.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Local $msg

; FONT NAME Win95 WinNT Win98 Win2000 WinMe WinXP Vista
Global $aFonts[65][8] = [['Abadi MT Condensed Light', 0, 0, 1, 0, 0, 0, 0],['Arial', 1, 1, 1, 1, 1, 1, 1],['Arial Alternative Regular', 0, 0, 0, 0, 1, 0, 0],['Arial Alternative Symbol', 0, 0, 0, 0, 1, 0, 0] _
        ,['Arial Black', 0, 0, 1, 1, 1, 1, 1],['Book Antiqua', 0, 0, 1, 0, 0, 1, 1],['Calibri', 0, 0, 0, 0, 0, 0, 1],['Calisto MT', 0, 0, 1, 0, 0, 0, 0],['Cambria', 0, 0, 0, 0, 0, 0, 1],['Candara', 0, 0, 0, 0, 0, 0, 1] _
        ,['Century Gothic', 0, 0, 1, 0, 0, 0, 0],['Comic Sans MS', 0, 0, 1, 1, 1, 0, 0],['Consolas', 0, 0, 0, 0, 0, 0, 1],['Constantias', 0, 0, 0, 0, 0, 0, 1],['Copperplate Gothic Bold', 0, 0, 1, 0, 0, 0, 0] _
        ,['Copperplate Gothic Light', 0, 0, 1, 0, 0, 0, 0],['Corbel', 0, 0, 0, 0, 0, 0, 1],['Courier', 1, 1, 1, 1, 1, 1, 1],['Courier New', 1, 1, 1, 1, 1, 1, 1],['Estrangelo Edessa', 0, 0, 0, 0, 0, 1, 1] _
        ,['Franklin Gothic Medium', 0, 0, 0, 0, 0, 1, 1],['Gautami', 0, 0, 0, 0, 0, 1, 1],['Georgia', 0, 0, 0, 1, 0, 1, 1],['Georgia Italic Impact', 0, 0, 0, 0, 0, 1, 0],['Impact', 0, 0, 1, 1, 1, 1, 1] _
        ,['Latha', 0, 0, 0, 0, 0, 1, 1],['Lucida Console', 0, 1, 1, 1, 1, 1, 1],['Lucida Handwriting Italic', 0, 0, 1, 0, 0, 0, 0],['Lucida Sans Console', 0, 0, 0, 0, 0, 1, 1],['Lucida Sans Italic', 0, 0, 1, 0, 0, 0, 0] _
        ,['Lucida Sans Unicode', 0, 0, 1, 1, 0, 1, 1],['Marlett', 0, 0, 1, 0, 1, 0, 1],['Matisse ITC', 0, 0, 1, 0, 0, 0, 0],['Modern', 1, 1, 1, 1, 0, 0, 0],['Modern MS Sans Serif', 0, 0, 0, 0, 0, 1, 0] _
        ,['MS Sans Serif', 1, 1, 1, 1, 1, 1, 1],['MS Serif', 1, 1, 1, 1, 1, 1, 1],['Mv Boli', 0, 0, 0, 0, 0, 1, 1],['News Gothic MT', 0, 0, 1, 0, 0, 0, 0],['OCR A Extended', 0, 0, 1, 0, 0, 0, 0] _
        ,['Palatino Linotype', 0, 0, 0, 1, 0, 1, 1],['Roman', 0, 1, 0, 1, 0, 1, 1],['Script', 0, 1, 0, 1, 0, 1, 1],['Sego Print', 0, 0, 0, 0, 0, 0, 1],['Sego Script', 0, 0, 0, 0, 0, 0, 1],['Sego UI', 0, 0, 0, 0, 0, 0, 1] _
        ,['Small Fonts', 0, 1, 0, 1, 0, 1, 1],['Smallfonts', 1, 0, 1, 0, 1, 0, 0],['Symbol', 1, 1, 1, 1, 1, 1, 1],['Tahoma', 0, 0, 1, 1, 1, 1, 1],['Tempus Sans ITC', 0, 0, 1, 1, 0, 0, 0],['Times New Roman', 1, 1, 1, 1, 1, 1, 1] _
        ,['Trebuchet', 0, 0, 0, 1, 1, 1, 1],['Tunga', 0, 0, 0, 0, 0, 1, 1],['Verdana', 0, 0, 1, 1, 1, 1, 1],['Webdings', 0, 0, 1, 1, 1, 1, 1],['Westminster', 0, 0, 1, 0, 1, 1, 0],['Wingdings', 1, 1, 0, 1, 0, 1, 1] _
        ,['WST_Czech', 0, 0, 0, 0, 0, 1, 0],['WST_Engl', 0, 0, 0, 0, 0, 1, 0],['WST_Fren', 0, 0, 0, 0, 0, 1, 0],['WST_Germ', 0, 0, 0, 0, 0, 1, 0],['WST_Ital', 0, 0, 0, 0, 0, 1, 0],['WST_Span', 0, 0, 0, 0, 0, 1, 0],['WST_Swed', 0, 0, 0, 0, 0, 1, 0]]

$GUI = GUICreate("Font Previewer", 760, 670) ; will create a dialog box that when displayed is centered
GUISetBkColor(0xFFFFFF)
GUISetState(@SW_SHOW) ; will display an empty dialog box

GUICtrlCreateLabel("Font available on", 10, 13, 85)
$combo_OS = GUICtrlCreateCombo("", 100, 10, 140)
GUICtrlSetData(-1, "Win95|WinNT|Win98|Win2000|WinMe|WinXP|Vista|-----|Win2000, WinXP, Vista|All OS", "Win2000, WinXP, Vista")

GUICtrlCreateLabel("Select Font to preview", 250, 13, 110)
$combo_Font = GUICtrlCreateCombo("", 370, 10, 160)

Global $aLabel[20][4]

For $i = 1 To 20
    $aLabel[$i - 1][0] = GUICtrlCreateLabel("Arial " & $i, 20, 20 + 30 * $i, 180, 30)
    GUICtrlSetFont(-1, $i, 200, 0, "Arial")
    $aLabel[$i - 1][1] = GUICtrlCreateLabel("Arial " & $i, 220, 20 + 30 * $i, 180, 30)
    GUICtrlSetFont(-1, $i, 400, 0, "Arial")
    $aLabel[$i - 1][2] = GUICtrlCreateLabel("Arial " & $i, 420, 20 + 30 * $i, 180, 30)
    GUICtrlSetFont(-1, $i, 600, 0, "Arial")
    $aLabel[$i - 1][3] = GUICtrlCreateLabel("Arial " & $i, 620, 20 + 30 * $i, 180, 30)
    GUICtrlSetFont(-1, $i, 800, 0, "Arial")
Next

Populate_Combo_Font()

While 1
    $msg = GUIGetMsg()

    If $msg = $combo_OS Then Populate_Combo_Font()

    If $msg = $combo_Font Then
        For $i = 1 To 20
            GUICtrlSetFont($aLabel[$i - 1][0], $i, 200, 0, GUICtrlRead($combo_Font))
            GUICtrlSetData($aLabel[$i - 1][0], GUICtrlRead($combo_Font) & " " & $i)

            GUICtrlSetFont($aLabel[$i - 1][1], $i, 400, 0, GUICtrlRead($combo_Font))
            GUICtrlSetData($aLabel[$i - 1][1], GUICtrlRead($combo_Font) & " " & $i)

            GUICtrlSetFont($aLabel[$i - 1][2], $i, 600, 0, GUICtrlRead($combo_Font))
            GUICtrlSetData($aLabel[$i - 1][2], GUICtrlRead($combo_Font) & " " & $i)

            GUICtrlSetFont($aLabel[$i - 1][3], $i, 800, 0, GUICtrlRead($combo_Font))
            GUICtrlSetData($aLabel[$i - 1][3], GUICtrlRead($combo_Font) & " " & $i)
        Next
    EndIf

    If $msg = $GUI_EVENT_CLOSE Then ExitLoop

WEnd

GUIDelete()

Func Populate_Combo_Font()
    Local $sFont, $sOS
    $sOS = GUICtrlRead($combo_OS)
    For $i = 0 To 64
        Switch $sOS
            Case "Win95"
                If $aFonts[$i][1] = 1 Then
                    If $sFont Then
                        $sFont &= "|" & $aFonts[$i][0]
                    Else
                        $sFont &= $aFonts[$i][0]
                    EndIf
                EndIf
            Case "WinNT"
                If $aFonts[$i][2] = 1 Then
                    If $sFont Then
                        $sFont &= "|" & $aFonts[$i][0]
                    Else
                        $sFont &= $aFonts[$i][0]
                    EndIf
                EndIf
            Case "Win98"
                If $aFonts[$i][3] = 1 Then
                    If $sFont Then
                        $sFont &= "|" & $aFonts[$i][0]
                    Else
                        $sFont &= $aFonts[$i][0]
                    EndIf
                EndIf
            Case "Win2000"
                If $aFonts[$i][4] = 1 Then
                    If $sFont Then
                        $sFont &= "|" & $aFonts[$i][0]
                    Else
                        $sFont &= $aFonts[$i][0]
                    EndIf
                EndIf
            Case "WinMe"
                If $aFonts[$i][5] = 1 Then
                    If $sFont Then
                        $sFont &= "|" & $aFonts[$i][0]
                    Else
                        $sFont &= $aFonts[$i][0]
                    EndIf
                EndIf
            Case "WinXP"
                If $aFonts[$i][6] = 1 Then
                    If $sFont Then
                        $sFont &= "|" & $aFonts[$i][0]
                    Else
                        $sFont &= $aFonts[$i][0]
                    EndIf
                EndIf
            Case "Vista"
                If $aFonts[$i][7] = 1 Then
                    If $sFont Then
                        $sFont &= "|" & $aFonts[$i][0]
                    Else
                        $sFont &= $aFonts[$i][0]
                    EndIf
                EndIf
            Case "Win2000, WinXP, Vista"
                $bValid = True
                If $aFonts[$i][4] = 0 Then $bValid = False ; Win2000
                If $aFonts[$i][6] = 0 Then $bValid = False ; WinXP
                If $aFonts[$i][7] = 0 Then $bValid = False ; Vista
                If $bValid = True Then
                    If $sFont Then
                        $sFont &= "|" & $aFonts[$i][0]
                    Else
                        $sFont &= $aFonts[$i][0]
                    EndIf
                EndIf
            Case "All OS"
                $bValid = True
                For $y = 1 To 7
                    If $aFonts[$i][$y] = 0 Then $bValid = False
                Next
                If $bValid = True Then
                    If $sFont Then
                        $sFont &= "|" & $aFonts[$i][0]
                    Else
                        $sFont &= $aFonts[$i][0]
                    EndIf
                EndIf
        EndSwitch
    Next
    If $sFont Then
        GUICtrlSetData($combo_Font, "")
        GUICtrlSetData($combo_Font, $sFont, "Arial")
    EndIf
EndFunc   ;==>Populate_Combo_Font

Best Regards

Link to comment
Share on other sites

Simple little script to preview Fonts size and weight on labels.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Local $msg

; FONT NAME Win95 WinNT Win98 Win2000 WinMe WinXP Vista
Global $aFonts[65][8] = [['Abadi MT Condensed Light', 0, 0, 1, 0, 0, 0, 0],['Arial', 1, 1, 1, 1, 1, 1, 1],['Arial Alternative Regular', 0, 0, 0, 0, 1, 0, 0],['Arial Alternative Symbol', 0, 0, 0, 0, 1, 0, 0] _
        ,['Arial Black', 0, 0, 1, 1, 1, 1, 1],['Book Antiqua', 0, 0, 1, 0, 0, 1, 1],['Calibri', 0, 0, 0, 0, 0, 0, 1],['Calisto MT', 0, 0, 1, 0, 0, 0, 0],['Cambria', 0, 0, 0, 0, 0, 0, 1],['Candara', 0, 0, 0, 0, 0, 0, 1] _
        ,['Century Gothic', 0, 0, 1, 0, 0, 0, 0],['Comic Sans MS', 0, 0, 1, 1, 1, 0, 0],['Consolas', 0, 0, 0, 0, 0, 0, 1],['Constantias', 0, 0, 0, 0, 0, 0, 1],['Copperplate Gothic Bold', 0, 0, 1, 0, 0, 0, 0] _
        ,['Copperplate Gothic Light', 0, 0, 1, 0, 0, 0, 0],['Corbel', 0, 0, 0, 0, 0, 0, 1],['Courier', 1, 1, 1, 1, 1, 1, 1],['Courier New', 1, 1, 1, 1, 1, 1, 1],['Estrangelo Edessa', 0, 0, 0, 0, 0, 1, 1] _
        ,['Franklin Gothic Medium', 0, 0, 0, 0, 0, 1, 1],['Gautami', 0, 0, 0, 0, 0, 1, 1],['Georgia', 0, 0, 0, 1, 0, 1, 1],['Georgia Italic Impact', 0, 0, 0, 0, 0, 1, 0],['Impact', 0, 0, 1, 1, 1, 1, 1] _
        ,['Latha', 0, 0, 0, 0, 0, 1, 1],['Lucida Console', 0, 1, 1, 1, 1, 1, 1],['Lucida Handwriting Italic', 0, 0, 1, 0, 0, 0, 0],['Lucida Sans Console', 0, 0, 0, 0, 0, 1, 1],['Lucida Sans Italic', 0, 0, 1, 0, 0, 0, 0] _
        ,['Lucida Sans Unicode', 0, 0, 1, 1, 0, 1, 1],['Marlett', 0, 0, 1, 0, 1, 0, 1],['Matisse ITC', 0, 0, 1, 0, 0, 0, 0],['Modern', 1, 1, 1, 1, 0, 0, 0],['Modern MS Sans Serif', 0, 0, 0, 0, 0, 1, 0] _
        ,['MS Sans Serif', 1, 1, 1, 1, 1, 1, 1],['MS Serif', 1, 1, 1, 1, 1, 1, 1],['Mv Boli', 0, 0, 0, 0, 0, 1, 1],['News Gothic MT', 0, 0, 1, 0, 0, 0, 0],['OCR A Extended', 0, 0, 1, 0, 0, 0, 0] _
        ,['Palatino Linotype', 0, 0, 0, 1, 0, 1, 1],['Roman', 0, 1, 0, 1, 0, 1, 1],['Script', 0, 1, 0, 1, 0, 1, 1],['Sego Print', 0, 0, 0, 0, 0, 0, 1],['Sego Script', 0, 0, 0, 0, 0, 0, 1],['Sego UI', 0, 0, 0, 0, 0, 0, 1] _
        ,['Small Fonts', 0, 1, 0, 1, 0, 1, 1],['Smallfonts', 1, 0, 1, 0, 1, 0, 0],['Symbol', 1, 1, 1, 1, 1, 1, 1],['Tahoma', 0, 0, 1, 1, 1, 1, 1],['Tempus Sans ITC', 0, 0, 1, 1, 0, 0, 0],['Times New Roman', 1, 1, 1, 1, 1, 1, 1] _
        ,['Trebuchet', 0, 0, 0, 1, 1, 1, 1],['Tunga', 0, 0, 0, 0, 0, 1, 1],['Verdana', 0, 0, 1, 1, 1, 1, 1],['Webdings', 0, 0, 1, 1, 1, 1, 1],['Westminster', 0, 0, 1, 0, 1, 1, 0],['Wingdings', 1, 1, 0, 1, 0, 1, 1] _
        ,['WST_Czech', 0, 0, 0, 0, 0, 1, 0],['WST_Engl', 0, 0, 0, 0, 0, 1, 0],['WST_Fren', 0, 0, 0, 0, 0, 1, 0],['WST_Germ', 0, 0, 0, 0, 0, 1, 0],['WST_Ital', 0, 0, 0, 0, 0, 1, 0],['WST_Span', 0, 0, 0, 0, 0, 1, 0],['WST_Swed', 0, 0, 0, 0, 0, 1, 0]]

$GUI = GUICreate("Font Previewer", 760, 670) ; will create a dialog box that when displayed is centered
GUISetBkColor(0xFFFFFF)
GUISetState(@SW_SHOW) ; will display an empty dialog box

GUICtrlCreateLabel("Font available on", 10, 13, 85)
$combo_OS = GUICtrlCreateCombo("", 100, 10, 140)
GUICtrlSetData(-1, "Win95|WinNT|Win98|Win2000|WinMe|WinXP|Vista|-----|Win2000, WinXP, Vista|All OS", "Win2000, WinXP, Vista")

GUICtrlCreateLabel("Select Font to preview", 250, 13, 110)
$combo_Font = GUICtrlCreateCombo("", 370, 10, 160)

Global $aLabel[20][4]

For $i = 1 To 20
    $aLabel[$i - 1][0] = GUICtrlCreateLabel("Arial " & $i, 20, 20 + 30 * $i, 180, 30)
    GUICtrlSetFont(-1, $i, 200, 0, "Arial")
    $aLabel[$i - 1][1] = GUICtrlCreateLabel("Arial " & $i, 220, 20 + 30 * $i, 180, 30)
    GUICtrlSetFont(-1, $i, 400, 0, "Arial")
    $aLabel[$i - 1][2] = GUICtrlCreateLabel("Arial " & $i, 420, 20 + 30 * $i, 180, 30)
    GUICtrlSetFont(-1, $i, 600, 0, "Arial")
    $aLabel[$i - 1][3] = GUICtrlCreateLabel("Arial " & $i, 620, 20 + 30 * $i, 180, 30)
    GUICtrlSetFont(-1, $i, 800, 0, "Arial")
Next

Populate_Combo_Font()

While 1
    $msg = GUIGetMsg()

    If $msg = $combo_OS Then Populate_Combo_Font()

    If $msg = $combo_Font Then
        For $i = 1 To 20
            GUICtrlSetFont($aLabel[$i - 1][0], $i, 200, 0, GUICtrlRead($combo_Font))
            GUICtrlSetData($aLabel[$i - 1][0], GUICtrlRead($combo_Font) & " " & $i)

            GUICtrlSetFont($aLabel[$i - 1][1], $i, 400, 0, GUICtrlRead($combo_Font))
            GUICtrlSetData($aLabel[$i - 1][1], GUICtrlRead($combo_Font) & " " & $i)

            GUICtrlSetFont($aLabel[$i - 1][2], $i, 600, 0, GUICtrlRead($combo_Font))
            GUICtrlSetData($aLabel[$i - 1][2], GUICtrlRead($combo_Font) & " " & $i)

            GUICtrlSetFont($aLabel[$i - 1][3], $i, 800, 0, GUICtrlRead($combo_Font))
            GUICtrlSetData($aLabel[$i - 1][3], GUICtrlRead($combo_Font) & " " & $i)
        Next
    EndIf

    If $msg = $GUI_EVENT_CLOSE Then ExitLoop

WEnd

GUIDelete()

Func Populate_Combo_Font()
    Local $sFont, $sOS
    $sOS = GUICtrlRead($combo_OS)
    For $i = 0 To 64
        Switch $sOS
            Case "Win95"
                If $aFonts[$i][1] = 1 Then
                    If $sFont Then
                        $sFont &= "|" & $aFonts[$i][0]
                    Else
                        $sFont &= $aFonts[$i][0]
                    EndIf
                EndIf
            Case "WinNT"
                If $aFonts[$i][2] = 1 Then
                    If $sFont Then
                        $sFont &= "|" & $aFonts[$i][0]
                    Else
                        $sFont &= $aFonts[$i][0]
                    EndIf
                EndIf
            Case "Win98"
                If $aFonts[$i][3] = 1 Then
                    If $sFont Then
                        $sFont &= "|" & $aFonts[$i][0]
                    Else
                        $sFont &= $aFonts[$i][0]
                    EndIf
                EndIf
            Case "Win2000"
                If $aFonts[$i][4] = 1 Then
                    If $sFont Then
                        $sFont &= "|" & $aFonts[$i][0]
                    Else
                        $sFont &= $aFonts[$i][0]
                    EndIf
                EndIf
            Case "WinMe"
                If $aFonts[$i][5] = 1 Then
                    If $sFont Then
                        $sFont &= "|" & $aFonts[$i][0]
                    Else
                        $sFont &= $aFonts[$i][0]
                    EndIf
                EndIf
            Case "WinXP"
                If $aFonts[$i][6] = 1 Then
                    If $sFont Then
                        $sFont &= "|" & $aFonts[$i][0]
                    Else
                        $sFont &= $aFonts[$i][0]
                    EndIf
                EndIf
            Case "Vista"
                If $aFonts[$i][7] = 1 Then
                    If $sFont Then
                        $sFont &= "|" & $aFonts[$i][0]
                    Else
                        $sFont &= $aFonts[$i][0]
                    EndIf
                EndIf
            Case "Win2000, WinXP, Vista"
                $bValid = True
                If $aFonts[$i][4] = 0 Then $bValid = False ; Win2000
                If $aFonts[$i][6] = 0 Then $bValid = False ; WinXP
                If $aFonts[$i][7] = 0 Then $bValid = False ; Vista
                If $bValid = True Then
                    If $sFont Then
                        $sFont &= "|" & $aFonts[$i][0]
                    Else
                        $sFont &= $aFonts[$i][0]
                    EndIf
                EndIf
            Case "All OS"
                $bValid = True
                For $y = 1 To 7
                    If $aFonts[$i][$y] = 0 Then $bValid = False
                Next
                If $bValid = True Then
                    If $sFont Then
                        $sFont &= "|" & $aFonts[$i][0]
                    Else
                        $sFont &= $aFonts[$i][0]
                    EndIf
                EndIf
        EndSwitch
    Next
    If $sFont Then
        GUICtrlSetData($combo_Font, "")
        GUICtrlSetData($combo_Font, $sFont, "Arial")
    EndIf
EndFunc   ;==>Populate_Combo_Font

Best Regards

Useful idea KaFu.

Maybe you could have an option to read all the installed fonts on the current PC from

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows[NT]\CurrentVersion\Fonts

It would also be useful if you could select some class of fonts. For example, populate the combo with all the fonts which are monspaced, or all which are TrueType.

mgreffonts1

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

@KaFu

Nice One :)

@martin

Thanks for the idea, I've made an example with it :

#include <File.au3>
 
 Local $i_font = _FileListToArray(@WindowsDir & '\Fonts', '*'), $s_font, $aLabel[20][4]
 
 For $i = 1 To $i_font[0]
     $r_font = RegEnumVal('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts', $i)
     If StringInStr($r_font, '(') Then
         $s_font &= StringLeft($r_font, StringInStr($r_font, ' (') -1) & '|'
     EndIf
 Next
 
 
 $GUI = GUICreate('Font Previewer', 760, 550); will create a dialog box that when displayed is centered
 GUISetBkColor(0xFFFFFF)
 GUISetState(@SW_SHOW); will display an empty dialog box
 
 GUICtrlCreateLabel('Select Font to preview :', 80, 5, 170)
 GUICtrlSetFont(-1, 12)
 $combo_Font = GUICtrlCreateCombo('', 260, 5, 200, 20, 2097155)
 GUICtrlSetData($combo_Font, $s_font)
 
 
 
 For $i = 5 To 20
     $aLabel[$i - 1][0] = GUICtrlCreateLabel('Arial ' & $i, 20, -100 + 30 * $i, 180, 7 + $i)
     GUICtrlSetFont(-1, $i, 200, 0, 'Arial')
     $aLabel[$i - 1][1] = GUICtrlCreateLabel('Arial ' & $i, 220, -100 + 30 * $i, 180, 7 + $i)
     GUICtrlSetFont(-1, $i, 400, 0, 'Arial')
     $aLabel[$i - 1][2] = GUICtrlCreateLabel('Arial ' & $i, 420, -100 + 30 * $i, 180, 7 + $i)
     GUICtrlSetFont(-1, $i, 600, 0, 'Arial')
     $aLabel[$i - 1][3] = GUICtrlCreateLabel('Arial ' & $i, 620, -100 + 30 * $i, 180, 7 + $i)
     GUICtrlSetFont(-1, $i, 800, 0, 'Arial')
 Next
 
 
 While 1
     $msg = GUIGetMsg( )
     If $msg = -3 Then Exit
     
     If $msg = $combo_Font Then
         For $i = 5 To 20
             GUICtrlSetData($aLabel[$i - 1][0], GUICtrlRead($combo_Font) & ' ' & $i)
             GUICtrlSetFont($aLabel[$i - 1][0], $i, 200, 0, GUICtrlRead($combo_Font))
 
             GUICtrlSetData($aLabel[$i - 1][1], GUICtrlRead($combo_Font) & ' ' & $i)
             GUICtrlSetFont($aLabel[$i - 1][1], $i, 400, 0, GUICtrlRead($combo_Font))
 
             GUICtrlSetData($aLabel[$i - 1][2], GUICtrlRead($combo_Font) & ' ' & $i)
             GUICtrlSetFont($aLabel[$i - 1][2], $i, 600, 0, GUICtrlRead($combo_Font))
 
             GUICtrlSetData($aLabel[$i - 1][3], GUICtrlRead($combo_Font) & ' ' & $i)
             GUICtrlSetFont($aLabel[$i - 1][3], $i, 800, 0, GUICtrlRead($combo_Font))
         Next
     EndIf
 WEnd

Edit 1 : Fixed StringInStr problem

Edit 2 : Added scrolling combo

Cheers, FireFox.

Edited by FireFox
Link to comment
Share on other sites

Some time ago i made one also:

#include <GuiConstantsEx.au3>
#include <String.au3>
#include <Array.au3>


Dim $aFonts[1] = ["0"]
dim $searchstring[1]
;///////////////////////////////////////////////////
;/  create array with fonts list
;///////////////////////////////////////////////////
$sRegRoot = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts"

$i = 1
Do
    $var = RegEnumVal($sRegRoot, $i)
    If Not @error Then
        $iIndex = $aFonts[0] + 1
        ReDim $aFonts[$iIndex + 1]
        $aFonts[0] = $iIndex
        $aFonts[$iIndex] = $var
        
;~      msgbox(0,"",$aFonts[])
    EndIf
    $i += 1
Until @error



;///////////////////////////////////////////////////
;/  order in array - create html file
;///////////////////////////////////////////////////
_ArraySort($aFonts,0,1)
$file = FileOpen("yourfonts.html", 10); which is similar to 2 + 8 (erase + create dir)

;head of html file
FileWriteLine($file, "</body>" & @CRLF)
FileWriteLine($file, "</html>" & @CRLF)
FileWriteLine($file, "<html>" & @CRLF)
FileWriteLine($file, "<head>" & @CRLF)
FileWriteLine($file, "<title>Your Fonts</title>" & @CRLF)
FileWriteLine($file, "<meta http-equiv=" & chr(34) & "Content-Type" & chr(34) & "content=" & chr(34) & "text/html; charset=iso-8859-1" & chr(34) & ">" & @CRLF)
FileWriteLine($file, "</head>" & @CRLF)
FileWriteLine($file, "" & @CRLF)
FileWriteLine($file, "<body bgcolor=" & chr(34) & "#FFFFFF" & chr(34) & ">" & @CRLF)
FileWriteLine($file, "<p>" & @CRLF)


;////////////////////////////////////////////////////
;/ cicle trought list - clean font names - build html
;////////////////////////////////////////////////////
$i = 1
Do
    
    if $i > _ArrayMaxIndex($aFonts, 0, 1) Then
        exitloop
    EndIf
    
    If Not @error Then
;~      msgbox(0,"", RegRead($sRegRoot, $aFonts[$i]))

        $result = StringInStr(RegRead($sRegRoot, $aFonts[$i]), "\")
;~  MsgBox(0, "Search result:", $result)

    ;if \ not found go on
        if $result = 0 Then


            ;if ( found go on
                $result = StringInStr($aFonts[$i], "(")
;~              msgbox(0,"",$result)
                if $result <> 0 Then
                    $clean_font = _StringReplaceBetween($aFonts[$i], "(", ")", "")
                    $clean_font = stringreplace($clean_font, "(", "")
                    $clean_font = stringreplace($clean_font, ")", "")
                    $clean_font = StringStripWS($clean_font,3)
                    
                    FileWriteLine($file, "<font face=" & chr(34) & $clean_font & chr(34) & ">" & stringleft($clean_font & "_______" & $result & "________", 30) & " - The quick brown fox jumps over the lazy dog</font><br>" & @CRLF)
;~          else
;~              $clean_font = StringStripWS($aFonts[$i],3)
                EndIf
                
                
;~          FileWriteLine($file, "<font face=" & chr(34) & $clean_font & chr(34) & ">" & stringleft($clean_font & "____________________", 30) & " - The quick brown fox jumps over the lazy dog</font><br>" & @CRLF)
                

            $i += 1
        elseif $result <> 0 Then
            $i += 1
        Endif   
    EndIf
Until @error

;close html file
FileWriteLine($file, "</body>" & @CRLF)
FileWriteLine($file, "</html>" & @CRLF)




;///////////////////////////////////////////////////
;/  functions
;///////////////////////////////////////////////////

Func _StringReplaceBetween ($sString, $sStart, $sEnd, $sReplace)
    dim $searchstring[1]
    $searchstring = _StringBetween ($sString, $sStart, $sEnd)
    If @error Then SetError (1, -1, 0)
    $return = StringReplace ($sString, $searchstring[0], $sReplace)
    Return $return
EndFunc

return html page with font in your system,

m.

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...