Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Windows Font List
#1
Code: (Select All)
'Option _Explicit

Screen _NewImage(800, 600, 32)
'$Console:Only

Type Font_Name_Type
Name As String
FileName As String
End Type
ReDim Shared As Font_Name_Type Fonts(10000), MonoFonts(10000)
Screen _NewImage(1280, 720, 32)
GetFontList
GetMonoFontList
numbered = -1 'number our quick list
l = 20 'number of lines to print to the screen
w = 50 'width to print to the screen

Do
Cls
_Limit 30
k = _KeyHit
Select Case k
Case 20480: s = s + 1: If s > UBound(Fonts) Then s = UBound(Fonts)
Case 18432: s = s - 1: If s < 0 Then s = 0
End Select
Locate 3, 20: Print "FONT NAME"
Locate 3, 70: Print "FILE NAME"
Locate 5
start = s: finish = s + l - 1
For i = start To finish
If i > UBound(Fonts) Then _Continue
If numbered Then counter$ = LTrim$(Str$(i)) + ") "
Locate , 10: Print counter$ + Left$(Fonts(i).Name, w);
Locate , 70: Print Fonts(i).FileName
Next
Locate 28, 15: Print "MONOSPACE FONT NAME"
Locate 28, 70: Print "FILE NAME"
Locate 30
For i1 = 0 To UBound(MonoFonts)
If numbered Then counter$ = LTrim$(Str$(i1)) + ") "
Locate , 10: Print counter$ + Left$(MonoFonts(i1).Name, w);
Locate , 70: Print Left$(MonoFonts(i1).FileName, w)
Next

_Display
Loop Until k = 27
System



Sub GetFontList
Shell "Powershell -command " + Chr$(34) + "$Host.UI.RawUI.BufferSize = New-Object Management.Automation.Host.Size (500, 50); Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts'|Out-File -Encoding Ascii 'temp_fontlist.txt'" + Chr$(34)
If _FileExists("temp_fontlist.txt") Then
f = FreeFile
Open "temp_fontlist.txt" For Binary As #f

Do Until EOF(1)
Line Input #1, temp$
sep = InStr(temp$, ":")
l$ = _Trim$(Left$(temp$, sep - 1))
r$ = _Trim$(Mid$(temp$, sep + 1))
If l$ <> "PSPath" Then
If l$ <> "" Then ' skip the blank space lines
Fonts(count).Name = l$
Fonts(count).FileName = r$
count = count + 1
End If
Else
Exit Do ' we can stop reading files at this point (according to my tests)
End If
Loop
Close f
Kill "temp_fontlist.txt" ' clean up the file after we're done with parsing it.
count = count - 1 ' adjust for that last count + 1, which we didn't use.
ReDim _Preserve Fonts(count) As Font_Name_Type

'a quick and simple combsort to make certain our list is in alphabetical order
gap = count
Do
gap = 10 * gap \ 13
If gap < 1 Then gap = 1
i = 0
swapped = 0
Do
If Fonts(i).Name > Fonts(i + gap).Name Then
Swap Fonts(i).Name, Fonts(i + gap).Name
Swap Fonts(i).FileName, Fonts(i + gap).FileName
swapped = -1
End If
i = i + 1
Loop Until i + gap > count
Loop Until gap = 1 And swapped = 0
Else 'very poor error handling here
Print "Powershell failed to create font list."
Beep
Sleep
Exit Sub
End If
End Sub

Sub GetMonoFontList
count = UBound(Fonts)
newcount = 0
f = _Font
For i = 0 To count
f$ = Fonts(i).FileName
If UCase$(Right$(f$, 4)) = ".FON" Then _Continue
temp = _LoadFont(f$, 12)
_Font temp
'no need to check all characters. I chose to just check the ones that tend to vary the greatest
pw = _PrintWidth("W"): pw1 = _PrintWidth("l")
If pw = pw1 Then
pw2 = _PrintWidth(" ")
If pw = pw2 Then
pw3 = _PrintWidth(".")
If pw = pw3 Then
MonoFonts(newcount).Name = Fonts(i).Name
MonoFonts(newcount).FileName = Fonts(i).FileName
newcount = newcount + 1
End If
End If
End If
_Font f
_FreeFont temp
Next
newcount = newcount - 1
If newcount >= 0 Then ReDim _Preserve MonoFonts(newcount) As Font_Name_Type
End Sub




Sub Pause (time As _Float, exclude_code As Long)
'exclude_code is the binary value of things we don't want to allow to break Pause
'1 = No brealing pause if Window lost focus
'2 = No Mouse breaking pause
'4 - No Keyboard breaking pause
'8 - No Keyup events break pause
'16 - No modifier keys breaking pause (Shift/Ctrl/Alt)

Dim t As _Float, k As Long, d As String
d = Date$: t = Timer + time
Do
_Limit 10 'we're a pause. We don't need to do a bunch of crap per second.
If (exclude_code And 1) Then 'don't unpause until window has focus or time has ran out
If _WindowHasFocus = 0 Then _Continue
End If
If (exclude_code And 2) = 0 Then 'mouse clicks break pause
While _MouseInput: Wend
If _MouseButton(1) Or _MouseButton(2) Then Exit Do
End If
If (exclude_code And 4) = 0 Then 'we allow keyboard input (of some sort) to break pause
k = _KeyHit
If (exclude_code And 8) Then If k < 0 Then k = 0 'but we don't allow keyup events to do it
If (exclude_code And 16) Then 'here we don't allow modifier keys to do it
Select Case k
Case 100304, 100303, -100304, -100303 'shift up/down
_Continue
Case 100306, 100305, -100306, -100305 'ctrl up/down
_Continue
Case 100308, 100307, -100308, -100307 'alt up/down
_Continue
End Select
End If
End If
If d <> Date$ Then d = Date$: t = t - 86400 'adjust for midnight by subtracting a day from the counter
If time <> 0 And Timer > t Then Exit Do
If k <> 0 Then Exit Do
Loop
End Sub

Function Format$ (num As _Float, using$)
Static tempimage As Long
Dim As Long d, s, i, p
Dim As String text
If tempimage = 0 Then tempimage = _NewImage(80, 1, 0)
d = _Dest: s = _Source
_Dest tempimage: _Source tempimage
Cls
Print Using using$; num;
For i = 1 To 80
p = Screen(1, i)
If p = 0 Then Exit For
text$ = text$ + Chr$(p)
Next
_Dest d: _Source s
Format$ = text$
End Function

Function SwapEnd~&& (num As _Unsigned _Integer64, biteSize As Integer)
'One command to swap endianness for int64, long, and integer type variables. Supply the value and the bite size.
Dim temp As _Unsigned _Integer64, temp1 As _Unsigned Long, temp2 As _Unsigned Integer
Select Case biteSize
Case 8 'integer64
temp = _ShL(num And &HFF&&, 56) 'byte #1
temp = temp Or _ShL(num And &HFF00&&, 40) '2
temp = temp Or _ShL(num And &HFF0000&&, 24) '3
temp = temp Or _ShL(num And &HFF000000&&, 8) '4
temp = temp Or _ShR(num And &HFF00000000&&, 8) '5
temp = temp Or _ShR(num And &HFF0000000000&&, 24) '6
temp = temp Or _ShR(num And &HFF000000000000&&, 40) '7
temp = temp Or _ShR(num And &HFF00000000000000&&, 56) '8
SwapEnd = temp
Case 4 'long
temp1 = _ShL(num And &HFF~&, 24)
temp1 = temp1 Or _ShL(num And &HFF00~&, 8)
temp1 = temp1 Or _ShR(num And &HFF0000~&, 8)
temp1 = temp1 Or _ShR(num And &HFF000000~&, 24)
SwapEnd = temp1
Case 2 'integer
temp2 = temp2 Or _ShL(num And &HFF~%, 8) '1
temp2 = temp2 Or _ShR(num And &HFF00~%, 8) '2
SwapEnd = temp2
End Select
End Function

