qcfFontSize static method
Compute dynamic font size for QCF (downloaded fonts) pages.
- Uses Layout constraints width when available, else MediaQuery width.
- Adjusts for orientation and clamps to reasonable bounds.
Implementation
static double qcfFontSize({
required BuildContext context,
required int pageIndex,
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 size = 100.0 * ratio;
// In landscape we usually need a smaller size to avoid overflow
if (orientation == Orientation.landscape) {
size *= 0.82;
}
// Minor adjustment for the first two pages (Fatihah/Baqarah start)
if (pageIndex == 0 || pageIndex == 1) {
size *= 0.96;
}
// Clamp to safe bounds
return size.clamp(78.0, 120.0);
}