title: How do I change text in a python-fu gimp script without changing the font?
body: <p>I have a master image which I edit in gimp to get the look and feel wanted. I then want to use a python script to produce a bunch of new images with the text (on several different layers) changed. I would like to leave the font, size, italicized or not, etc. alone.</p>
  
  <p>I've successfully changed the text in my batch script with this function:</p>
  
  <pre><code>pdb.gimp_text_layer_set_text(layer, text)
  </code></pre>
  
  <p>The problem is this also overwrites the font and other text parameters that I had picked out in the master file. Is there a way to change <em>just</em> the text and leave the font alone?</p>
  
  <p>Alternately, a more clunky way would be to try and save everything important about the font before the change and try to reapply it. This is what I've tried:</p>
  
  <pre><code># Find the text layer
  text1_layer = filter(lambda x: x.name == 'text1', im.layers)[0]
  
  # Save the font                
  font = pdb.gimp_text_layer_get_font(text1_layer)                              
  font_size, font_unit = pdb.gimp_text_layer_get_font_size(text1_layer)
  
  # Set the text       
  pdb.gimp_text_layer_set_text(text1_layer, tex1_text)
  
  # Restore the font                       
  pdb.gimp_text_layer_set_font(text1_layer, font)                               
  pdb.gimp_text_layer_set_font_size(text1_layer, font_size, font_unit)
  </code></pre>
  
  <p>Unfortunately, that doesn't seem to work consistently. It looks like the get_font and get_font_size commands retrieve the right font for one of the layers, but not for the others. It doesn't seem to preserve italics etc., and I wouldn't expect it to preserve whether or not text is underlined.</p>
  
  <p>A third option would be to hard code in the font. I would need to go through all the text fields, figure out what the font parameters are and hard code them in for each one. Then, if I redesign the master file (which I will do a lot), I have to repeat the process. This shouldn't be necessary.</p>