I’m researching methods to render text along a path, like you can easily do in Illustrator. Unfortunately, it’s not so simple in Processing (unless someone knows of a library that does this).
You can find a demo and the source here. Click four times to set the curve points and handles. Move the mouse left and right to alter the curve tightness.
In a nutshell, the algorithm computes the approximate length of the line segment by chopping it into smaller segments and computing the linear distance between points. Once the length of the segment is known in pixels, textWidth() is called to obtain the width in pixels of each character. This width divided by the length of the curve determines the percentage of the curve the character occupies. Once this is know, the amount to increment the variable t in the parametric curvePoint(…) function is known. From here, we can find the starting point, determine the tangent, and draw the letter.
All straightforward, right? For whatever reason, though, the kerning is severely off under certain conditions. When there is a slight curve in the line segment, it seems to be balanced. When the curve tightness is altered and becomes very flat, or very curved, the letters become overly spaced out at one end, and overly compressed at the other. Does anyone have any suggestions as to why this is happening?
