|
Post by Rod on May 2, 2023 14:02:13 GMT -5
How do we determine the default font in use on a users PC? Anyone know any tricks hints or tips?
|
|
|
Post by Walt Decker on May 2, 2023 18:55:23 GMT -5
Get a DC for the desktop then use the GetTextMetrics() function. That should give you the windows default font. It will not give you the font used by other apps running on the pc.
|
|
|
Post by xxgeek on May 3, 2023 10:22:12 GMT -5
After a bit of searching, some tips and tricks at best.
The only way I found to change the default font is to edit the registry. It seems the default font on a win 10 pc is set to "Segoe UI", and when changed the "registry" reflects the change by adding a few entries to, in effect, trick windows into believing the new font is the old "Segoe UI".
The registry "key" to find that is HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontSubstitutes "Segoe UI"
If this key exists it will hold the users\system default font, and will look like this: HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontSubstitutes "Segoe UI" = "some font name"
Since you are familiar with the command line it should be a simple reg query to retrieve the user/system font.
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontSubstitutes" /s /f "Segoe UI"
From what I gather if you get a font in part of the output, that will be the font you are looking for. If you do not get a font in the output, then the font you are looking for would be the the Win 10 default of "Segoe UI".
You will need to use cmd to output the info to a file and have LB read it to get the font name. The output should look similar to this: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontSubstitutes Segoe UI REG_SZ Arial
I changed my own default to Arial, then did as stated above to get this output, so it seems to work.
This line will output the resulting "output" to font.txt from there you can get LB to grab the font name. reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontSubstitutes" /s /f "Segoe UI">>font.txt
Good luck with the rest.
|
|
|
Post by Walt Decker on May 3, 2023 15:06:39 GMT -5
The easiest way to change the pc default font is use the windoz regedit() application. If you want to do it programmatically I have routines in my archives that I think can be adapted to LB.
|
|
|
Post by xxgeek on May 3, 2023 17:15:09 GMT -5
It's easy to change the default font from the command line of regedit, but Rod just wants the name of the default font.
This works for me to obtain my own default font in win 10 pro. It could be adapted to other OS's The pause may be shortened if your pc is fairly fast. Save to it's own folder before running.
q$=chr$(34) open "getfont.cmd" for output as #font #font "reg query ";q$;"HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontSubstitutes";q$;" /s /f ";q$;"Segoe UI";q$;">>info.txt" close #font getfont$ = "getfont.cmd" run getfont$ call pause 1000 open "info.txt" for input as #font while eof(#font) = 0 x=x+1 line input #font, font$ if instr(font$, "Segoe") then exit while wend close #font font$ = word$(font$,4)+" "+word$(font$,5)+" "+word$(font$,6) : font$ = trim$(font$) if font$ <> "" then print "default font = ";font$ else print "default font = Segoe UI" end if kill DefaultDir$;"\info.txt" kill DefaultDir$;"\getfont.cmd" end
'sub to create pauses in program sub pause mil t=time$("ms")+mil while time$("ms")<t scan wend end sub
|
|