Shape heigth is not calculated properly

When I use an autosized shape (based on a text), the size of the shape is not calculated properly.
If you run the code bellow, you will notice the shapes will have different heigth.
What should I do to retrieve the correct shape size ?

public void TextSize(string fileName)
{
Diagram diagram = new Diagram();
long shapeId = diagram.Pages[0].DrawRectangle(2, 5, 5, 0.1);
Shape shape = diagram.Pages[0].Shapes.GetShape(shapeId);

FormatText(shape);

shape.XForm.Height.Ufe.F = "GUARD(TEXTHEIGHT(TheText,Width))";
shape.RefreshData();

double width = shape.XForm.Width.Value;
double height = shape.XForm.Height.Value;

diagram.Pages[0].DrawRectangle(7, 5, width, height);

diagram.Save(fileName, SaveFileFormat.Vsdx);

}

private void FormatText(Shape shape)
{
shape.Text.Value.Clear();
shape.Chars.Clear();

// Mark character run and add text
shape.Text.Value.Add(new Cp(0));
shape.Text.Value.Add(new Txt("TextStyle_Regular\n"));
shape.Text.Value.Add(new Cp(1));
shape.Text.Value.Add(new Txt("TextStyle_Bold_Italic\n"));
shape.Text.Value.Add(new Cp(2));
shape.Text.Value.Add(new Txt("TextStyle_Underline_Italic\n"));
shape.Text.Value.Add(new Cp(3));
shape.Text.Value.Add(new Txt("TextStyle_Bold_Italic_Underline\n"));
shape.Text.Value.Add(new Cp(4));
shape.Text.Value.Add(new Txt("TextStyle_Bold_Italic_Underline\n"));
shape.Text.Value.Add(new Cp(5));
shape.Text.Value.Add(new Txt("TextStyle_Bold_Italic_Underline"));

// Add formatting characters
shape.Chars.Add(new Aspose.Diagram.Char());
shape.Chars.Add(new Aspose.Diagram.Char());
shape.Chars.Add(new Aspose.Diagram.Char());
shape.Chars.Add(new Aspose.Diagram.Char());
shape.Chars.Add(new Aspose.Diagram.Char());
shape.Chars.Add(new Aspose.Diagram.Char());

// Set properties e.g. color, font, size and style etc.
shape.Chars[0].IX = 0;
shape.Chars[0].Color.Value = "#FF0000";
shape.Chars[0].Font.Value = 4;
shape.Chars[0].Size.Value = 0.12;
shape.Chars[0].Style.Value = StyleValue.Undefined;

// Set properties e.g. color, font, size and style etc.
shape.Chars[1].IX = 1;
shape.Chars[1].Color.Value = "#FF00FF";
shape.Chars[1].Font.Value = 4;
shape.Chars[1].Size.Value = 0.14;
shape.Chars[1].Style.Value = StyleValue.Bold | StyleValue.Italic;

// Set properties e.g. color, font, size and style etc.
shape.Chars[2].IX = 2;
shape.Chars[2].Color.Value = "#00FF00";
shape.Chars[2].Font.Value = 4;
shape.Chars[2].Size.Value = 0.16;
shape.Chars[2].Style.Value = StyleValue.Underline | StyleValue.Italic;

// Set properties e.g. color, font, size and style etc.
shape.Chars[3].IX = 3;
shape.Chars[3].Color.Value = "#3333FF";
shape.Chars[3].Font.Value = 4;
shape.Chars[3].Size.Value = 0.18;
shape.Chars[3].Style.Value = StyleValue.Bold | StyleValue.Italic | StyleValue.Underline;

// Set properties e.g. color, font, size and style etc.
shape.Chars[4].IX = 4;
shape.Chars[4].Color.Value = "#3333FF";
shape.Chars[4].Font.Value = 4;
shape.Chars[4].Size.Value = 0.20;
shape.Chars[4].Style.Value = StyleValue.Bold | StyleValue.Italic | StyleValue.Underline;

// Set properties e.g. color, font, size and style etc.
shape.Chars[5].IX = 5;
shape.Chars[5].Color.Value = "#3333FF";
shape.Chars[5].Font.Value = 4;
shape.Chars[5].Size.Value = 0.22;
shape.Chars[5].Style.Value = StyleValue.Bold | StyleValue.Italic | StyleValue.Underline;

}

@zkormos
Thanks for the sample code.
After an initial testing, I am able to reproduce the issue as you mentioned by using your sample code.
I found the height calculation of the shape has a deviation.

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): DIAGRAMNET-53244

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

The issues you have found earlier (filed as DIAGRAMNET-53244) have been fixed in this update. This message was posted using Bugs notification tool by philip.zhou