title: Using regular expression in Python to generate a list
body: <p>I have a small script which is used to produce an image with predefined font and text. I would like to change it to use multiple fonts to render the same text e.g. letter <code>A</code> in 5 fonts. I am defining my fonts list as :</p>
  
  <p><code>fonts    = [ 'Georgia', 'Consolas', 'Arial'</code> ]</p>
  
  <p>and then I use it in : </p>
  
  <pre><code>for item in enumerate(fonts) :
   ...
  </code></pre>
  
  <p>I would like to generate the list with all e.g. Times New Roman family fonts. I was trying to generate the list with regular expression but with no luck. I do not really know how to embed it in the list (with quotes, with <code>/</code> in beginning and end, etc.)</p>
  
  <p>I have tried something like this :  <code>fonts = [ '/^.Times.*$/' ]</code> and this <code>fonts = [ '/Times.*/g' ]</code> but with no success.</p>
  
  <p>Seond problem arose when I wanted to use 3 words fonts like <code>Luicida Console Regular</code>, then I got this error : </p>
  
  <pre><code>C:\Users\xxx\Desktop\test.py:46: PangoWarning: couldn't load font "Luicid
  a Console 40", falling back to "Sans 40", expect ugly output.
    pangctx.show_layout (layout)
  </code></pre>
  
  <p>looks like the script is getting only two words from the font name.</p>
  
  <p><strong>EDIT</strong></p>
  
  <pre><code>def main ():
      surface = cairo.ImageSurface (cairo.FORMAT_ARGB32, WIDTH, HEIGHT)
      context = cairo.Context (surface) 
      source  = context.get_source ()
      font    = sys.argv[1]
  
      fonts    = [ 'Georgia', 'Consolas', 'Arial',  'Lucida Console', 'Times New Roman' ]
      output  = sys.argv[2]
      text    = sys.argv[3]
  
      background = cairo.SolidPattern (255, 255, 255)
      context.rectangle (0, 0, WIDTH, HEIGHT)
      context.set_source (background)
      context.fill ()
  
      pangctx = pangocairo.CairoContext (context)
  
      layout  = pangctx.create_layout () 
      layout.set_width ((WIDTH - 2 * PADDING) * pango.SCALE)
      layout.set_single_paragraph_mode (True)
      layout.set_wrap (pango.WRAP_CHAR)
  
      size    = 40 * pango.SCALE
      spacing = 10 * pango.SCALE
      markup = ''
      for index, item in enumerate(fonts):
          print index, item
          markup  += '&lt;span font="'+ item +'" size="' + str(size) + '" letter_spacing="' + str(spacing) + '"&gt;' + text +'&lt;/span&gt;'
      layout.set_markup (markup)
      pangctx.update_layout (layout)
  
      context.new_path ()
      context.move_to (PADDING, PADDING)
      context.set_source (source)
      context.set_source_rgb (0, 0, 0)
  
      pangctx.show_layout (layout)
      surface.write_to_png (output)
  </code></pre>
  
  <p><strong>EDIT</strong> 
  seems that this is still a bug in pango <a href="https://bugs.launchpad.net/openobject-client/+bug/734689" rel="nofollow">launchpad link</a></p>