drawFittedText draws over given rectangle


#1

example (see attachement)


void MainContentComponent::paint (Graphics& g)
{
    g.fillAll (Colour (0xffeeddff));

    Rectangle<int> rect(0,getHeight()/3,getWidth(),getHeight()/3);
    g.setColour(Colours::red);
    g.fillRect(rect);
    g.setColour(Colours::black);
    g.drawFittedText("Bla bla bla bla\nBla bla bla bla\nBla bla bla bla\nBla bla bla bla\nBla bla bla bla\nBla bla bla bla\nBla bla bla bla\nBla bla bla bla\nBla bla bla bla\nBla bla bla bla\nBla bla bla bla\nBla bla bla bla\nBla bla bla bla\nBla bla bla bla\nBla bla bla bla\nBla bla bla bla\nBla bla bla bla\n"
                ,rect,Justification::centred,100,0.5);
}

 


 


#2

Yeah, it just centres it in that rectangle, it doesn't try to clip it (that would be a big performance overhead that few people ever need). 

If you want to clip it, just use do that yourself before drawing the text.


#3

mhh well, it just doesn't do what the description says:


 If the text just won't fit into the space,
        it'll cram as much as possible in there, and put some ellipsis at the end to show that
        it's been truncated.
 

 


#4

It can only truncate with ellipsis for horizontally long lines. You might want to just set the maximum number of lines to use.