Function Convert.HBO$ (in As String) 'Convert Hex, Binary, Oct to Decimal values inside a string
'Note that this converts all the hex/binary/octal values inside a whole string.
'It doesn't stop at just the first instance to convert
Dim As String temp, vc, m, t
Dim As Long finished, Cpos, EndPos
Dim ub As _Unsigned _Bit, b As _Bit
Dim ubyte As _Unsigned _Byte, byte As _Byte
Dim ui As _Unsigned Integer, i As Integer
Dim ul As _Unsigned Long, l As Long
Dim ui64 As _Unsigned _Integer64, i64 As _Integer64


temp = _Trim$(UCase$(in))
Do
finished = -1
Cpos = String.Find(temp, "&H", 1)
If Cpos Then '&H located
EndPos = 2: finished = 0
vc = "01234567889ABCDEF": GoSub endposition 'get the hex characters
GoSub typesymbol
temp = Left$(temp, Cpos - 1) + " " + m + Mid$(temp, Cpos + EndPos)
End If
Cpos = String.Find(temp, "&B", 1)
If Cpos Then '&B located
EndPos = 2: finished = 0
vc = "01": GoSub endposition 'get the binary characters
GoSub typesymbol
temp = Left$(temp, Cpos - 1) + " " + m + Mid$(temp, Cpos + EndPos)
End If
Cpos = String.Find(temp, "&O", 1)
If Cpos Then '&O located
EndPos = 2: finished = 0
vc = "01234567": GoSub endposition 'get the octal characters
GoSub typesymbol
temp = Left$(temp, Cpos - 1) + " " + m + Mid$(temp, Cpos + EndPos)
End If
Loop Until finished
Convert.HBO = temp
Exit Function

endposition:
Do
m = Mid$(temp, Cpos + EndPos, 1)
If m = "" Then Exit Do
If InStr(vc, m) Then EndPos = EndPos + 1 Else Exit Do
Loop
Return

typesymbol:
Dim datatype As Long
t = Left$(Mid$(temp, Cpos + EndPos, 3) + " ", 3)
m = Mid$(temp, Cpos, EndPos)
If Left$(t, 1) = "~" Then 'unsigned
t = Mid$(t, 2) 'unsigned + 2 characters to the right for identification
Select Case Left$(t, 1)
Case "`": ub = Val(m): m = _ToStr$(ub): EndPos = EndPos + 2 'bit
Case "%" 'integer or byte
Select Case Right$(t, 1)
Case "%": ubyte = Val(m): m = _ToStr$(ubyte): EndPos = EndPos + 3 'byte
Case Else: ui = Val(m): m = _ToStr$(ui): EndPos = EndPos + 2 'integer
End Select
Case "&" 'long or integer64
Select Case Right$(t, 1)
Case "&": ui64 = Val(m): m = _ToStr$(ui64): EndPos = EndPos + 3 'integer64
Case Else: ul = Val(m): m = _ToStr$(ul): EndPos = EndPos + 2 'long
End Select
End Select
Else
t = Left$(t, 2)
Select Case Left$(t, 1)
Case "`": b = Val(m): m = _ToStr$(b): EndPos = EndPos + 1 'bit
Case "%" 'integer or byte
Select Case Right$(t, 1)
Case "%": byte = Val(m): m = _ToStr$(byte): EndPos = EndPos + 2 'integer
Case Else: i = Val(m): m = _ToStr$(i): EndPos = EndPos + 1 'byte
End Select
Case "&" 'long or integer64
Select Case Right$(t, 1)
Case "&": i64 = Val(m): m = _ToStr$(i64): EndPos = EndPos + 2 'integer64
Case Else: l = Val(m): m = _ToStr$(l): EndPos = EndPos + 1 'long
End Select
Case Else
Select Case Len(m)
Case Is <= 6: i = Val(m): m = _ToStr$(i)
Case Is <= 10: l = Val(m): m = _ToStr$(l)
Case Else: i64 = Val(m): m = _ToStr$(i64)
End Select
End Select
End If
Return
End Function

Function String.Find& (Content As String, Search As String, CountTo As Long)
'If CountTo is 0, this routine will count the number of instances of the search term inside the content string
'If CountTo is >0, this routine will find the position of that instance, if it exists, inside the search string.
'For example, CountTo = 2, it'll find the location of the 2nd instance of the search term, skipping the first.
If CountTo < 0 Then Exit Function 'Can't find a negative position.
Dim As Long p, l, count
If Search$ = "" Then Exit Function
p = InStr(Content$, Search$)
l = Len(Search$)
Do While p& > 0
count = count + 1
If CountTo = count Then String.Find = p: Exit Function
p = InStr(p + l, Content$, Search$)
Loop
If CountTo = 0 Then String.Find = count
End Function

Function String.Replace$ (content$, from$, to$, position As Long)
Dim found As Long: found = String.Find(content$, from$, position)
If found Then String.Replace = Left$(content$, found - 1) + to$ + Mid$(content$, found + Len(from$))
End Function

Function String.Replace.All$ (content$, from$, to$)
'Inspired by the forum post here: https://qb64phoenix.com/forum/showthread...9#pid33559
'Original credit goes to mdijkens as I just tweaked it a little to make it a bit more library friendly
$Checking:Off
Dim As Long mp, pp, found, flen, tlen, p
Dim m As _MEM
Dim As String content2
found = String.Find(content$, from$, 0)
flen = Len(from$): tlen = Len(to$)

m = _MemNew(Len(content$) + (tlen& - flen&) * found): mp = 0: pp = 1
p = InStr(content$, from$)
Do While p > 0
_MemPut m, m.OFFSET + mp, Mid$(content$, pp, p& - pp): mp = mp + p& - pp
_MemPut m, m.OFFSET + mp, to$: mp = mp + tlen&: pp = p& + flen&
p& = InStr(p + flen&, content$, from$)
Loop
_MemPut m, m.OFFSET + mp, Mid$(content$, pp): mp = mp + Len(Mid$(content$, pp))
content2$ = Space$(mp): _MemGet m, m.OFFSET, content2$: _MemFree m
String.Replace.All$ = content2$
$Checking:On
End Function

Function Color.Find& (targetColor As _Unsigned Long, Pal() As _Unsigned Long)
Dim As Long tr, tg, tb, colors, bestdist
Dim As Long bestIndex, dr, dg, db, i, dist
Dim As _Unsigned Long c

tr = _Red32(targetColor): tg = _Green32(targetColor): tb = _Blue32(targetColor):
colors = UBound(Pal): bestdist = _LONG_MAX

$Checking:Off
While i < colors
c = Pal(i)
dr = tr - _Red32(c)
dg = tg - _Green32(c)
db = tb - _Blue32(c)
dist = dr * dr + dg * dg + db * db
If dist < bestdist Then
If dist = 0 Then Color.Find& = i: Exit Function
bestdist = dist: bestIndex = i
End If
i = i + 1
Wend
$Checking:On
Color.Find& = bestIndex
End Function

Sub MemSort (m As _MEM)
Dim i As _Unsigned Long
Dim As Long DataType, i1, gap, swapped
$If 64BIT Then
Dim ES As _Integer64, EC As _Integer64
$Else
DIM ES AS LONG, EC AS LONG
$End If

