drawText/drawFittedText that supports fallback font


#1

Hi Jules,

 

Would it be possible to add an equivalent of drawFittedText or drawText with the same parameters which uses internally

TextLayout which would basically do this ?

juce::TextLayout textLayout;
juce::AttributedString str(text);
str.setJustification(justificationFlags);
str.setColour(colour);
str.setFont(context.getFont());
textLayout.createLayout(str, width);
textLayout.draw(g, juce::Rectangle<int>(x, y, width, height).toFloat());
 

It helps supporting non latin text display.

If you want a faster version, you can cache the TextLayout in your code but it's not always mandatory so it a useful addition to simplify some code.

 

Thanks,

 


#2

I can't really see a good argument for adding something like that to the Graphics class.. It'd work equally well as a free function that you can write yourself, and which you can tailor to do exactly as much as you need.


#3

ok, no pb.

As long as you add the height argument in createLayout, I'm fine :)

 

Thanks !