JUCE methods for fitting text along a Path?


#1

I’m looking through the docs and wondering if there are methods that would enable fitting labels along a path, e.g. within a circle? So that the text bends around the path.


#2

There may be other methods… but I’d try putting the text onto an Image… then applying an AffineTransform on the Image

Also check out Graphics::addTransform()

Rail


#3

Thanks I’ll check that out.


#4

Interesting… I wonder if you could do something using a PathFlatteningIterator positioning and transforming the glyphs along the path using PositionedGlyph, adding them to a GlyphArrangement


#5

That sounds more like a proper plan, the Image transform suggestions won’t get you a nice result because of the Image resampling, you’d really want to render each glyph with it’s correct transform to get the best results. Would like to see the result. Adamski, i would like to see what you come up with.


#6

The points in PathFlatteningIterator look quite closely spaced (in units of 0.6) so I guess you could calculate the mean normal vector across the width of the glyph for a given section and calculate the rotation. If the path curves are relatively gentle this shouldn’t be too hard, but if there are tight complex curves it could get a bit trickier.


#7

Yes, you’d need to iterate along the path, figuring out the angle as you go… You could probably do something with getPointAlongPath (and in fact may want to look inside that method at how it’s done for some tips on iterating)


#8

Thanks all, its actually going to be following a circle, so I should be able to use just the one angle…