If Not m.TYPE And 65536 Then Exit Sub 'We won't work without an array
If m.TYPE And 1024 Then DataType = 10
If m.TYPE And 1 Then DataType = DataType + 1
If m.TYPE And 2 Then DataType = DataType + 2
If m.TYPE And 4 Then If m.TYPE And 128 Then DataType = DataType + 4 Else DataType = 3
If m.TYPE And 8 Then If m.TYPE And 128 Then DataType = DataType + 8 Else DataType = 5
If m.TYPE And 32 Then DataType = 6
If m.TYPE And 512 Then DataType = 7

'Convert our offset data over to something we can work with
Dim m1 As _MEM: m1 = _MemNew(Len(ES))
_MemPut m1, m1.OFFSET, m.ELEMENTSIZE: _MemGet m1, m1.OFFSET, ES 'Element Size
_MemPut m1, m1.OFFSET, m.SIZE: _MemGet m1, m1.OFFSET, EC 'Element Count will temporily hold the WHOLE array size
_MemFree m1

EC = EC / ES - 1 'Now we take the whole element size / the size of the elements and get our actual element count. We subtract 1 so our arrays start at 0 and not 1.
'And work with it!
Dim o As _Offset, o1 As _Offset, counter As _Unsigned Long

Select Case DataType
Case 1 'BYTE
Dim temp1(-128 To 127) As _Unsigned Long
Dim t1 As _Byte
i = 0
Do
_MemGet m, m.OFFSET + i, t1
temp1(t1) = temp1(t1) + 1
i = i + 1
Loop Until i > EC
i1 = -128
Do
Do Until temp1(i1) = 0
_MemPut m, m.OFFSET + counter, i1 As _Byte
counter = counter + 1
temp1(i1) = temp1(i1) - 1
If counter > EC Then Exit Sub
Loop
i1 = i1 + 1
Loop Until i1 > 127
Case 2: 'INTEGER
Dim temp2(-32768 To 32767) As _Unsigned Long
Dim t2 As Integer
i = 0
Do
_MemGet m, m.OFFSET + i * 2, t2
temp2(t2) = temp2(t2) + 1
i = i + 1
Loop Until i > EC
i1 = -32768
Do
Do Until temp2(i1) = 0
_MemPut m, m.OFFSET + counter * 2, i1 As Integer
counter = counter + 1
temp2(i1) = temp2(i1) - 1
If counter > EC Then Exit Sub
Loop
i1 = i1 + 1
Loop Until i1 > 32767
Case 3 'SINGLE
Dim T3a As Single, T3b As Single
gap = EC
Do
gap = 10 * gap \ 13
If gap < 1 Then gap = 1
i = 0
swapped = 0
Do
o = m.OFFSET + i * 4
o1 = m.OFFSET + (i + gap) * 4
If _MemGet(m, o, Single) > _MemGet(m, o1, Single) Then
_MemGet m, o1, T3a
_MemGet m, o, T3b
_MemPut m, o1, T3b
_MemPut m, o, T3a
swapped = -1
End If
i = i + 1
Loop Until i + gap > EC
Loop Until gap = 1 And swapped = 0
Case 4 'LONG
Dim T4a As Long, T4b As Long
gap = EC
Do
gap = 10 * gap \ 13
If gap < 1 Then gap = 1
i = 0
swapped = 0
Do
o = m.OFFSET + i * 4
o1 = m.OFFSET + (i + gap) * 4
If _MemGet(m, o, Long) > _MemGet(m, o1, Long) Then
_MemGet m, o1, T4a
_MemGet m, o, T4b
_MemPut m, o1, T4b
_MemPut m, o, T4a
swapped = -1
End If
i = i + 1
Loop Until i + gap > EC
Loop Until gap = 1 And swapped = 0
Case 5 'DOUBLE
Dim T5a As Double, T5b As Double
gap = EC
Do
gap = 10 * gap \ 13
If gap < 1 Then gap = 1
i = 0
swapped = 0
Do
o = m.OFFSET + i * 8
o1 = m.OFFSET + (i + gap) * 8
If _MemGet(m, o, Double) > _MemGet(m, o1, Double) Then
_MemGet m, o1, T5a
_MemGet m, o, T5b
_MemPut m, o1, T5b
_MemPut m, o, T5a
swapped = -1
End If
i = i + 1
Loop Until i + gap > EC
Loop Until gap = 1 And swapped = 0
Case 6 ' _FLOAT
Dim T6a As _Float, T6b As _Float
gap = EC
Do
gap = 10 * gap \ 13
If gap < 1 Then gap = 1
i = 0
swapped = 0
Do
o = m.OFFSET + i * 32
o1 = m.OFFSET + (i + gap) * 32
If _MemGet(m, o, _Float) > _MemGet(m, o1, _Float) Then
_MemGet m, o1, T6a
_MemGet m, o, T6b
_MemPut m, o1, T6b
_MemPut m, o, T6a
swapped = -1
End If
i = i + 1
Loop Until i + gap > EC
Loop Until gap = 1 And swapped = 0
Case 7 'String
Dim T7a As String, T7b As String, T7c As String
T7a = Space$(ES): T7b = Space$(ES): T7c = Space$(ES)
gap = EC
Do
gap = Int(gap / 1.247330950103979)
If gap < 1 Then gap = 1
i = 0
swapped = 0
Do
o = m.OFFSET + i * ES
o1 = m.OFFSET + (i + gap) * ES
_MemGet m, o, T7a
_MemGet m, o1, T7b
If T7a > T7b Then
T7c = T7b
_MemPut m, o1, T7a
_MemPut m, o, T7c
swapped = -1
End If
i = i + 1
Loop Until i + gap > EC
Loop Until gap = 1 And swapped = 0
Case 8 '_INTEGER64
Dim T8a As _Integer64, T8b As _Integer64
gap = EC
Do
gap = 10 * gap \ 13
If gap < 1 Then gap = 1
i = 0
swapped = 0
Do
o = m.OFFSET + i * 8
o1 = m.OFFSET + (i + gap) * 8
If _MemGet(m, o, _Integer64) > _MemGet(m, o1, _Integer64) Then
_MemGet m, o1, T8a
_MemGet m, o, T8b
_MemPut m, o1, T8b
_MemPut m, o, T8a
swapped = -1
End If
i = i + 1
Loop Until i + gap > EC
Loop Until gap = 1 And swapped = 0
Case 11: '_UNSIGNED _BYTE
Dim temp11(0 To 255) As _Unsigned Long
Dim t11 As _Unsigned _Byte
i = 0
Do
_MemGet m, m.OFFSET + i, t11
temp11(t11) = temp11(t11) + 1
i = i + 1
Loop Until i > EC
i1 = 0
Do
Do Until temp11(i1) = 0
_MemPut m, m.OFFSET + counter, i1 As _Unsigned _Byte
counter = counter + 1
temp11(i1) = temp11(i1) - 1
If counter > EC Then Exit Sub
Loop
i1 = i1 + 1
Loop Until i1 > 255
Case 12 '_UNSIGNED INTEGER
Dim temp12(0 To 65535) As _Unsigned Long
Dim t12 As _Unsigned Integer
i = 0
Do
_MemGet m, m.OFFSET + i * 2, t12
temp12(t12) = temp12(t12) + 1
i = i + 1
Loop Until i > EC
i1 = 0
Do
Do Until temp12(i1) = 0
_MemPut m, m.OFFSET + counter * 2, i1 As _Unsigned Integer
counter = counter + 1
temp12(i1) = temp12(i1) - 1
If counter > EC Then Exit Sub
Loop
i1 = i1 + 1
Loop Until i1 > 65535
Case 14 '_UNSIGNED LONG
Dim T14a As _Unsigned Long, T14b As _Unsigned Long
gap = EC
Do
gap = 10 * gap \ 13
If gap < 1 Then gap = 1
i = 0
swapped = 0
Do
o = m.OFFSET + i * 4
o1 = m.OFFSET + (i + gap) * 4
If _MemGet(m, o, _Unsigned Long) > _MemGet(m, o1, _Unsigned Long) Then
_MemGet m, o1, T14a
_MemGet m, o, T14b
_MemPut m, o1, T14b
_MemPut m, o, T14a
swapped = -1
End If
i = i + 1
Loop Until i + gap > EC
Loop Until gap = 1 And swapped = 0
Case 18: '_UNSIGNED _INTEGER64
Dim T18a As _Unsigned _Integer64, T18b As _Unsigned _Integer64
gap = EC
Do
gap = 10 * gap \ 13
If gap < 1 Then gap = 1
i = 0
swapped = 0
Do
o = m.OFFSET + i * 8
o1 = m.OFFSET + (i + gap) * 8
If _MemGet(m, o, _Unsigned _Integer64) > _MemGet(m, o1, _Unsigned _Integer64) Then
_MemGet m, o1, T18a
_MemGet m, o, T18b
_MemPut m, o1, T18b
_MemPut m, o, T18a
swapped = -1
End If
i = i + 1
Loop Until i + gap > EC
Loop Until gap = 1 And swapped = 0
End Select
End Sub

