My environment: Apple Mac mini M2, macOS Tahoe 26.1.
I want to set the color of a text layer from a Python plug-in. In Gimp 2 I used the plug-in "gimp-text-layer-set-color".
In Gimp 3 I find the layer method "set_color(color)", but the color remains to be the foreground color. The same with the PDB plug-in.
First try with layer method:
The text is black.
Next try with pdb proc:
The text is black.
Next try with foreground:
Success! The text is red.
Where is the error? With my code or with Gimp?
I want to set the color of a text layer from a Python plug-in. In Gimp 2 I used the plug-in "gimp-text-layer-set-color".
In Gimp 3 I find the layer method "set_color(color)", but the color remains to be the foreground color. The same with the PDB plug-in.
First try with layer method:
Code:
textColor = Gegl.Color.new("red") # e.g.
textLayer = Gimp.TextLayer.new(image, "Text", someFont, sometextSize, Gimp.Unit.pixel())
textLayer.set_name("Text")
textLayer.set_color(textColor)
image.insert_layer(textLayer, parent, position)Next try with pdb proc:
Code:
textColor = Gegl.Color.new("red") # e.g.
textLayer = Gimp.TextLayer.new(image, "Text", someFont, sometextSize, Gimp.Unit.pixel())
textLayer.set_name("Text")
pdb = Gimp.get_pdb()
textLayerSetColor = pdb.lookup_procedure("gimp-text-layer-set-color")
pdbConfig = textLayerSetColor.create_config()
pdbConfig.set_property("layer", textLayer)
pdbConfig.set_property("color", textColor)
textLayerSetColor.run(pdbConfig)
image.insert_layer(textLayer, parent, position)Next try with foreground:
Code:
textColor = Gegl.Color.new("red") # e.g.
foreground = Gimp.context_get_foreground()
Gimp.context_set_foreground(textColor)
textLayer = Gimp.TextLayer.new(image, "Text", someFont, sometextSize, Gimp.Unit.pixel())
textLayer.set_name("Text")
image.insert_layer(textLayer, parent, position)
Gimp.context_set_foreground(foreground)Where is the error? With my code or with Gimp?

