Windows: Font name -> font FILE name ?

644 views
Skip to first unread message

Sergy

unread,
Jun 4, 2017, 3:10:26 AM6/4/17
to Harbour Users
Hello friends

I'm exploring now HBHPDF possibilites. Stuck in a dark with question: it needs a "font file" instead of "font name".

How to resolve it correctly? Of course, my first step was a simply hash table:

hList := {"Andale Mono"  => "andalemo.ttf",;
          "Arial"        => "arial.ttf",;
          "Arial Bold"   => "arialbd.ttf",;
          "Arial Italic" => "ariali.ttf",;
          "Calibri"      => "calibri.ttf",;
          "Consolas"     => "consola.ttf",;
          "Courier"      => "cour.ttf"}

But it seems too ugly. Windows has a registry key HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts, where it stores a font file names.

But win_regRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts") returns a NIL.

How I can resolve this ?

Thanks.

Sergy

unread,
Jun 6, 2017, 5:14:32 PM6/6/17
to Harbour Users
I found some VB script which retrives this section of registry to text file:

Set wshShell = WScript.CreateObject("WScript.Shell")
Set wshSysEnv = wshShell.Environment("PROCESS")
sMyFile = "Fontlist.txt"
Dim objFileSystem, objOutputFile
Dim strOutputFile
Set objFileSystem = CreateObject("Scripting.fileSystemObject")
Set objOutputFile = objFileSystem.CreateTextFile(sMyFile, TRUE)
Dim str
Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."

Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\default:StdRegProv")

strKeyPath = "Software\Microsoft\Windows NT\CurrentVersion\Fonts"
objReg.EnumValues HKEY_LOCAL_MACHINE, _
strKeyPath,arrEntryNames,arrEntryZZZ

For Each entry in arrEntryNames
str = wshshell.RegRead("HKLM\Software\Microsoft\Windows NT\CurrentVersion\Fonts\" & entry)
       objOutputFile.WriteLine(entry & "," & str)
Next
objOutputFile.Close
Reply all
Reply to author
Forward
0 new messages