The above will generate, sort, and display a list of all the fonts which is installed on an user's Windows PC.  This gives you both the font name and style (such as "Courier New Bold"), as well as the filename ("courbd.ttf", in this case).

(Code updated to the latest version in this thread, which should have fixes for terminal vs console, and also for too small of a console/terminal size.)
Reply
#2
Very useful! Thank you.

Update: Whoops, didn't work for me (Windows 7 Pro 64bit). I attached the temp file that was created below.


Attached Files
.txt   temp.txt (Size: 411.58 KB / Downloads: 88)
New to QB64pe? Visit the QB64 tutorial to get started.
QB64 Tutorial
Reply
#3
Looks like you're getting wide text characters.  Give this version a quick try:

Code: (Select All)
Type Font_Name_Type
    Name As String
    FileName As String
End Type
ReDim Shared Fonts(10000) As Font_Name_Type

Screen _NewImage(1280, 720, 32)
GetFontList

For i = 0 To UBound(Fonts)
    Print Fonts(i).Name, Fonts(i).FileName
Next

Sub GetFontList
    Shell _Hide "Powershell Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts'|Out-File -Encoding Ascii 'temp_fontlist.txt'"
    f = FreeFile
    Open "temp_fontlist.txt" For Binary As #f
    Do Until EOF(1)
        Line Input #1, temp$
        sep = InStr(temp$, ":")
        l$ = _Trim$(Left$(temp$, sep - 1))
        r$ = _Trim$(Mid$(temp$, sep + 1))
        If l$ <> "PSPath" Then
            Fonts(count).Name = l$
            Fonts(count).FileName = r$
            count = count + 1
        Else
            count = count - 1
            Exit Do
        End If
    Loop
    Close f
    Kill "temp_fontlist.txt"
    ReDim _Preserve Fonts(count) As Font_Name_Type

    'a quick and simple combsort to make certain our list is in alphabetical order

    gap = count
    Do
        gap = 10 * gap \ 13
        If gap < 1 Then gap = 1
        i = 0
        swapped = 0
        Do
            If Fonts(i).Name > Fonts(i + gap).Name Then
                Swap Fonts(i).Name, Fonts(i + gap).Name
                Swap Fonts(i).FileName, Fonts(i + gap).FileName
                swapped = -1
            End If
            i = i + 1
        Loop Until i + gap > count
    Loop Until gap = 1 And swapped = 0
End Sub

To give an idea of what the output should look like, it should resemble something similar to this:

