def _print_all_fonts(): output = ['xart : generate art ascii texts.\n'] fonts = Font.get_all_fonts() for idx, font_name in enumerate(fonts): output.append(' {}. {}'.format(idx, font_name)) output.append('\nAll {} fonts.\n'.format(len(fonts))) sys.stdout.write('\n'.join(output))
def _render_fonts(text, font=None, show=False, color='WHITE'): if not font: font = random.choice(Font.get_all_fonts()) if not text: text = 'xart' renderer = Renderer(Font(font)) data = renderer.render(text) sys.stdout.write(Color.dyeing(data, Color.get_color(color))) if show: sys.stdout.write('Font name : {}\n'.format(font))
def _render_fonts(text, font=None, show=False, color='WHITE', outfile=''): if not font: font = random.choice(Font.get_all_fonts()) if not text: text = 'xart' renderer = Renderer(Font(font)) data = renderer.render(text) if outfile: with open(outfile, 'w') as fp: fp.write(data) else: sys.stdout.write(Color.dyeing(data, Color.get_color(color))) if show: sys.stdout.write('Font name : {}\n'.format(font))