#NEWLINE# def text2png( text , fn = None , fontsize = 100 , dpi = 100 ) : #NEWLINE# #INDENT# '\n    Renders inputted text to a png image using matplotlib.\n\n    Inputs:\n     text (string) -  text to render\n\n    Optional input:\n     fn (string)  -  filename of png to be outputted.\n                     defaults to the entered text\n\n    Returns: (None)\n    ' #NEWLINE# f = plt . figure ( frameon = False ) #NEWLINE# ax = f . add_subplot ( 111 ) #NEWLINE# plt . text ( 0.5 , 0.5 , text , horizontalalignment = 'center' , verticalalignment = 'center' , transform = ax . transAxes , fontsize = fontsize ) #NEWLINE# ax . set_axis_off ( ) #NEWLINE# if ( not fn ) : #NEWLINE# #INDENT# fn = '' . join ( ( e for e in text if e . isalnum ( ) ) ) #NEWLINE# #UNINDENT# f . savefig ( ( fn + '.png' ) , bbox_inches = 'tight' , dpi = dpi ) #NEWLINE# plt . close ( )