Skip to main content
March 3, 2009
Question

Text height/overlapping bug

  • March 3, 2009
  • 2 replies
  • 1267 views
We are having a problem where part of a previous textline is overlapping the next line. The tails of letters like "j" and "g" and "y" are overlapping the next line when we have different font sizes. From our text metrics debugging, the line height seems to be off by the descent amount. I am using build 5011. Here is sample code to recreate the problem.
This topic has been closed for replies.

2 replies

March 4, 2009
In InDesign, I can turn off this feature (either with the "Paragraph" toolbar by clicking the "Align to baseline grid" button, or with "Paragraph Styles" under "Indents and Spacing", by setting "Align to Grid=All Lines"). Is there (or will there) be something similar in the TextLayoutFramework.
March 10, 2009
I was about to post this as a possible bug also, but I guess Robin's answer would make sense. The issue I was running into is that the 'lineHeight' style is not being observed for the first line. I could potentially attempt to manage the 'firstBaselineOffset' style, but it seems like this could get messy if user splits that first line paragraph or inserts lines above it...

If I have some text and I know exactly how tall I want that line to be, can I just set both lineHeight and firstBaselineOffset for that Para/Span? I guess my question is more about how firstBaselineOffset works. Does that only get applied if the corresponding text line is the first line in a container, otherwise lineHeight is used?

Thanks in advance,
Brent
Adobe Employee
March 4, 2009
I think this is not a bug, but a byproduct of the fact that TLF is doing baseline leading. TLF is placing the first line based on the largest ascent on the line. You can alter the placement of this line down by changing the value of the firstBaselineOffset property. The second line is placed according to its lineHeight propery (also sometimes called the leading). In this case, the lineHeight is the default value, 120% of the largest fontSize, which with the fontSize=12 will be 14.4 pixels. So the second line is placed so that its baseline is 14.4 pixels below the baseline of the first line. In this case, that's too tight.

There are a couple of things you could do to space the paragraphs out further. You could assign a larger lineHeight to the second line, either a larger percentage or absolute pixel value. Or you could add space between the two paragraphs by assigning a positive value to the first paragraph's marginBottom. Or you could set the marginTop of the second paragraph.

Baseline leading is a different model from that used by most word processors, including Microsoft Word. It is used in applications such as Adobe InDesign and Illustrator. The advantage is that it gives the user more control over how the lines are placed. The disadvantage is cases like these where it doesn't do the right thing by default.

I hope that one of these proposals is a viable solution to your problem.

Thanks!