#NEWLINE# def glyph_to_bzs( g ) : #NEWLINE# #INDENT# bzs = [ ] #NEWLINE# for i in range ( g . numberOfContours ) : #NEWLINE# #INDENT# beg = ( 0 if ( i == 0 ) else ( g . endPtsOfContours [ ( i - 1 ) ] + 1 ) ) #NEWLINE# end = ( g . endPtsOfContours [ i ] + 1 ) #NEWLINE# n = ( end - beg ) #NEWLINE# pts = g . coordinates [ beg : end ] #NEWLINE# flags = g . flags [ beg : end ] #NEWLINE# bz = [ ] #NEWLINE# for j in range ( n ) : #NEWLINE# #INDENT# ( x1 , y1 ) = pts [ ( ( j + 1 ) % n ) ] #NEWLINE# if ( flags [ j ] and flags [ ( ( j + 1 ) % n ) ] ) : #NEWLINE# #INDENT# bz . append ( ( pts [ j ] , ( x1 , y1 ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( not flags [ j ] ) : #NEWLINE# #INDENT# if flags [ ( j - 1 ) ] : #NEWLINE# #INDENT# ( x0 , y0 ) = pts [ ( j - 1 ) ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ( x0 , y0 ) = lerppt ( 0.5 , pts [ ( j - 1 ) ] , pts [ j ] ) #NEWLINE# #UNINDENT# if ( not flags [ ( ( j + 1 ) % n ) ] ) : #NEWLINE# #INDENT# ( x1 , y1 ) = lerppt ( 0.5 , ( x1 , y1 ) , pts [ j ] ) #NEWLINE# #UNINDENT# if ( ( tuple ( pts [ j ] ) == ( x0 , y0 ) ) or ( tuple ( pts [ j ] ) == ( x1 , y1 ) ) ) : #NEWLINE# #INDENT# bz . append ( ( ( x0 , y0 ) , ( x1 , y1 ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# bz . append ( ( ( y0 , y0 ) , pts [ j ] , ( x1 , y1 ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# bzs . append ( bz ) #NEWLINE# #UNINDENT# return bzs