0

I have a simple python-fu script for gimp

list_of_text = [
"long string one", 
"long string two ",
]

x=200
y=400
border=0
font_size=62
font="Merriweather"
path='/Users/incognito/blank_card.xcf'

for text in list_of_text:
    image = pdb.gimp_file_load(path, '1')
    gimp.Display(image)

    gimp.set_foreground(23, 18, 20)
    layer = pdb.gimp_text_fontname(image, None, x, y, text, border, True, font_size, PIXELS, font)

Everything works there.

The issue is I can't find any way in the API to resize the text box. As you can see in this image the length of the text is so long that I can't even get access to the handles to resize the box.

enter image description here

I've tried a few things like using the layer resize api but this seems to only anchor the image somehow. I've also tried creating layers that have limited sizes but the new text seems to ignore it.

I've been reading through the docs here but it isn't very obvious to me. https://developer.gimp.org/api/2.0/libgimp/libgimp-gimptextlayer.html

xenoid
  • 8,396
  • 3
  • 23
  • 49
Incognito
  • 20,537
  • 15
  • 80
  • 120
  • In addition to you answer, you can use middle-click and drag to shift the whole canvas across the image window. Between this and being zoomed out, I can grab th erihgt side of the window (using the Text tool) and then resize the text. You can also prevent the problem using `gimp_text_get_extents_fontname` to figure out in advance the size of the layer. – xenoid Jul 13 '22 at 16:45

1 Answers1

1

What I wanted was

>>> pdb.gimp_text_layer_resize(layer, 300, 300)

enter image description here

Incognito
  • 20,537
  • 15
  • 80
  • 120