I want to install new fonts on windows with Python 2.7. First I copied myFont.ttf to windows Fonts folder then I Added My Font (True Type) key to registry (HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts). Now I want to declare system that a new font has been installed. For this I found that I should use win32api.SendMessage, But I don't know how to provide required arguments for this method?

Is there anyway to install ttf fonts on windows with python? I googled it but I couldn't find useful data on Python.

有帮助吗?

解决方案

import win32api
import win32con
import ctypes

ctypes.windll.gdi32.AddFontResourceA("C:\\Users\\Username\\Desktop\\fontname.ttf")
win32api.SendMessage(win32con.HWND_BROADCAST, win32con.WM_FONTCHANGE)
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top