I've made the changes and it works a treat, thank you.
For the benefit of anyone wanting to make a similar change, I altered the CreateLayout method; removing the following lines of code:
Code:
if (y > rectHeight)
{
block.Stop = true;
break;
}
And following the
if (block.Type == BlockType.LineBreak) then..else (in the same method), I first added the following, which met the requirement that I initially had, to ensure that the text did not flow beyond the boundary of the rectangle.
Code:
if (y < rectHeight) continue;
block.Stop = true;
break;
I have since extended this a little further, so that in any instance where the text "would" have overflowed the rectangle, it will not allow the overflow and will append "[...]" in place of the last word, on the last line...
Code:
if (y < rectHeight) continue;
if (idx < count)
{
int lastidx = idx;
while (lastidx > 0 && this.blocks[lastidx].Type == BlockType.LineBreak)
{
lastidx--;
}
this.blocks[lastidx].Text = "[...]";
}
block.Stop = true;
break;
Note that I replaced the last word, rather than appending to it, because I wanted to avoid making the text potentially overflow the right edge of the rectangle, and don't have the time right now to work out how to ensure that this doesn't ever occur