drawFittedText request


#1

drawFittedText is super, but right now it’s bugging me.

It appears to be the only function that will automatically put text on multiple lines when needed whilst providing you with justification controls. however, for my current purposes, i really don’t want it to squish the text horizontally.

Any chance of adding an extra bool parameter (default true) to allow this feature to be disabled?

For my quiz program, the questions are written by the teacher and can be of any length, but i don’t want them to have to carefully make sure they’re not at a length that makes them squished (and subsequently harder to read on a projected image at the front of the class).


#2

Yes, I can tweak that a bit for you. If you look in GlyphArrangement::addFittedText you’ll see there’s a fixed minimumHorizontalScale value, which I could turn into a parameter - you could do the same things as a quick hack if you need to get it going.


#3

It would be nice if drawFittedText and the other drawing functions returned a Rectangle of where the text was actually drawn.


#4

You can get that info if you use a GlyphArrangement directly.


#5

You can get that info if you use a GlyphArrangement directly.[/quote]

True, but I thought it might be handy.

Does drawFittedText ignore the height parameter? I thought if the text went past the height it would get clipped.


#6

I prefer the idea that you create an object containing your text layout and then ask it questions about its position, rather than having a method that returns some info about the layout that it’s drawing. That way the gypharrangement class can have a wide range of methods for getting more interesting info about the layout.

The text drawing methods won’t clip, but you can easily use Graphics::reduceClipRegion to do that yourself. I didn’t want to add the overhead of doing a saveState/reduceClipRegion/restoreState inside every text drawing call, when clipping is something that you rarely need it to do.


#7