[python-win32] List all fonts filename

Tim Roberts timr at probo.com
Thu Jan 5 15:26:07 EST 2023


Moi15 Moi wrote:
> My goal is to list all the filename of the font installed without 
> listing the file in those 2 folders:
> - C:\Windows\Fonts
> - %userprofile%\AppData\Local\Microsoft\Windows\Fonts
>
> I found a way to do it directwrite: 
> https://gist.github.com/JeremieBergeron/dc04bcb747c94a82a10020a990ba884a
> But, from what I can see, pywin32 doesn't support directwrite api.

It's just COM, which pywin32 does perfectly well.  The advantage of COM 
is that you don't need a custom interface.  Did you look at the pyglet 
code that does this?


> But, I don't know how I get the font path 
> (ex: C:\Users\Admin\AppData\Local\Microsoft\Windows\Fonts\Jester.ttf) 
> with GDI

The easier way would be to read the registry. 
"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" 
is where Windows stores the registered fonts.  The key is the font name, 
the value is the file name.  If there is a file name without a path, it 
defaults to C:\Windows\Fonts.

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3428 bytes
Desc: S/MIME Cryptographic Signature
URL: <https://mail.python.org/pipermail/python-win32/attachments/20230105/4963e49c/attachment.bin>


More information about the python-win32 mailing list