GIMP Chat
http://gimpchat.com/

Python - How to set text on layer without loosing formating
http://gimpchat.com/viewtopic.php?f=9&t=15586
Page 1 of 1

Author:  morneomorneo [ Wed May 17, 2017 1:34 pm ]
Post subject:  Python - How to set text on layer without loosing formating

I have realy simple script:
def replace(image, drawable):
    layers = image.layers
    for layer in layers:
        if pdb.gimp_drawable_is_text_layer(layer):
            pdb.gimp_text_layer_set_text(layer,'aaa')


It works. After this script on every text layer is text 'aaa' but my settings of font size and color disappear (after script text is always black and font size = 18).

What is wrong?

Author:  trandoductin [ Wed May 17, 2017 2:28 pm ]
Post subject:  Re: Python - How to set text on layer without loosing formating

Which gimp are you using.
It works on mine (the formatting, font and font size stays the same).
I am on Gimp 2.8.20

PS: I think I know what you did. I recreated your problem. You created text layers, then instead of setting/changing font options using tool options you selected the text and changed the font and font size for that text. So that doesn't work because the text layer itself still has the font and font size of default Sans 18. So when you set the text the format is lost because that text layer is still Sans 18. To make it work, you have to change font settings in Tool options then create text that way, you're setting the text layer's font and fontsize and not just for the text you've created. I hope i am explaining that right.

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/