pythonoperating-systemos.pathlistdir

How to get a list of installed windows fonts using python?


How do I get a list of all the font names that are on my computer's system?


Solution

  • This is just a matter of listing the files in Windows\fonts:

    import os
    
    print(os.listdir(r'C:\Windows\fonts'))
    

    The output is a list that starts with something that looks like this:

    ['arial.ttf', 'arialbd.ttf', 'arialbi.ttf', 'cambria.ttc', 'cambriab.ttf'