Gimp-Forum.net
Apply stroke to text in Gegl? - Printable Version

+- Gimp-Forum.net (https://www.gimp-forum.net)
+-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP)
+--- Forum: General questions (https://www.gimp-forum.net/Forum-General-questions)
+--- Thread: Apply stroke to text in Gegl? (/Thread-Apply-stroke-to-text-in-Gegl)



Apply stroke to text in Gegl? - JasonP - 03-12-2020

Hi,

This isn't really a Gimp question, but I'm having trouble finding a better place to post it - please feel free to redirect me if appropriate.  I've been feeding xml files to the Gegl command line application to process photos - applying a crop, doing rotations, compositing, adding text, etc.  But now I've been asked to add dropshadows and strokes to the text.  Dropshadows were easy... but it looks like to apply a stroke, I'd need to somehow define a path around the text.  I've been all over the (somewhat sparse) documentation, but I can't find anything that even gives me a starting point on how to do that.  Does anyone here have any suggestions for doing this in an automated fashion?

Thanks,
Jason


RE: Apply stroke to text in Gegl? - denzjos - 03-12-2020

On your text layer :
- (right mouse button) click on : Alpha to Selection
- the text is now selected (walking ants)
- in the gimp menu : Select / To Path
- now there is a path made
- in the gimp menu : Select / None
- right click in the 'Paths' dock on the constructed path 
- click on 'Stroke Path'


RE: Apply stroke to text in Gegl? - JasonP - 03-12-2020

Thanks for responding, denzjos! I understand how to do it in Gimp, but I'm trying to see if there is a way to get the path using only the Gegl library Gimp relies. The intended application is for fully automated photo manipulation. Our plan is to generate xml files that can be processed using the Gegl command line application. I've been able to handle every request so far except adding a stroke to text. And as I said, my sticking point is that I can't see a way to obtain the path of the text node.


RE: Apply stroke to text in Gegl? - JasonP - 03-17-2020

OK - just to wrap this up, I ended up writing my own operation in Gegl. Basically, I just copied the existing "text.c" operation to a new "textstroke.c" file, added "stoke_width" and "stroke_color" parameters, and used pango_cairo_layout_path() to get the text path. Once I had that, I just used cairo_stroke() to draw it.

All in all, it was pretty straightforward. Documentation on Gegl is sparse, but the operations are very readable. Getting my head around the pango (text layout) and cairo (2D vector drawing) libraries were the hardest part. I imagine doing anything serious would take more effort, but I was impressed at how easy the Gegl library was to modify.