Different font sizes for different reading distances are currently achievable by assuming a device’s form factor using @media queries. Long term, this is probably not ideal — that is, until reading distance-detection techniques, like the one you are testing right now, become more feasible. In the meantime, use Size Calculator by Nick Sherman and Chris Lewis to calculate the physical or perceived f