Code: (Select All)
Arial (TrueType)                                                      : arial.ttf
Arial Black (TrueType)                                                : ariblk.ttf
Arial Bold (TrueType)                                                : arialbd.ttf
Arial Bold Italic (TrueType)                                          : arialbi.ttf
Arial Italic (TrueType)                                              : ariali.ttf
Bahnschrift (TrueType)                                                : bahnschrift.ttf
Calibri (TrueType)                                                    : calibri.ttf
Calibri Bold (TrueType)                                              : calibrib.ttf
Calibri Bold Italic (TrueType)                                        : calibriz.ttf
Calibri Italic (TrueType)                                            : calibrii.ttf
Calibri Light (TrueType)                                              : calibril.ttf
Calibri Light Italic (TrueType)                                      : calibrili.ttf
Cambria & Cambria Math (TrueType)                                    : cambria.ttc
Cambria Bold (TrueType)                                              : cambriab.ttf
Cambria Bold Italic (TrueType)                                        : cambriaz.ttf
Cambria Italic (TrueType)                                            : cambriai.ttf
Candara (TrueType)                                                    : candara.ttf
Candara Bold (TrueType)                                              : candarab.ttf
Candara Bold Italic (TrueType)                                        : candaraz.ttf
Candara Italic (TrueType)                                            : candarai.ttf
Candara Light (TrueType)                                              : candaral.ttf
Candara Light Italic (TrueType)                                      : candarali.ttf
Comic Sans MS (TrueType)                                              : comic.ttf
Comic Sans MS Bold (TrueType)                                        : comicbd.ttf
Comic Sans MS Bold Italic (TrueType)                                  : comicz.ttf
Comic Sans MS Italic (TrueType)                                      : comici.ttf
Consolas (TrueType)                                                  : consola.ttf
Consolas Bold (TrueType)                                              : consolab.ttf
Consolas Bold Italic (TrueType)                                      : consolaz.ttf
Consolas Italic (TrueType)                                            : consolai.ttf
Constantia (TrueType)                                                : constan.ttf
Constantia Bold (TrueType)                                            : constanb.ttf
Constantia Bold Italic (TrueType)                                    : constanz.ttf
Constantia Italic (TrueType)                                          : constani.ttf
Corbel (TrueType)                                                    : corbel.ttf
Corbel Bold (TrueType)                                                : corbelb.ttf
Corbel Bold Italic (TrueType)                                        : corbelz.ttf
Corbel Italic (TrueType)                                              : corbeli.ttf
Corbel Light (TrueType)                                              : corbell.ttf
Corbel Light Italic (TrueType)                                        : corbelli.ttf
Courier New (TrueType)                                                : cour.ttf
Courier New Bold (TrueType)                                          : courbd.ttf
Courier New Bold Italic (TrueType)                                    : courbi.ttf
Courier New Italic (TrueType)                                        : couri.ttf
Ebrima (TrueType)                                                    : ebrima.ttf
Ebrima Bold (TrueType)                                                : ebrimabd.ttf
Franklin Gothic Medium (TrueType)                                    : framd.ttf
Franklin Gothic Medium Italic (TrueType)                              : framdit.ttf
Gabriola (TrueType)                                                  : Gabriola.ttf
Gadugi (TrueType)                                                    : gadugi.ttf
Gadugi Bold (TrueType)                                                : gadugib.ttf
Georgia (TrueType)                                                    : georgia.ttf
Georgia Bold (TrueType)                                              : georgiab.ttf
Georgia Bold Italic (TrueType)                                        : georgiaz.ttf
Georgia Italic (TrueType)                                            : georgiai.ttf
Holo MDL2 Assets (TrueType)                                          : holomdl2.ttf
Impact (TrueType)                                                    : impact.ttf
Ink Free (TrueType)                                                  : Inkfree.ttf
Javanese Text (TrueType)                                              : javatext.ttf
Leelawadee UI (TrueType)                                              : leelawui.ttf
Leelawadee UI Bold (TrueType)                                        : leelauib.ttf
Leelawadee UI Semilight (TrueType)                                    : leeluisl.ttf
Lucida Console (TrueType)                                            : lucon.TTF
Lucida Sans Unicode (TrueType)                                        : l_10646.ttf
Malgun Gothic (TrueType)                                              : malgun.ttf
Malgun Gothic Bold (TrueType)                                        : malgunbd.ttf
Malgun Gothic SemiLight (TrueType)                                    : malgunsl.ttf
Microsoft Himalaya (TrueType)                                        : himalaya.ttf
Microsoft JhengHei & Microsoft JhengHei UI (TrueType)                : msjh.ttc
Microsoft JhengHei Bold & Microsoft JhengHei UI Bold (TrueType)      : msjhbd.ttc
Microsoft JhengHei Light & Microsoft JhengHei UI Light (TrueType)    : msjhl.ttc
Microsoft New Tai Lue (TrueType)                                      : ntailu.ttf
Microsoft New Tai Lue Bold (TrueType)                                : ntailub.ttf
Microsoft PhagsPa (TrueType)                                          : phagspa.ttf
Microsoft PhagsPa Bold (TrueType)                                    : phagspab.ttf
Microsoft Sans Serif (TrueType)                                      : micross.ttf
Microsoft Tai Le (TrueType)                                          : taile.ttf
Microsoft Tai Le Bold (TrueType)                                      : taileb.ttf
Microsoft YaHei & Microsoft YaHei UI (TrueType)                      : msyh.ttc
Microsoft YaHei Bold & Microsoft YaHei UI Bold (TrueType)            : msyhbd.ttc
Microsoft YaHei Light & Microsoft YaHei UI Light (TrueType)          : msyhl.ttc
Microsoft Yi Baiti (TrueType)                                        : msyi.ttf
MingLiU-ExtB & PMingLiU-ExtB & MingLiU_HKSCS-ExtB (TrueType)          : mingliub.ttc
Modern (All res)                                                      : modern.fon
Mongolian Baiti (TrueType)                                            : monbaiti.ttf
MS Gothic & MS UI Gothic & MS PGothic (TrueType)                      : msgothic.ttc
MV Boli (TrueType)                                                    : mvboli.ttf
Myanmar Text (TrueType)                                              : mmrtext.ttf
Myanmar Text Bold (TrueType)                                          : mmrtextb.ttf
Nirmala UI (TrueType)                                                : Nirmala.ttf
Nirmala UI Bold (TrueType)                                            : NirmalaB.ttf
Nirmala UI Semilight (TrueType)                                      : NirmalaS.ttf
Palatino Linotype (TrueType)                                          : pala.ttf
Palatino Linotype Bold (TrueType)                                    : palab.ttf
Palatino Linotype Bold Italic (TrueType)                              : palabi.ttf
Palatino Linotype Italic (TrueType)                                  : palai.ttf
Roman (All res)                                                      : roman.fon
Sans Serif Collection (TrueType)                                      : SansSerifCollection.ttf
Script (All res)                                                      : script.fon
Segoe Fluent Icons (TrueType)                                        : SegoeIcons.ttf
Segoe MDL2 Assets (TrueType)                                          : segmdl2.ttf
Segoe Print (TrueType)                                                : segoepr.ttf
Segoe Print Bold (TrueType)                                          : segoeprb.ttf
Segoe Script (TrueType)                                              : segoesc.ttf
Segoe Script Bold (TrueType)                                          : segoescb.ttf
Segoe UI (TrueType)                                                  : segoeui.ttf
Segoe UI Black (TrueType)                                            : seguibl.ttf
Segoe UI Black Italic (TrueType)                                      : seguibli.ttf
Segoe UI Bold (TrueType)                                              : segoeuib.ttf
Segoe UI Bold Italic (TrueType)                                      : segoeuiz.ttf
Segoe UI Emoji (TrueType)                                            : seguiemj.ttf
Segoe UI Historic (TrueType)                                          : seguihis.ttf
Segoe UI Italic (TrueType)                                            : segoeuii.ttf
Segoe UI Light (TrueType)                                            : segoeuil.ttf
Segoe UI Light Italic (TrueType)                                      : seguili.ttf
Segoe UI Semibold (TrueType)                                          : seguisb.ttf
Segoe UI Semibold Italic (TrueType)                                  : seguisbi.ttf
Segoe UI Semilight (TrueType)                                        : segoeuisl.ttf
Segoe UI Semilight Italic (TrueType)                                  : seguisli.ttf
Segoe UI Symbol (TrueType)                                            : seguisym.ttf
Segoe UI Variable (TrueType)                                          : SegUIVar.ttf
SimSun & NSimSun (TrueType)                                          : simsun.ttc
SimSun-ExtB (TrueType)                                                : simsunb.ttf
Sitka Text (TrueType)                                                : SitkaVF.ttf
Sitka Text Italic (TrueType)                                          : SitkaVF-Italic.ttf
Sylfaen (TrueType)                                                    : sylfaen.ttf
Symbol (TrueType)                                                    : symbol.ttf
Tahoma (TrueType)                                                    : tahoma.ttf
Tahoma Bold (TrueType)                                                : tahomabd.ttf
Times New Roman (TrueType)                                            : times.ttf
Times New Roman Bold (TrueType)                                      : timesbd.ttf
Times New Roman Bold Italic (TrueType)                                : timesbi.ttf
Times New Roman Italic (TrueType)                                    : timesi.ttf
Trebuchet MS (TrueType)                                              : trebuc.ttf
Trebuchet MS Bold (TrueType)                                          : trebucbd.ttf
Trebuchet MS Bold Italic (TrueType)                                  : trebucbi.ttf
Trebuchet MS Italic (TrueType)                                        : trebucit.ttf
Verdana (TrueType)                                                    : verdana.ttf
Verdana Bold (TrueType)                                              : verdanab.ttf
Verdana Bold Italic (TrueType)                                        : verdanaz.ttf
Verdana Italic (TrueType)                                            : verdanai.ttf
Webdings (TrueType)                                                  : webdings.ttf
Wingdings (TrueType)                                                  : wingding.ttf
Yu Gothic Bold & Yu Gothic UI Semibold & Yu Gothic UI Bold (TrueType) : YuGothB.ttc
Yu Gothic Light & Yu Gothic UI Light (TrueType)                      : YuGothL.ttc
Yu Gothic Medium & Yu Gothic UI Regular (TrueType)                    : YuGothM.ttc
Yu Gothic Regular & Yu Gothic UI Semilight (TrueType)                : YuGothR.ttc
Cascadia Code Regular (TrueType)                                      : CascadiaCode.ttf
Cascadia Mono Regular (TrueType)                                      : CascadiaMono.ttf
Agency FB Bold (TrueType)                                            : AGENCYB.TTF
Agency FB (TrueType)                                                  : AGENCYR.TTF
Algerian (TrueType)                                                  : ALGER.TTF
Book Antiqua Bold (TrueType)                                          : ANTQUAB.TTF
Book Antiqua Bold Italic (TrueType)                                  : ANTQUABI.TTF
Book Antiqua Italic (TrueType)                                        : ANTQUAI.TTF
Arial Narrow (TrueType)                                              : ARIALN.TTF
Arial Narrow Bold (TrueType)                                          : ARIALNB.TTF
Arial Narrow Bold Italic (TrueType)                                  : ARIALNBI.TTF
Arial Narrow Italic (TrueType)                                        : ARIALNI.TTF
Arial Rounded MT Bold (TrueType)                                      : ARLRDBD.TTF
Baskerville Old Face (TrueType)                                      : BASKVILL.TTF
Bauhaus 93 (TrueType)                                                : BAUHS93.TTF
Bell MT (TrueType)                                                    : BELL.TTF
Bell MT Bold (TrueType)                                              : BELLB.TTF
Bell MT Italic (TrueType)                                            : BELLI.TTF
Bernard MT Condensed (TrueType)                                      : BERNHC.TTF
Book Antiqua (TrueType)                                              : BKANT.TTF
Bodoni MT Bold (TrueType)                                            : BOD_B.TTF
Bodoni MT Bold Italic (TrueType)                                      : BOD_BI.TTF
Bodoni MT Black Italic (TrueType)                                    : BOD_BLAI.TTF
Bodoni MT Black (TrueType)                                            : BOD_BLAR.TTF
Bodoni MT Condensed Bold (TrueType)                                  : BOD_CB.TTF
Bodoni MT Condensed Bold Italic (TrueType)                            : BOD_CBI.TTF
Bodoni MT Condensed Italic (TrueType)                                : BOD_CI.TTF
Bodoni MT Condensed (TrueType)                                        : BOD_CR.TTF
Bodoni MT Italic (TrueType)                                          : BOD_I.TTF
Bodoni MT Poster Compressed (TrueType)                                : BOD_PSTC.TTF
Bodoni MT (TrueType)                                                  : BOD_R.TTF
Bookman Old Style (TrueType)                                          : BOOKOS.TTF
Bookman Old Style Bold (TrueType)                                    : BOOKOSB.TTF
Bookman Old Style Bold Italic (TrueType)                              : BOOKOSBI.TTF
Bookman Old Style Italic (TrueType)                                  : BOOKOSI.TTF
Bradley Hand ITC (TrueType)                                          : BRADHITC.TTF
Britannic Bold (TrueType)                                            : BRITANIC.TTF
Berlin Sans FB Bold (TrueType)                                        : BRLNSB.TTF
Berlin Sans FB Demi Bold (TrueType)                                  : BRLNSDB.TTF
Berlin Sans FB (TrueType)                                            : BRLNSR.TTF
Broadway (TrueType)                                                  : BROADW.TTF
Brush Script MT Italic (TrueType)                                    : BRUSHSCI.TTF
Bookshelf Symbol 7 (TrueType)                                        : BSSYM7.TTF
Californian FB Bold (TrueType)                                        : CALIFB.TTF
Californian FB Italic (TrueType)                                      : CALIFI.TTF
Californian FB (TrueType)                                            : CALIFR.TTF
Calisto MT (TrueType)                                                : CALIST.TTF
Calisto MT Bold (TrueType)                                            : CALISTB.TTF
Calisto MT Bold Italic (TrueType)                                    : CALISTBI.TTF
Calisto MT Italic (TrueType)                                          : CALISTI.TTF
Castellar (TrueType)                                                  : CASTELAR.TTF
Century Schoolbook (TrueType)                                        : CENSCBK.TTF
Centaur (TrueType)                                                    : CENTAUR.TTF
Century (TrueType)                                                    : CENTURY.TTF
Chiller (TrueType)                                                    : CHILLER.TTF
Colonna MT (TrueType)                                                : COLONNA.TTF
Cooper Black (TrueType)                                              : COOPBL.TTF
Copperplate Gothic Bold (TrueType)                                    : COPRGTB.TTF
Copperplate Gothic Light (TrueType)                                  : COPRGTL.TTF
Curlz MT (TrueType)                                                  : CURLZ___.TTF
Dubai Bold (TrueType)                                                : DUBAI-BOLD.TTF
Dubai Light (TrueType)                                                : DUBAI-LIGHT.TTF
Dubai Medium (TrueType)                                              : DUBAI-MEDIUM.TTF
Dubai Regular (TrueType)                                              : DUBAI-REGULAR.TTF
Elephant (TrueType)                                                  : ELEPHNT.TTF
Elephant Italic (TrueType)                                            : ELEPHNTI.TTF
Engravers MT (TrueType)                                              : ENGR.TTF
Eras Bold ITC (TrueType)                                              : ERASBD.TTF
Eras Demi ITC (TrueType)                                              : ERASDEMI.TTF
Eras Light ITC (TrueType)                                            : ERASLGHT.TTF
Eras Medium ITC (TrueType)                                            : ERASMD.TTF
Felix Titling (TrueType)                                              : FELIXTI.TTF
Forte (TrueType)                                                      : FORTE.TTF
Franklin Gothic Book (TrueType)                                      : FRABK.TTF
Franklin Gothic Book Italic (TrueType)                                : FRABKIT.TTF
Franklin Gothic Demi (TrueType)                                      : FRADM.TTF
Franklin Gothic Demi Cond (TrueType)                                  : FRADMCN.TTF
Franklin Gothic Demi Italic (TrueType)                                : FRADMIT.TTF
Franklin Gothic Heavy (TrueType)                                      : FRAHV.TTF
Franklin Gothic Heavy Italic (TrueType)                              : FRAHVIT.TTF
Franklin Gothic Medium Cond (TrueType)                                : FRAMDCN.TTF
Freestyle Script (TrueType)                                          : FREESCPT.TTF
French Script MT (TrueType)                                          : FRSCRIPT.TTF
Footlight MT Light (TrueType)                                        : FTLTLT.TTF
Garamond (TrueType)                                                  : GARA.TTF
Garamond Bold (TrueType)                                              : GARABD.TTF
Garamond Italic (TrueType)                                            : GARAIT.TTF
Gigi (TrueType)                                                      : GIGI.TTF
Gill Sans MT Bold Italic (TrueType)                                  : GILBI___.TTF
Gill Sans MT Bold (TrueType)                                          : GILB____.TTF
Gill Sans MT Condensed (TrueType)                                    : GILC____.TTF
Gill Sans MT Italic (TrueType)                                        : GILI____.TTF
Gill Sans Ultra Bold Condensed (TrueType)                            : GILLUBCD.TTF
Gill Sans Ultra Bold (TrueType)                                      : GILSANUB.TTF
Gill Sans MT (TrueType)                                              : GIL_____.TTF
Gloucester MT Extra Condensed (TrueType)                              : GLECB.TTF
Gill Sans MT Ext Condensed Bold (TrueType)                            : GLSNECB.TTF
Century Gothic (TrueType)                                            : GOTHIC.TTF
Century Gothic Bold (TrueType)                                        : GOTHICB.TTF
Century Gothic Bold Italic (TrueType)                                : GOTHICBI.TTF
Century Gothic Italic (TrueType)                                      : GOTHICI.TTF
Goudy Old Style (TrueType)                                            : GOUDOS.TTF
Goudy Old Style Bold (TrueType)                                      : GOUDOSB.TTF
Goudy Old Style Italic (TrueType)                                    : GOUDOSI.TTF
Goudy Stout (TrueType)                                                : GOUDYSTO.TTF
Harlow Solid Italic (TrueType)                                        : HARLOWSI.TTF
Harrington (TrueType)                                                : HARNGTON.TTF
Haettenschweiler (TrueType)                                          : HATTEN.TTF
High Tower Text (TrueType)                                            : HTOWERT.TTF
High Tower Text Italic (TrueType)                                    : HTOWERTI.TTF
Imprint MT Shadow (TrueType)                                          : IMPRISHA.TTF
Informal Roman (TrueType)                                            : INFROMAN.TTF
Blackadder ITC (TrueType)                                            : ITCBLKAD.TTF
Edwardian Script ITC (TrueType)                                      : ITCEDSCR.TTF
Kristen ITC (TrueType)                                                : ITCKRIST.TTF
Jokerman (TrueType)                                                  : JOKERMAN.TTF
Juice ITC (TrueType)                                                  : JUICE___.TTF
Kunstler Script (TrueType)                                            : KUNSTLER.TTF
Wide Latin (TrueType)                                                : LATINWD.TTF
Lucida Bright (TrueType)                                              : LBRITE.TTF
Lucida Bright Demibold (TrueType)                                    : LBRITED.TTF
Lucida Bright Demibold Italic (TrueType)                              : LBRITEDI.TTF
Lucida Bright Italic (TrueType)                                      : LBRITEI.TTF
Lucida Calligraphy Italic (TrueType)                                  : LCALLIG.TTF
Leelawadee (TrueType)                                                : LEELAWAD.TTF
Leelawadee Bold (TrueType)                                            : LEELAWDB.TTF
Lucida Fax Regular (TrueType)                                        : LFAX.TTF
Lucida Fax Demibold (TrueType)                                        : LFAXD.TTF
Lucida Fax Demibold Italic (TrueType)                                : LFAXDI.TTF
Lucida Fax Italic (TrueType)                                          : LFAXI.TTF
Lucida Handwriting Italic (TrueType)                                  : LHANDW.TTF
Lucida Sans Regular (TrueType)                                        : LSANS.TTF
Lucida Sans Demibold Roman (TrueType)                                : LSANSD.TTF
Lucida Sans Demibold Italic (TrueType)                                : LSANSDI.TTF
Lucida Sans Italic (TrueType)                                        : LSANSI.TTF
Lucida Sans Typewriter Regular (TrueType)                            : LTYPE.TTF
Lucida Sans Typewriter Bold (TrueType)                                : LTYPEB.TTF
Lucida Sans Typewriter Bold Oblique (TrueType)                        : LTYPEBO.TTF
Lucida Sans Typewriter Oblique (TrueType)                            : LTYPEO.TTF
Magneto Bold (TrueType)                                              : MAGNETOB.TTF
Maiandra GD (TrueType)                                                : MAIAN.TTF
Matura MT Script Capitals (TrueType)                                  : MATURASC.TTF
Mistral (TrueType)                                                    : MISTRAL.TTF
Modern No. 20 (TrueType)                                              : MOD20.TTF
Microsoft Uighur Bold (TrueType)                                      : MSUIGHUB.TTF
Microsoft Uighur (TrueType)                                          : MSUIGHUR.TTF
Monotype Corsiva (TrueType)                                          : MTCORSVA.TTF
MT Extra (TrueType)                                                  : MTEXTRA.TTF
Niagara Engraved (TrueType)                                          : NIAGENG.TTF
Niagara Solid (TrueType)                                              : NIAGSOL.TTF
OCR A Extended (TrueType)                                            : OCRAEXT.TTF
Old English Text MT (TrueType)                                        : OLDENGL.TTF
Onyx (TrueType)                                                      : ONYX.TTF
MS Outlook (TrueType)                                                : OUTLOOK.TTF
Palace Script MT (TrueType)                                          : PALSCRI.TTF
Papyrus (TrueType)                                                    : PAPYRUS.TTF
Parchment (TrueType)                                                  : PARCHM.TTF
Perpetua Bold Italic (TrueType)                                      : PERBI___.TTF
Perpetua Bold (TrueType)                                              : PERB____.TTF
Perpetua Italic (TrueType)                                            : PERI____.TTF
Perpetua Titling MT Bold (TrueType)                                  : PERTIBD.TTF
Perpetua Titling MT Light (TrueType)                                  : PERTILI.TTF
Perpetua (TrueType)                                                  : PER_____.TTF
Playbill (TrueType)                                                  : PLAYBILL.TTF
Poor Richard (TrueType)                                              : POORICH.TTF
Pristina (TrueType)                                                  : PRISTINA.TTF
Rage Italic (TrueType)                                                : RAGE.TTF
Ravie (TrueType)                                                      : RAVIE.TTF
MS Reference Sans Serif (TrueType)                                    : REFSAN.TTF
MS Reference Specialty (TrueType)                                    : REFSPCL.TTF
Rockwell Condensed Bold (TrueType)                                    : ROCCB___.TTF
Rockwell Condensed (TrueType)                                        : ROCC____.TTF
Rockwell (TrueType)                                                  : ROCK.TTF
Rockwell Bold (TrueType)                                              : ROCKB.TTF
Rockwell Bold Italic (TrueType)                                      : ROCKBI.TTF
Rockwell Extra Bold (TrueType)                                        : ROCKEB.TTF
Rockwell Italic (TrueType)                                            : ROCKI.TTF
Century Schoolbook Bold (TrueType)                                    : SCHLBKB.TTF
Century Schoolbook Bold Italic (TrueType)                            : SCHLBKBI.TTF
Century Schoolbook Italic (TrueType)                                  : SCHLBKI.TTF
Script MT Bold (TrueType)                                            : SCRIPTBL.TTF
Showcard Gothic (TrueType)                                            : SHOWG.TTF
Snap ITC (TrueType)                                                  : SNAP____.TTF
Stencil (TrueType)                                                    : STENCIL.TTF
Tw Cen MT Bold Italic (TrueType)                                      : TCBI____.TTF
Tw Cen MT Bold (TrueType)                                            : TCB_____.TTF
Tw Cen MT Condensed Bold (TrueType)                                  : TCCB____.TTF
Tw Cen MT Condensed Extra Bold (TrueType)                            : TCCEB.TTF
Tw Cen MT Condensed (TrueType)                                        : TCCM____.TTF
Tw Cen MT Italic (TrueType)                                          : TCMI____.TTF
Tw Cen MT (TrueType)                                                  : TCM_____.TTF
Tempus Sans ITC (TrueType)                                            : TEMPSITC.TTF
Viner Hand ITC (TrueType)                                            : VINERITC.TTF
Vivaldi Italic (TrueType)                                            : VIVALDII.TTF
Vladimir Script (TrueType)                                            : VLADIMIR.TTF
Wingdings 2 (TrueType)                                                : WINGDNG2.TTF
Wingdings 3 (TrueType)                                                : WINGDNG3.TTF
PSPath                                                                : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_
                                                                        MACHINE\SOFTWARE\Microsoft\Windows
                                                                        NT\CurrentVersion\Fonts
