normalizeSize
A utility function to normalize font sizes based on device font scale
Installation
npx expo-app-ui add normalizeSizeUsage
import { normalizeSize } from "@/helper/normalizeSize";Function Signature
normalizeSize(size: number): numberParameters
| Parameter | Type | Description |
|---|---|---|
| size | number | The base font size to normalize |
Returns
| Type | Description |
|---|---|
| number | The normalized font size |
Examples
Basic Usage
const fontSize = normalizeSize(16);
// On normal devices: returns 16
// On devices with large text: returns ~13.6In StyleSheet
const styles = StyleSheet.create({
text: {
fontSize: normalizeSize(18),
},
});Features
- Automatic font scale detection
- Adjusts for accessibility settings
- Prevents text from becoming too large