#NEWLINE# def load( self , name , size ) : #NEWLINE# #INDENT# font = ImageFont . truetype ( name , size ) #NEWLINE# chars = [ chr ( x ) for x in range ( 32 , 127 ) ] #NEWLINE# sizes = dict ( ( ( c , font . getsize ( c ) ) for c in chars ) ) #NEWLINE# offsets = dict ( ( ( c , font . getoffset ( c ) ) for c in chars ) ) #NEWLINE# mw = ( max ( ( sizes [ c ] [ 0 ] for c in chars ) ) + 1 ) #NEWLINE# mh = ( max ( ( sizes [ c ] [ 1 ] for c in chars ) ) + 1 ) #NEWLINE# rows = 10 #NEWLINE# cols = 10 #NEWLINE# w = ( mw * cols ) #NEWLINE# h = ( mh * rows ) #NEWLINE# w = int ( ( 2 ** ceil ( ( log ( w ) / log ( 2 ) ) ) ) ) #NEWLINE# h = int ( ( 2 ** ceil ( ( log ( h ) / log ( 2 ) ) ) ) ) #NEWLINE# im = Image . new ( 'RGBA' , ( w , h ) , self . bg ) #NEWLINE# draw = ImageDraw . Draw ( im ) #NEWLINE# for ( ( row , col ) , c ) in zip ( product ( range ( rows ) , range ( cols ) ) , chars ) : #NEWLINE# #INDENT# x = ( col * mw ) #NEWLINE# y = ( row * mh ) #NEWLINE# ( dx , dy ) = offsets [ c ] #NEWLINE# draw . text ( ( ( ( x + 1 ) - dx ) , ( ( y + 1 ) - dy ) ) , c , size . fg , font ) #NEWLINE# #UNINDENT# self . dx = mw #NEWLINE# self . dy = mh #NEWLINE# self . du = ( float ( mw ) / w ) #NEWLINE# self . dv = ( float ( mh ) / h ) #NEWLINE# self . sizes = sizes #NEWLINE# self . offsets = offsets #NEWLINE# self . im = im #NEWLINE# self . font = font