expressiveTextLayout function
style and the text-height behaviour that lay it out as Compose does:
unchanged with the default behaviour when its line height covers Roboto
Flex's height, else the font's own ascent over the first line and
descent under the last. Scale-free: text scaling multiplies the size and
the line height alike.
In the second case the style's leading is distributed proportionally:
Flutter 3.47's paragraph ignores applyHeightToFirstAscent and
applyHeightToLastDescent under TextLeadingDistribution.even
(measured: a two-line display medium stays 104 dp tall). Proportional
leading moves only the boundary between inner lines, never a baseline,
so the result matches Compose's centred split (the oracle's
type/display-* scenes hold it to 0.2 dp).
Implementation
(TextStyle, TextHeightBehavior) expressiveTextLayout(TextStyle style) {
final height = style.height;
const font =
ExpressiveRobotoFlexMetrics.ascent +
ExpressiveRobotoFlexMetrics.descent +
ExpressiveRobotoFlexMetrics.lineGap;
if (height == null || height >= font) return (style, _applied);
return (
style.copyWith(leadingDistribution: TextLeadingDistribution.proportional),
_fontEdges,
);
}