VerticalLineInfo CalcVerticalInfo(XFont font)
{
ParagraphFormat paragraphFormat = this.paragraph.Format;
LineSpacingRule spacingRule = paragraphFormat.LineSpacingRule;
XUnit lineHeight = 0;
XUnit descent = FontHandler.GetDescent(font);
descent = Math.Max(this.currentVerticalInfo.descent, descent);
XUnit singleLineSpace = font.GetHeight();
RenderInfo imageRenderInfo = this.CurrentImageRenderInfo;
if (imageRenderInfo != null)
singleLineSpace = singleLineSpace - FontHandler.GetAscent(font) + imageRenderInfo.LayoutInfo.ContentArea.Height;
XUnit inherentLineSpace = Math.Max(this.currentVerticalInfo.inherentlineSpace, singleLineSpace);
switch (spacingRule)
{
case LineSpacingRule.Single:
lineHeight = singleLineSpace;
break;
case LineSpacingRule.OnePtFive:
lineHeight = 1.5 * singleLineSpace;
break;
case LineSpacingRule.Double:
lineHeight = 2.0 * singleLineSpace;
break;
case LineSpacingRule.Multiple:
lineHeight = this.paragraph.Format.LineSpacing * singleLineSpace;
break;
case LineSpacingRule.AtLeast:
lineHeight = Math.Max(singleLineSpace, paragraph.Format.LineSpacing);
break;
case LineSpacingRule.Exactly:
lineHeight = new XUnit(paragraph.Format.LineSpacing);
inherentLineSpace = paragraph.Format.LineSpacing.Point;
break;
}
lineHeight = Math.Max(this.currentVerticalInfo.height, lineHeight);
if (this.MaxElementHeight > 0)
lineHeight = Math.Min(this.MaxElementHeight - Renderer.Tolerance, lineHeight);
return new VerticalLineInfo(lineHeight, descent, inherentLineSpace);
}