visualHeightScaleForFontFamily function

double visualHeightScaleForFontFamily(
  1. String? fontFamily
)

Scale for normal text-theme roles relative to the reference font.

Uses a composite font-height metric based on rendered phrase height, x-height, and average phrase character advance. Intended for display/headline/body/label role sizing, not for matching monospace code to prose.

Implementation

double visualHeightScaleForFontFamily(String? fontFamily) {
  final visualHeightEm = rasterVisualHeightEmForFontFamily(fontFamily);
  if (visualHeightEm == null || visualHeightEm <= 0) return 1.0;
  return kReferenceRasterVisualHeightEm / visualHeightEm;
}