rnapier/CurvyText

"Center" align?

Closed this issue · 2 comments

@rnapier not seeing the option upon initial review, but I figure it's worth asking — do you have a solution for "center" aligning the text along the path?

So rather than laying out the first character at the beginning of the curve, start from the center and then render half the text to the left of center, half the text to the right?

I haven't written that, but it's certainly writable. You'd need a length() method on PathSection in order to compute the entire path length to work out the midpoint. You can get the text width using LayoutManager.typographicBounds. With those, you'd want to initialize TangentGeneator.lastLocation to the desired starting location rather than 0. The rest should "just work."

If the text is editable, it would probably be worth caching the total path length, since curve length computations are somewhat expensive, and the entire curve length has to be computed to support centering. I'm not currently making enhancements to this repo (too many other volunteer projects right now), but if someone needs additional features, I'm open to short-term contract work.

Appreciate the response and the proposed solution. I'll try out that approach. I may follow up with you about the potential for a short-term contract to implement this. Thanks @rnapier