Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python get list of available fonts on system

how can I get all available fonts in the system (Linux) ?

I searched and found this: http://www.lemoda.net/pango/list-fonts/ but it's in C and depend on pango.

How can I do this in Python?

like image 642
wong2 Avatar asked Dec 22 '25 13:12

wong2


1 Answers

You can try using fc-list on ubuntu and then split every line by ":" to get all fonts on ubuntu http://manpages.ubuntu.com/manpages/hardy/man1/fc-list.1.html

map(lambda x : x.split(":")[1],commands.getstatusoutput('fc-list')[1].split("\n"))

While some of the font-names may contain symbols which python may not be able to print properly.

like image 158
Akshay Hazari Avatar answered Dec 24 '25 02:12

Akshay Hazari