def render_pass(self, text, known_width):
     # 1st pass - calculate width requirment - return width integer
     # 2nd pass - render result image itself
     if known_width:
         height = self.map2glyph.map.values()[0].get_height() # get any glyph to calculate image's height
         result_image = Image.new("RGB", (known_width,height), COLOR_WHITE)
         result_image.source ="font-render-image"
     else:
         result_image = None
     def_glyph = self.map2glyph.get('?')
     print "default glyph: %s" % def_glyph
     left = 0
     for char in text:
         glyph = self.find_glyph(char, def_glyph)
         if glyph:
             blind_left, blind_right = glyph.get_blind_pixels_info()
             if blind_left or blind_right:
                 print "blind pixels detected: %s %s" % (blind_left, blind_right)
             if result_image:
                 result_image.paste(glyph.image, (left,0))
             left += glyph.get_width()
             left += self.char_gap
             if HINT_CHARS_OPEN_RIGHT.find(char.lower()) >= 0:
                 left -= 1
             #left -= blind_left + blind_right
             #left += int(11.00000)
     return result_image if result_image else left
 def __init__(self, char_gap, space_width):
     self.char_gap = char_gap
     self.map2glyph = GlyphMap()
     space_glyph = Glyph(Image.new("RGB", (space_width,1), COLOR_WHITE))
     space_glyph.image.source = "space-image"
     self.map2glyph.set(' ', space_glyph)