hafsFontSize static method

double hafsFontSize({
  1. required BuildContext context,
  2. double? maxWidth,
})

Compute dynamic base font size for Hafs (text-scale mode).

Implementation

static double hafsFontSize({
  required BuildContext context,
  double? maxWidth,
}) {
  final media = MediaQuery.of(context);
  final width =
      (maxWidth != null && maxWidth > 0) ? maxWidth : media.size.width;
  final orientation = media.orientation;

  double ratio = (width / _designWidth).clamp(0.6, 1.6);
  double base = 22.0 * ratio;
  if (orientation == Orientation.landscape) base *= 0.9;
  return base.clamp(16.0, 28.0);
}