#NEWLINE# def text2array( text , fontsize = 100 ) : #NEWLINE# #INDENT# '\n    Renders inputted text, and returns array representation.\n\n    Inputs:\n     text (string) -  text to render\n\n    Returns: A (ndarray) - 2D numpy array of rendered text\n    ' #NEWLINE# text2png ( text , fn = '_text' , fontsize = fontsize ) #NEWLINE# A = plt . imread ( '_text.png' ) [ : , : , : 3 ] . mean ( axis = 2 ) #NEWLINE# os . remove ( '_text.png' ) #NEWLINE# return ( A . max ( ) - A )