FeD:Code/Pyglet.py

Aus Förderverein euregionale Digitalkultur e.V.

Wechseln zu: Navigation, Suche

Starte den Siff hier einfach mit einem kleinen(!) Text als Parameter und es spuckt dir alle möglichen Varianten mit Deinen installierten FIGlet-Fonts aus:

#!/bin/env python
 
#   pyglet        Figlet Font Demo Tool.
#   Copyright (c) 2008 riot@resisty.org
#                 All Rights Reserved
# 
#   This program is free software; you can redistribute it and/or
#   modify it under the terms of the Do What The Fuck You Want To
#   Public License, Version 2, as published by Sam Hocevar. See
#   http://sam.zoy.org/wtfpl/COPYING for more details.
 
 
import os, sys, subprocess
 
 
figfonts = "/usr/share/figlet/fonts/"
figlet = "/usr/bin/figlet"
output = ""
 
def listDirectory(directory, fileExtList):                                        
    fileList = [os.path.normcase(f)
        for f in os.listdir(directory)]
    fileList = [os.path.join(directory, f)
        for f in fileList
            if os.path.splitext(f)[1] in fileExtList]
    return fileList
 
 
for font in listDirectory(figfonts, ".flf"):
    cmd = "%s -f %s %s"%(figlet,font, sys.argv[1])
    output += font + "\n"
    process = subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE)
    fontdemo = process.communicate()[0]
    output += fontdemo
 
print output