Reputation: 879
I'm looking for a way to list all fonts installed on a linux/Debian system, and then generate images of some strings using these fonts. I'm looking for your advice as I kind of see how to do each part, but not to do both:
To list all fonts on a UNIX system, xlsfonts
can do the trick:
import os
list_of_fonts=os.popen("xslfonts").readlines()
ImageFont
class.However, ImagesFont.load
expects a file name, whereas xlsfonts
gives a kind of normalized font name, and the correspondence between the two doesn't seems obvious (I tried to search my system for files named as the output of xlsfonts
, without results).
Does anyone has an idea on how I can do that? Thanks!
Upvotes: 5
Views: 1022
Reputation:
you best bet is to do a find
on all the fonts on the system, and then use ImagesFont.load()
on the results of that list. I don't know where the fonts are on Debian, but they should be in a well known folder you can just do an os.walk
and then feed the filenames in that way.
Upvotes: 1
Reputation: 20878
You can do this using pango, through the pygtk package. Pango can list fonts and render them.
Upvotes: 1