Closed vaukalak closed 7 years ago
hi @vaukalak ,
so the goal is to limit font scaling, correct?
Maybe just support allowFontScaling
for Android instead of introducing maxFontSize
(that does not present in RN and may confuse people) ?
hey @vitalets,
Right now my issue is on ios, and allowFontScaling
will just on / off possibility to scale fonts in user preferences. I'd like to provide a functionality that will allow to limit scaling. right now on ios user can select x4 scale for fonts, wich breaks layout. I'd like to have API that will mention: allow to scale up this text component, but until certain value. this could be probably called maxFontScale
instead of maxFontSize
thoughts?
I got the point. I think using value as a function should do exactly that:
{
fontSize: () => EStyleSheet.value('1rem') * Math.min(2, PixelRatio.getFontScale())
}
@vitalets yeah, but I think it's gonna be something like:
const scaledFont = (value, maxScale = PixelRatio.getFontScale()) => {
const calculated = EStyleSheet.value(value);
return calculated / (PixelRatio.getFontScale() / maxScale);
}
Do you want that in your lib, or you think that should be a separate module?
For me it looks more as separate module until we get many requests for that.
On ios it's possible to change font scale in accessibility settings. Right now you can control if to allow the font scaling at all in the specific text component. anyway you can't set the max scale value for that text. Hopefully there's pixel ratio api which seems to allow query for current font scale.
That said, I think there should be an Api to set the max font size in the specific text field:
Which should be equivalent of
Thanks.