primaryLineHeight static method

double primaryLineHeight(
  1. TextStyle style
)

Primary-face line height ≈ FreeType ascent + descent (Alacritty metrics.line_height without offset). Ignores style's height multiplier and fontFamilyFallback — only the primary family.

Implementation

static double primaryLineHeight(TextStyle style) {
  final fontSize = style.fontSize ?? 14.0;
  final probe = TextPainter(
    text: TextSpan(
      // Accents + descender so ascent/descent are populated.
      text: 'Éy',
      style: TextStyle(
        fontFamily: style.fontFamily,
        fontSize: fontSize,
        fontWeight: style.fontWeight,
        fontStyle: style.fontStyle,
      ),
    ),
    textDirection: TextDirection.ltr,
  )..layout();
  final lines = probe.computeLineMetrics();
  if (lines.isEmpty) return fontSize;
  final m = lines.first;
  final h = m.ascent + m.descent;
  return h > 0 ? h : fontSize;
}