When you draw a string containing 2 spaces like "this is me" then in the actual drawing 3 spaces are used. This prohibits exact placing of various sequential strings. The code below contains the fixes marked with "JV-2008-8-11"
Code:
void CreateLayout()
{
double rectWidth = this.layoutRectangle.width;
double rectHeight = this.layoutRectangle.height - 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)
{
if (Alignment == XParagraphAlignment.Justify)
((Block)this.blocks[firstIndex]).Alignment = XParagraphAlignment.Left;
AlignLine(firstIndex, idx - 1, rectWidth);
firstIndex = idx + 1;
x = 0;
y += this.lineSpace;
}
else
{
double width = block.Width; //JV-2008-08-11
if ((x + width <= rectWidth || x == 0) && block.Type != BlockType.LineBreak)
{
block.Location = new XPoint(x, y);
x += width + this.spaceWidth; // JV-2008-08-11
}
else
{
AlignLine(firstIndex, idx - 1, rectWidth);
firstIndex = idx;
y += this.lineSpace;
if (y > rectHeight)
{
block.Stop = true;
break;
}
block.Location = new XPoint(0, y);
x = width;
}
}
}
if (firstIndex < count && this.Alignment != XParagraphAlignment.Justify)
AlignLine(firstIndex, count - 1, rectWidth);
}