Drawing text inside a path


#1

Does anyone have some tips for drawing wrapped text inside an arbitrary path?

The Graphics class has drawFittedText(), which makes use of the GlyphArrangement class to draw wrapped text inside of a rectangle. It works great, but only handles rectangles.

I'm looking for a way to draw wrapped text inside an arbitrary path. Let's start with an oval, since concave paths could get very complicated. Is there anything in JUCE that might help me with this? I can understand that this could be considered outside the scope of the JUCE library, but before I go looking elswhere I thought I'd ask.

Just to be clear, I don't want the text to follow a path (although that would be fun too), but to fit inside it, like this:

 

 

Thanks,

Mike

 


#2

I'm sure there must be a way of doing it, I just don't know an easy way. Perhaps you can create a RectangleList of all font height rectangles that fit within the path? Then you'd need to incrementally draw sub strings of your entire text to each Rectangle area. Ok, this is probably a shit idea. But there you go, just thought I get a discussion going. Jules will probably now point us directly to a method that does exactly what you're looking for!  


#3

Sadly we don't have any off-the-shelf functionality for that.. Yep, finding rectangles that fit into each layer of the shape and then fitting text into them is probably the best algorithm.


#4

OK, thanks. I just didn't want to do a bunch of work and then find out that I missed something that already existed.