Font sizes on iphone6 and iphone4 are particularly small. It would be good to use a "resizing" function to help with this across pixel ratios.
If you would like me to submit a PR please let me know.
const React = require('react-native')
const {
PixelRatio
} = React;
const pixelRatio = PixelRatio.get();
const normalize = (size) => {
if (pixelRatio == 2) {
return size * 1.15;
}
if (pixelRatio == 3) {
return size * 1.35;
}
return size * pixelRatio;
}
export default normalize;
Usage:
import normalize from '../helpers/normalizeText';
fontSize: normalize(14)
Code example from: https://jsfiddle.net/97ty7yjk/ and https://stackoverflow.com/questions/34837342/font-size-on-iphone-6s-plus.
Hello @xiaoneng , this would be a great addition for the project. Feel free to go ahead and submit a pr if you have the time, if not I will put this on my todo list! Thanks.
@xiaoneng How did you come to the numbers 1.15 and 1.35 for pixel ratios 2 and 3, respectively? They seem arbitrary
This was to scratch my own itch and meant as a starter for covering the gamut of pixel ratios / screen sizes combos out there. By all means fork, fix, pull request.
Most helpful comment
@xiaoneng How did you come to the numbers 1.15 and 1.35 for pixel ratios 2 and 3, respectively? They seem arbitrary