Installing TTF fonts on windows with python

徘徊边缘 提交于 2019-12-30 21:57:19

问题


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.


回答1:


import win32api
import win32con
import ctypes

ctypes.windll.gdi32.AddFontResourceA("C:\\Users\\Username\\Desktop\\fontname.ttf")
win32api.SendMessage(win32con.HWND_BROADCAST, win32con.WM_FONTCHANGE)


来源:https://stackoverflow.com/questions/19767822/installing-ttf-fonts-on-windows-with-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!