PSParentPath                                                          : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_
                                                                        MACHINE\SOFTWARE\Microsoft\Windows
                                                                        NT\CurrentVersion
PSChildName                                                          : Fonts
PSDrive                                                              : HKLM
PSProvider                                                            : Microsoft.PowerShell.Core\Registry
Reply
#4
This one does not create the temp_fontlist.txt file on my drive.
New to QB64pe? Visit the QB64 tutorial to get started.
QB64 Tutorial
Reply
#5
A version with a scrollable listing.  Just use arrow keys to scroll up and down.  

Code: (Select All)
Type Font_Name_Type
    Name As String
    FileName As String
End Type
ReDim Shared Fonts(10000) As Font_Name_Type

Screen _NewImage(1280, 720, 32)
GetFontList

numbered = -1 'number our quick list
l = 20 'number to print to the screen
w = 50 'width to print to the screen
Do
    Cls
    _Limit 30
    k = _KeyHit
    Select Case k
        Case 20480: s = s + 1: If s > UBound(Fonts) Then s = UBound(Fonts)
        Case 18432: s = s - 1: If s < 0 Then s = 0
    End Select
    Locate 10
    start = s: finish = s + l - 1
    For i = start To finish
        If numbered Then counter$ = LTrim$(Str$(i)) + ") "
        Locate , 10: Print counter$ + Left$(Fonts(i).Name, w);
        Locate , 70: Print Left$(Fonts(i).FileName, w)
    Next
    _Display
