i think i got it...
Code:
/// <summary>
/// finds out the height of a textrect by giving the width.
/// </summary>
/// <param name="text">The text</param>
/// <param name="font">The font.</param>
/// <param name="rectWidth">The width of the textrect.</param>
public double getTextRectHeight(string text, XFont font, double rectWidth)
{
Text = text;
Font = font;
CreateBlocks();
double rectHeight = this.cyAscent + this.cyDescent;
int firstIndex = 0;
double x = 0, y = 0;
int count = this.blocks.Count;
for (int idx = 0; idx < count; idx++)
{
Block block = (Block)this.blocks[idx];
if (block.Type == BlockType.LineBreak)
{
firstIndex = idx + 1;
x = 0;
y += this.lineSpace;
}
else
{
double width = this.spaceWidth + block.Width;
if ((x + width <= rectWidth || x == 0) && block.Type != BlockType.LineBreak)
{
block.Location = new XPoint(x, y);
x += width;
}
else
{
firstIndex = idx;
y += this.lineSpace;
block.Location = new XPoint(0, y);
x = width;
}
}
}
return rectHeight + y;
}
i just copied and modified the code of the CreateLayout-Function and tested it with the TextLayout-Example ... and it seems to work