X
X
xomiles2020-08-13 01:29:48
Python
xomiles, 2020-08-13 01:29:48

How to package a python application using pyinstaller so that the downloaded font works for others?

I downloaded the font, but I don’t know how to pack it so that it works on other PCs.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
SKEPTIC, 2020-08-13
@xomiles

Open font in binary mode

f = open("shrift.ttf", "rb")
font = f.read()

Next, encode font in base64 and write it to some file.
Open the file in a text editor and copy the text. Next, paste this text as a string into the python script.
Then decode it from base64 and write it to a file in binary mode. Use this file as a font.
Profit

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question