Loop Until k = 27




Sub GetFontList
    Shell _Hide "Powershell Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts'|Out-File -Encoding Ascii 'temp_fontlist.txt'"
    f = FreeFile
    Open "temp_fontlist.txt" For Binary As #f
    Do Until EOF(1)
        Line Input #1, temp$
        sep = InStr(temp$, ":")
        l$ = _Trim$(Left$(temp$, sep - 1))
        r$ = _Trim$(Mid$(temp$, sep + 1))
        If l$ <> "PSPath" Then 'we can stop reading files at this point (according to my tests)
            If l$ <> "" Then 'skip the blank space lines
                Fonts(count).Name = l$
                Fonts(count).FileName = r$
                count = count + 1
            End If
        Else
            count = count - 1
            Exit Do
        End If
    Loop
    Close f
    Kill "temp_fontlist.txt"
    ReDim _Preserve Fonts(count) As Font_Name_Type

    'a quick and simple combsort to make certain our list is in alphabetical order

    gap = count
    Do
        gap = 10 * gap \ 13
        If gap < 1 Then gap = 1
        i = 0
        swapped = 0
        Do
            If Fonts(i).Name > Fonts(i + gap).Name Then
                Swap Fonts(i).Name, Fonts(i + gap).Name
                Swap Fonts(i).FileName, Fonts(i + gap).FileName
                swapped = -1
            End If
            i = i + 1
        Loop Until i + gap > count
    Loop Until gap = 1 And swapped = 0
