#NEWLINE# def compile( self ) : #NEWLINE# #INDENT# 'Create metrics and bitmap' #NEWLINE# if self . bitmap : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# h = w = maxwidth = 0 #NEWLINE# lines = 1 #NEWLINE# for glyph in self : #NEWLINE# #INDENT# if glyph : #NEWLINE# #INDENT# ( d , dst , src , im ) = glyph #NEWLINE# h = max ( h , ( src [ 3 ] - src [ 1 ] ) ) #NEWLINE# w = ( w + ( src [ 2 ] - src [ 0 ] ) ) #NEWLINE# if ( w > WIDTH ) : #NEWLINE# #INDENT# lines = ( lines + 1 ) #NEWLINE# w = ( src [ 2 ] - src [ 0 ] ) #NEWLINE# #UNINDENT# maxwidth = max ( maxwidth , w ) #NEWLINE# #UNINDENT# #UNINDENT# xsize = maxwidth #NEWLINE# ysize = ( lines * h ) #NEWLINE# if ( ( xsize == 0 ) and ( ysize == 0 ) ) : #NEWLINE# #INDENT# return '' #NEWLINE# #UNINDENT# self . ysize = h #NEWLINE# self . bitmap = Image . new ( '1' , ( xsize , ysize ) ) #NEWLINE# self . metrics = ( [ None ] * 256 ) #NEWLINE# x = y = 0 #NEWLINE# for i in range ( 256 ) : #NEWLINE# #INDENT# glyph = self [ i ] #NEWLINE# if glyph : #NEWLINE# #INDENT# ( d , dst , src , im ) = glyph #NEWLINE# ( xx , yy ) = ( ( src [ 2 ] - src [ 0 ] ) , ( src [ 3 ] - src [ 1 ] ) ) #NEWLINE# ( x0 , y0 ) = ( x , y ) #NEWLINE# x = ( x + xx ) #NEWLINE# if ( x > WIDTH ) : #NEWLINE# #INDENT# ( x , y ) = ( 0 , ( y + h ) ) #NEWLINE# ( x0 , y0 ) = ( x , y ) #NEWLINE# x = xx #NEWLINE# #UNINDENT# s = ( ( src [ 0 ] + x0 ) , ( src [ 1 ] + y0 ) , ( src [ 2 ] + x0 ) , ( src [ 3 ] + y0 ) ) #NEWLINE# self . bitmap . paste ( im . crop ( src ) , s ) #NEWLINE# self . metrics [ i ] = ( d , dst , s )