PointSize and Vertical Alignment

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF Generator for .NET (v4)  /  PointSize and Vertical Alignment

DynamicPDF Generator for .NET (v4) Forum

 Apr 01 2009 4:23 PM
I have a method that reduces the size of the font contained within a formatted text area until overflow no longer occurs. However, I noticed that the method GetRequiredHeight() returns a minimum of 13.8010006, even if the point size is 1. Could this be do to the line leading? I am using Auto leading, which always seems to return a value of 9.36. If the leading is set to Auto, shouldn't it be variable based on the point size? The definition I found for the auto leading equation is as follows:

(pointSize * .2 + pointSize) = leading

If the auto leading is not "auto-adjusting", would you recommend using the above equation to adjust it on the fly? Is there something I am missing to make it auto-adjust?

Consequently, any formatted text area with a height less than 14 is being reduced to a point size of 1, and rests at the bottom of the formatted text area, even it is top-aligned. See below:

============================ \
                              \__ FTA (12 pt height)
                              /
tiny text (1 pt height)      /
============================/

I appreciate any help in this matter.

Sincerely,
Matthew W. Abercrombie
 Apr 01 2009 4:51 PM
The diagram above did not display as I intended. The point size from the top horizontal rule to the bottom horizontal rule is 12 points.
 Apr 01 2009 5:01 PM
Posted by a ceTe Software moderator
Hello Matthew,

We will do some testing on our end and post the response tomorrow.

If
Ascender = 13pt
Descender = 4 pt
Leading = 13pt + 4pt = 17pt (the default)
Y = 100pt

The baseline of the first line is 100pt + 13pt (Y + Ascender) = 113pt.
The baseline or the second line is baseline of previous line + Leading = 113pt + 17pt = 130pt
The baseline or the third line is baseline of previous line + Leading = 130pt + 17pt = 147pt
 
So in your case to calculate the Leading, you will have to add the ascender, descender and the line gap.

Leading = ceTe.DynamicPDF.Font.Courier.GetAscender(10) - ceTe.DynamicPDF.Font.Courier.GetDescender(10) + ceTe.DynamicPDF.Font.Courier.LineGap(10);

The LineGap is the distance between the baseline of first line and the baseline of the second line.

Thanks,
ceTe Software Support Team
 Apr 08 2009 10:38 AM
Posted by a ceTe Software moderator
Hello Matthew,

The behavior you are seeing is because of the different font size and PointSize you are using in the FormattedTextArea.

The GetRequiredHeight will calculate the height using the maximum size from the point size and font size given in the FormattedTextArea constructor. If you have given the font size as 12 in the formatted text area and even if you use a PointSize of 1 for the text inside the formatted text area, the height will be calculated using the font size 12 given in the constructor. Because the formatted text area may have some other text which needs this size. This is the reason for seeing the 13.801 for the GetRequiredHeight method.

You are not seeing the alignment is also for the same reason. If you give a font size of 1 in the formatted text area constructor then you can see the alignment and the Height also properly for the point size what ever you are specifying. But the default size for the text for which you do not specify the point size will be 1 as you have this in the constructor.

Thanks,
ceTe Software Support Team.
 Apr 08 2009 10:42 AM
I believe I understand now.

I was using 12pt in the constructor, and that is what the GetRequiredHeight was going by for its minimum value. By setting the default height to 1pt in the constructor, I believe my font reduction algorithm will work as intended.

Thank you for your help.

All times are US Eastern Standard time. The time now is 2:24 AM.