Skip to content
Advertisement

Is possible to link an online font file to PIL ImageFont.truetype()?

Instead of downloading the font locally and link it to ImageFont.truetyp() to be like this:

JavaScript

Can I do something like this:

JavaScript

Advertisement

Answer

ImageFont.true_type takes a file-like object.

Python’s standard library, urllib.request.urlopen returns a file-like object.

The following should work:

JavaScript

edit: As @flyer2403 answered, to make that particular url work you need to add ?raw=true to the end.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement