Page 1 of 1

Actual font location and name

Posted: Wed Sep 15, 2021 7:29 pm
by normeus
I can get a font file name by reading the registry, for example "Bahnschrift":

Code: Select all

;https://www.purebasic.fr/english/memberlist.php?mode=viewprofile&u=17681
Procedure.s RegReadString(HKMain, HKSub$, HKEntry$)
  hKey = 0
  If RegOpenKeyEx_(HKMain, HKSub$, 0, #KEY_QUERY_VALUE, @hKey) = #ERROR_SUCCESS
    result$ = Space(260)
    bufLen = Len(result$)
    If hKey
      If RegQueryValueEx_(hKey, HKEntry$, 0, 0, @result$, @bufLen) <> #ERROR_SUCCESS
        result$ = ""
      EndIf
      RegCloseKey_(hKey)
    EndIf
  Else
    result$ = ""
  EndIf
ProcedureReturn result$
EndProcedure
namer$ = "Bahnschrift" + " (TrueType)"
Debug RegReadString(#HKEY_LOCAL_MACHINE,"Software\Microsoft\Windows NT\CurrentVersion\fonts",namer$)

When you select a font using FontRequester() it gives you a font family name like "Bahnschrift Light Condensed". I couldn't find anything on the registry with "Light Condensed". I also tried using GDI retrieving font family using tagLOGFONTW structure, and also GetTextFace_ but they both return the name with qualifiers and I am not able to find a match for the actual font. Any one has any workaround for this or any other ideas and how to get the font file name?

Thank you.
Norm.

Re: Actual font location and name

Posted: Thu Sep 16, 2021 10:35 pm
by JHPJHP
Hi normeus,

I sent you a PM; see this post for additional information.

Example has been added to Windows Services & Other Stuff\Other_Stuff\FontStuff\...

Re: Actual font location and name

Posted: Thu Sep 16, 2021 10:57 pm
by normeus
Thank you! JHPJHP
I really appreciate you taking the time to answer my question.


Thank you.
Norm.

Re: Actual font location and name

Posted: Fri Sep 17, 2021 5:27 pm
by JHPJHP
Hi normeus,

I've added a new example that is a good companion to the other font scripts; see the following post Find Font File.

If you're interested, but do not have an access key, send me a PM and I'll package up the new example with the improved versions of FontStuffFromFile.pb and EnumerateSystemFonts.pb.

Re: Actual font location and name

Posted: Fri Sep 17, 2021 6:35 pm
by normeus
JHPJHP,

I do have an access key. I have not logged in because I haven't had time to program in PureBasic ( no time for fun).
I will check out the new example over the weekend.

Thank you.
Norm.