Calculates the height of the text in pixels (called workingHeight
, the offsetHeight minus top and bottom padding and border) and the number of lines the text uses. font-size and line-height have the same value for each test, padding varies but is always in multiples of the line-height.
Comparisons between Mozilla Firefox 1.5, Safari 2.02 and Opera 8.5 show that workingHeight = offsetHeight - paddingTop - paddingBottom - borderTop - borderBottom = lines * line-height. The Flash script only needs to know the number of lines and their height to render the text. This means that for tuning the font will be rendered with equal font-size for all elements subject to equal CSS rules. Width, however, is still an issue. If the text is wider than the allocated space on the page, it'll have to be wrapped. This could work quite well, however it might mean that the Flash will need an extra line.
This experiment does not yield proper results in Internet Explorer. See Deducing line-height in IE for a different experiment which does yield proper results.
This text normally fits on one line
This text normally fits on
two lines
This text normally fits on
two lines, with extra padding of two lines worth
This text normally fits on
two lines, with extra padding of four lines worth
This text normally
fits on
three lines