End Sub

(03-14-2024, 04:54 AM)TerryRitchie Wrote: This one does not create the temp_fontlist.txt file on my drive.

What does this single line do when you run it from a command prompt?

Code: (Select All)
Powershell Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts'|Out-File -Encoding Ascii 'temp_fontlist.txt

This should create the temp_fontlist.txt file for you. If it doesn't, it might be a difference in powershell commands from windows 7 to windows 11? I'll have to dig deeper to see what may have changed with it over the various versions.
Reply
#6
Still not creating the temp file for me. I also get subscript out of range in line 67 (due to no temp file to load from).

(03-14-2024, 05:12 AM)SMcNeill Wrote: What does this single line do when you run it from a command prompt?

Code: (Select All)
Powershell Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts'|Out-File -Encoding Ascii 'temp_fontlist.txt

This should create the temp_fontlist.txt file for you.  If it doesn't, it might be a difference in powershell commands from windows 7 to windows 11?  I'll have to dig deeper to see what may have changed with it over the various versions.
See screen shot below.


Attached Files Thumbnail(s)
   
New to QB64pe? Visit the QB64 tutorial to get started.
QB64 Tutorial
Reply
#7
Last thing I can think of to check, at the moment, is:  Does it have admin priveldges?

I don't know if that'd make a difference, or if this is just a difference between Win 7 powershell and Win 11, or what the heck the issue is.  I was thinking both still used Powershell 5.whatever under the hood.  I didn't think they'd behave different across various windows versions.
Reply
#8
(03-14-2024, 05:32 AM)SMcNeill Wrote: Last thing I can think of to check, at the moment, is:  Does it have admin priveldges?

I don't know if that'd make a difference, or if this is just a difference between Win 7 powershell and Win 11, or what the heck the issue is.  I was thinking both still used Powershell 5.whatever under the hood.  I didn't think they'd behave different across various windows versions.

Yep, it's an admin CMD prompt opened (caption in image above).
New to QB64pe? Visit the QB64 tutorial to get started.
QB64 Tutorial
Reply
#9
@TerryRitchie I think I've got it sorted out -- you're shelling out to command prompt and not terminal.   Give this a run from the command line, like you did above, and see if you still get the error message:

Code: (Select All)
cmd "Powershell Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts'|Out-File -Encoding Ascii 'temp_fontlist.txt'"

   

(You can see the difference in the two methods above with command prompt.  The first tosses the error like you're experiencing.  The second runs with no issues.  Wink )

so the change with the code I've been sharing should be just to make certain to add that "cmd" to the front of that shell statement, as we see above.
Reply
#10
Code: (Select All)
Type Font_Name_Type
Name As String
FileName As String
End Type
ReDim Shared Fonts(10000) As Font_Name_Type

Screen _NewImage(1280, 720, 32)
GetFontList

numbered = -1 'number our quick list
l = 20 'number to print to the screen
w = 50 'width to print to the screen
Do
Cls
_Limit 30
k = _KeyHit
Select Case k
Case 20480: s = s + 1: If s > UBound(Fonts) Then s = UBound(Fonts)
Case 18432: s = s - 1: If s < 0 Then s = 0
End Select
Locate 10
start = s: finish = s + l - 1
For i = start To finish
If numbered Then counter$ = LTrim$(Str$(i)) + ") "
Locate , 10: Print counter$ + Left$(Fonts(i).Name, w);
Locate , 70: Print Left$(Fonts(i).FileName, w)
Next
_Display
Loop Until k = 27




Sub GetFontList
Shell _Hide "Powershell -command " + Chr$(34) + "Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts'|Out-File -Encoding Ascii 'temp_fontlist.txt'" + Chr$(34)
f = FreeFile
Open "temp_fontlist.txt" For Binary As #f
Do Until EOF(1)
Line Input #1, temp$
sep = InStr(temp$, ":")
l$ = _Trim$(Left$(temp$, sep - 1))
r$ = _Trim$(Mid$(temp$, sep + 1))
If l$ <> "PSPath" Then 'we can stop reading files at this point (according to my tests)
If l$ <> "" Then 'skip the blank space lines
Fonts(count).Name = l$
Fonts(count).FileName = r$
count = count + 1
End If
Else
count = count - 1
Exit Do
End If
Loop
Close f
'Kill "temp_fontlist.txt"
ReDim _Preserve Fonts(count) As Font_Name_Type

'a quick and simple combsort to make certain our list is in alphabetical order

gap = count
Do
gap = 10 * gap \ 13
If gap < 1 Then gap = 1
i = 0
swapped = 0
Do
If Fonts(i).Name > Fonts(i + gap).Name Then
Swap Fonts(i).Name, Fonts(i + gap).Name
Swap Fonts(i).FileName, Fonts(i + gap).FileName
swapped = -1
End If
i = i + 1
Loop Until i + gap > count
Loop Until gap = 1 And swapped = 0
End Sub

I'm thinking the above version should work with either command prompt or terminal, with zero issues. Give it a try if you have a chance, and if it works as advertised this time, I'll go in and correct the original post and clean up the other versions from there to here, just to keep it from being confusing for others and hard to understand.

I honestly think, this whole time, the issue was nothing more than shelling out to CMD vs shelling out to Terminal, and the way they try and process the input. Tongue
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  File List and Directory List (as array) SMcNeill 10 1,448 01-23-2026, 04:31 PM
Last Post: hsiangch_ong
  Resizing Program Window and Font SMcNeill 2 527 09-05-2025, 05:55 AM
Last Post: Pete
  Book List to Folders SMcNeill 5 1,520 11-27-2023, 06:51 PM
Last Post: Dimster
  Snapback Windows SMcNeill 3 1,292 10-11-2023, 05:32 PM
Last Post: SMcNeill
  Windows Magnifier SMcNeill 10 2,371 12-28-2022, 12:07 AM
Last Post: SMcNeill

Forum Jump:


Users browsing this thread: