Вопрос

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