Skip to content

Commit

Permalink
[Windows] Fix x86
Browse files Browse the repository at this point in the history
  • Loading branch information
moi15moi committed Dec 21, 2024
1 parent f212f1d commit 0439168
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion find_system_fonts_filename/windows/dwrite.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,4 +347,4 @@ def __init__(self) -> None:
# https://learn.microsoft.com/en-us/windows/win32/api/dwrite/nf-dwrite-dwritecreatefactory
self.DWriteCreateFactory = dwrite.DWriteCreateFactory
self.DWriteCreateFactory.restype = HRESULT
self.DWriteCreateFactory.argtypes = [wintypes.UINT, GUID, POINTER(POINTER(IUnknown))]
self.DWriteCreateFactory.argtypes = [wintypes.UINT, POINTER(GUID), POINTER(POINTER(IUnknown))]
4 changes: 2 additions & 2 deletions find_system_fonts_filename/windows/gdi32.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ def __init__(self) -> None:
# https://learn.microsoft.com/en-us/previous-versions/dd162618(v=vs.85)
self.ENUMFONTFAMEXPROC = WINFUNCTYPE(
wintypes.INT,
ENUMLOGFONTEXW,
TEXTMETRICW,
POINTER(ENUMLOGFONTEXW),
POINTER(TEXTMETRICW),
wintypes.DWORD,
wintypes.LPARAM,
)
Expand Down
14 changes: 7 additions & 7 deletions find_system_fonts_filename/windows/windows_fonts.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def get_filepath_from_IDWriteFontFace(font_face) -> Set[str]:
return fonts_filename


def enum_fonts_2(logfont: ENUMLOGFONTEXW, text_metric: TEXTMETRICW, font_type: wintypes.DWORD, lparam: wintypes.LPARAM):
def enum_fonts_2(logfont: POINTER(ENUMLOGFONTEXW), text_metric: POINTER(TEXTMETRICW), font_type: wintypes.DWORD, lparam: wintypes.LPARAM):
enum_data: EnumData = py_object.from_address(lparam).value

# It seems that font_type can be 0. In those case, the font format is .fon
Expand All @@ -81,10 +81,10 @@ def enum_fonts_2(logfont: ENUMLOGFONTEXW, text_metric: TEXTMETRICW, font_type: w
# Replace the lfFaceName with the elfFullName.
# See why here: https://github.com/libass/libass/issues/744
lfFaceName = create_unicode_buffer(enum_data.gdi.LF_FACESIZE)
enum_data.msvcrt.wcsncpy_s(lfFaceName, enum_data.gdi.LF_FACESIZE, logfont.elfFullName, enum_data.msvcrt.TRUNCATE)
logfont.elfLogFont.lfFaceName = lfFaceName.value
enum_data.msvcrt.wcsncpy_s(lfFaceName, enum_data.gdi.LF_FACESIZE, logfont.contents.elfFullName, enum_data.msvcrt.TRUNCATE)
logfont.contents.elfLogFont.lfFaceName = lfFaceName.value

hfont = enum_data.gdi.CreateFontIndirectW(byref(logfont.elfLogFont))
hfont = enum_data.gdi.CreateFontIndirectW(byref(logfont.contents.elfLogFont))
enum_data.gdi.SelectObject(enum_data.dc, hfont)

font_face = POINTER(IDWriteFontFace)()
Expand All @@ -96,9 +96,9 @@ def enum_fonts_2(logfont: ENUMLOGFONTEXW, text_metric: TEXTMETRICW, font_type: w
return True


def enum_fonts_1(logfont: ENUMLOGFONTEXW, text_metric: TEXTMETRICW, font_type: wintypes.DWORD, lparam: wintypes.LPARAM):
def enum_fonts_1(logfont: POINTER(ENUMLOGFONTEXW), text_metric: POINTER(TEXTMETRICW), font_type: wintypes.DWORD, lparam: wintypes.LPARAM):
enum_data: EnumData = py_object.from_address(lparam).value
enum_data.gdi.EnumFontFamiliesW(enum_data.dc, logfont.elfLogFont.lfFaceName, enum_data.gdi.ENUMFONTFAMEXPROC(enum_fonts_2), lparam)
enum_data.gdi.EnumFontFamiliesW(enum_data.dc, logfont.contents.elfLogFont.lfFaceName, enum_data.gdi.ENUMFONTFAMEXPROC(enum_fonts_2), lparam)

return True

Expand Down Expand Up @@ -132,7 +132,7 @@ def get_system_fonts_filename() -> Set[str]:
fonts_filename = set()

dwrite_factory = POINTER(IDWriteFactory)()
dwrite.DWriteCreateFactory(DWRITE_FACTORY_TYPE.DWRITE_FACTORY_TYPE_ISOLATED, dwrite_factory._iid_, byref(dwrite_factory))
dwrite.DWriteCreateFactory(DWRITE_FACTORY_TYPE.DWRITE_FACTORY_TYPE_ISOLATED, byref(dwrite_factory._iid_), byref(dwrite_factory))

gdi_interop = POINTER(IDWriteGdiInterop)()
dwrite_factory.GetGdiInterop(byref(gdi_interop))
Expand Down

0 comments on commit 0439168

Please sign in to comment.