#!/usr/bin/python3 # -*- coding: utf-8 -*- # -*- mode: Python -*- ''' Static text writer pip3 install Hershey-Fonts v0.1.0 Font list : 'futural', 'astrology', 'cursive', 'cyrilc_1', 'cyrillic', 'futuram', 'gothgbt', 'gothgrt', 'gothiceng', 'gothicger', 'gothicita', 'gothitt', 'greek', 'greekc', 'greeks', 'japanese', 'markers', 'mathlow', 'mathupp', 'meteorology', 'music', 'rowmand', 'rowmans', 'rowmant', 'scriptc', 'scripts', 'symbolic', 'timesg', 'timesi', 'timesib', 'timesr', 'timesrb' Licensed under GNU GPLv3 by cocoa and Sam Neurohack ''' from __future__ import print_function import time import argparse import sys from HersheyFonts import HersheyFonts from os import path, getcwd abspath, filename = path.split(path.realpath(__file__ )) sys.path.insert(0, path.join(abspath,"../lib")) from clitools import Clitools argsparser = argparse.ArgumentParser(description="Text generator") argsparser.add_argument("-f","--fps",help="Frame Per Second",default=30,type=int) argsparser.add_argument("-v","--verbose",action="store_true",help="Verbose output") argsparser.add_argument("-t","--text",help="Text to display",default="hello",type=str) argsparser.add_argument("-p","--police",help="Herschey font to use. One of ({})".format(", ".join(HersheyFonts().default_font_names)),default="futural",type=str) args = argsparser.parse_args() fps = args.fps verbose = args.verbose text = args.text fontname = args.police cli = Clitools({ "verbose" : verbose, "looptime" : 1 / fps, "name" : "generator::text" }) # Useful variables init. white = cli.rgb2int((255,255,255)) red = cli.rgb2int((255,0,0)) blue = cli.rgb2int((0,0,255)) green = cli.rgb2int((0,255,0)) color = 65280 shape = [] thefont = HersheyFonts() #thefont.load_default_font() thefont.load_default_font(fontname) thefont.normalize_rendering(120) for (x1, y1), (x2, y2) in thefont.lines_for_text(text): shape.append([x1, -y1+400, color]) shape.append([x2 ,-y2+400, color]) while True: cli.startFrame() print(shape, flush = True); cli.endFrame()