[python-win32] EnumFontFamilies with EnumFontFamExProc
Moi15 Moi
moi15moismokerlolilol at gmail.com
Tue Mar 7 18:44:43 EST 2023
Hi,
I am trying to use EnumFontFamilies to get the elfFullName
<https://learn.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-enumlogfontw>
value
of each font.
Here is what I have tried:
from typing import Optional
import win32gui
def enum_fonts(family_name: Optional[str]=None):
hwnd = win32gui.GetDesktopWindow()
dc = win32gui.GetWindowDC(hwnd)
res = []
def callback(*args):
print(args[0].elfFullName)
res.append(args)
return 1
win32gui.EnumFontFamilies(dc, family_name, callback)
win32gui.ReleaseDC(hwnd, dc)
return res
for logfont in enum_fonts("Arial"):
print(f"Font name: {logfont[0].lfFaceName}")
print(f"Weight: {logfont[0].lfWeight}")
print(f"Width: {logfont[0].lfWidth}")
print(f"Height: {logfont[0].lfHeight}")
print(f"Italic: {bool(logfont[0].lfItalic)}")
print()
But, it does give me the elfFullName
<https://learn.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-enumlogfontw>
value.
How can I get it?
>From what I understand, I need to use EnumFontFamExProc
<https://learn.microsoft.com/en-us/previous-versions/dd162618(v=vs.85)>,
but I have no idea how to do it.
Thank you
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/pipermail/python-win32/attachments/20230307/58dd58e8/attachment.html>
More information about the python-win32
mailing list