Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python3 how to install .ttf font file?

I wanted to install .ttf font file on windows 10 with python3 (more precise Python 3.6) code, I googled but the only thing I found was this one Install TTF fonts on windows with python, I tested it but it didn't do anything. Is there a way to install .ttf with python3 code?

Thanks in advance.

like image 659
Senhor Sardinhas Avatar asked Jul 29 '26 00:07

Senhor Sardinhas


1 Answers

This library seems promising (I haven't tried myself).

Installing

pip install --user fonttools

or

pip3 install --user fonttools

Code

from fontTools.ttLib import TTFont
font = TTFont('/path/to/font.ttf')

Then use font.save method:

Definition: font.save(self, file, reorderTables=True)

Docstring: Save the font to disk. Similarly to the constructor, the 'file' argument can be either a pathname or a writable file object.

like image 183
Rafael Avatar answered Jul 31 '26 15:07

Rafael



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!