Warped text
Page 1 of 7

Author:  saulgoode [ Sat Jul 03, 2010 4:43 pm ]
Post subject:  Warped text

This script was written more as a learning exercise and I'm dubious as to its general utility. However, the crowd here seems somewhat adventurous and exceedingly creative, so I figured I'd see if any of you might not like to experiment a little with it.

The script will warp text to fit inside a four-point "Bezier patch". The bezier patch is created with the Path Tool, by placing first the upper-left anchor point, then the upper-right, followed by the lower-right, and finally the lower-left. You will probably want to close the path after placing the fourth point so that you can see the left-side curve. Closing a path is accomplished by holding down the CTRL key while clicking on the path's first anchor point.

File comment: The path that describes the target region
bezpatch.png [ 15.07 KiB | Viewed 9747 times ]

Once your patch is created, you can run the script (found under "Filters->Distorts->Warp Text...") on any text layer and eventually, after a good deal of huffing and puffing by the script, a new path will be created which is the outline of the text warped to fit within the patch. Basically, you are left just as you would be after doing a "Text along Path" in the Text tool Options dialog -- you are left to your own devices as to stroking the path, selecting from it and filling, etc. The dialog offers the option to warp any path, not just text; but I leave that for extra credit (perhap warping warped text? :) ).

File comment: Text path after warping
SSwarp.png [ 26.73 KiB | Viewed 9747 times ]

The fit is by no means perfect (usually mappings to Bezier surfaces entail additional control points inside the "patch"), but it may be useful for some situations. There is a "Padding" control which can be helpful in making sure the warped path doesn't fall outside the Bezier patch region (which is an unfortunate side effect of the shortcuts I took in my mapping algorithm). There is also a "Quality" setting which can range from below "10" (where letters are barely recognizable) to "250"; I don't notice much improvement above "100" and I set the default to "60" as speed versus quality compromise.

Let me know if you can find a use for it, if you find bugs, or if you can think of ways to improve it (I am considering allowing for more than four control points at some point, but that would require some slightly more sophisticated math).

EDIT: This script has now been submitted to the GIMP Plug-in Registry.

Author:  Oregonian [ Sat Jul 03, 2010 5:53 pm ]
Post subject:  Re: Warped text

This is a fun script. I tried it with some dingbat hearts and, of course, came up with warped hearts.

Here is some text I played with. As with the hearts, the text came out sideways and mirrored. I need to work more to see what is causing that.

The original text is black, the first text is the brownish gradient and is mirrored and on its side. The orange and black text is after I rotated and flipped the text path.

I like the script and will continue playing with it to see what I come up with. I thought of making the text an animated "pulsing" movement ... done by changing the shape of the path several times. That will come later after I figure out how to make it come out right-side up and not mirrored.

Very cool script, saulgoode. :bigthup I can see using it where you'd want an unusual text formation that can't be done using just text. Band banners where the script is fitted into a frame. Like some of the Grateful Dead Posters I've seen. Kind of on this order

Author:  saulgoode [ Sat Jul 03, 2010 6:38 pm ]
Post subject:  Re: Warped text

I have updated the script to fix a mistake (that caused the lower curve to be less influential).

As far as the flipped and/or rotated result, that is usually caused by the envelope path's points being in the wrong sequence, though it is possible I have a bug in my code. If you can't figure out what's happening, perhaps you can send me a small example XCF which exhibits the anomaly. My address is my user name @

Author:  Oregonian [ Sat Jul 03, 2010 6:49 pm ]
Post subject:  Re: Warped text

It could possibly be the sequence of the points. I'm a left-hander and even though I use my right hand for the mouse, it could be that the different direction is carried over to my mouse hand. I'll work with that and see if there's a difference with different directions.

Author:  Oregonian [ Sat Jul 03, 2010 11:06 pm ]
Post subject:  Re: Warped text

It does make a difference where you start the path and which direction you make it.

Upper Left and go CW all comes out fine.
Upper Left and CCW, comes out sideways and mirrored
Upper Right, CW makes it sideways but not mirrored
Upper Right, CCW upright but mirrored.

I deleted the old script and installed the updated one. I also closed and restarted GIMP to make sure the newest script was in effect.

Path was made starting on the lower right and CCW.
Text Came out upside down, mirrored, and turning it 180° corrected it.

These were just for fun and I used the same path on both dingbats.


Author:  Oregonian [ Sun Jul 04, 2010 10:00 am ]
Post subject:  Re: Warped text

The filter is not very happy with the bottom upward curve in the GIMP text in this one.


Author:  saulgoode [ Sun Jul 04, 2010 10:50 am ]
Post subject:  Re: Warped text

Oregonian wrote:
The filter is not very happy with the bottom upward curve in the GIMP text in this one.

I would suggest checking your side curves; that result can be caused if there is "zig" in one of the sides. If a horizontal line through one of the side curves intersects at more than one point, such as shown below, the result would match what you've shown.

File comment: Overlapping side curve
SSsidepath.png [ 413 Bytes | Viewed 9699 times ]

The "zig" may not even be visible when viewing the path; the overlapping points may lie directly over each other if the control handle for an anchor is located farther away than the other anchor.

If this is not the cause, perhaps you could export your path (available by right clicking on its thumbnail in the Paths Dialog) and provide me with the file (or provide an XCF containing your path).

Thanks for testing the script and providing feedback.

Author:  Oregonian [ Sun Jul 04, 2010 10:52 am ]
Post subject:  Re: Warped text

I did save it as an xcf file thinking you may want to look at it. Here it is.

bottomcurveNG.xcf [116.92 KiB]
Downloaded 279 times

Author:  saulgoode [ Sun Jul 04, 2010 11:12 am ]
Post subject:  Re: Warped text

Ahh, yes. Thanks.

The problem is indeed caused by the fact that the side curves have more than one X value for a given Y (though not exactly the "zig" I previously suggested).

If you can reposition your anchors to the bottom corners then you will not have that problem.
File comment: Repositioned anchors
SSmoved-anchors.png [ 1.05 KiB | Viewed 9693 times ]

As a general rule (unless one wants the distortion you obtained :) ), a control handle should always lie between its anchor and the adjacent anchor (either the next anchor in the path or the previous, depending on which control handle).

For example, in the above screenshot the control handle which happens to be closest to the lower-left anchor (the open circle) must not below the bottom-left anchor. Likewise, the other control handle shown must be to the right of the lower-left anchor.

Of course, rules can always be disregarded, if you are willing to accept the consequences.

Author:  Oregonian [ Sun Jul 04, 2010 11:30 am ]
Post subject:  Re: Warped text

I opened up my faulty path xcf file so I could visually see what you were saying about it. Aha! Understand.

Fixed my path.


Page 1 of 7 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group