Posts: 2,709
Threads: 328
Joined: Apr 2022
Reputation:
219
03-14-2024, 04:10 AM
(This post was last modified: 03-14-2024, 10:47 PM by SMcNeill .)
Code: (Select All)
Screen _NewImage (800 , 600 , 32 )
'$Console:Only
Type Font_Name_Type
Name As String
FileName As String
End Type
ReDim Shared Fonts(10000 ) As Font_Name_Type
ReDim Shared MonoFonts(10000 ) As Font_Name_Type
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 numbered Then counter$ = LTrim$ (Str$ (i)) + ") "
Locate , 10 : Print counter$ + Left$ (Fonts(i).Name , w);
Locate , 70 : Print Left$ (Fonts(i).FileName, w)
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 _Hide "Powershell -command " + Chr$ (34 ) + "$Host.UI.RawUI.BufferSize = New-Object Management.Automation.Host.Size (200, 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
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.)
Posts: 1,270
Threads: 118
Joined: Apr 2022
Reputation:
100
03-14-2024, 04:33 AM
(This post was last modified: 03-14-2024, 04:38 AM by TerryRitchie .)
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
temp.txt (Size: 411.58 KB / Downloads: 23)
New to QB64pe? Visit the QB64 tutorial to get started.
QB64 Tutorial
Posts: 2,709
Threads: 328
Joined: Apr 2022
Reputation:
219
03-14-2024, 04:47 AM
(This post was last modified: 03-14-2024, 04:49 AM by SMcNeill .)
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
Posts: 1,270
Threads: 118
Joined: Apr 2022
Reputation:
100
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
Posts: 2,709
Threads: 328
Joined: Apr 2022
Reputation:
219
03-14-2024, 05:12 AM
(This post was last modified: 03-14-2024, 05:14 AM by SMcNeill .)
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.
Posts: 1,270
Threads: 118
Joined: Apr 2022
Reputation:
100
03-14-2024, 05:15 AM
(This post was last modified: 03-14-2024, 05:19 AM by TerryRitchie .)
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
Image(s)
New to QB64pe? Visit the QB64 tutorial to get started.
QB64 Tutorial
Posts: 2,709
Threads: 328
Joined: Apr 2022
Reputation:
219
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.
Posts: 1,270
Threads: 118
Joined: Apr 2022
Reputation:
100
(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
Posts: 2,709
Threads: 328
Joined: Apr 2022
Reputation:
219
03-14-2024, 05:51 AM
(This post was last modified: 03-14-2024, 05:56 AM by SMcNeill .)
@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.
)
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.
Posts: 2,709
Threads: 328
Joined: Apr 2022
Reputation:
219
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.