A React Native library for accurately measuring text dimensions and retrieving font information before rendering.
React Native Text Size is a library that allows developers to measure text dimensions and retrieve font information programmatically before rendering in React Native apps. It solves the problem of dynamic layout calculation by providing accurate width, height, and line details, ensuring UI components adapt correctly to text content across Android and iOS.
React Native developers building dynamic UIs, custom text components, or list views (e.g., FlatList) that require precise text sizing and layout optimization.
Developers choose React Native Text Size for its accuracy matching React Native's rendering, performance-optimized batch operations, and comprehensive font metadata—saving time over manual calculations or inconsistent workarounds.
Measure text accurately before laying it out and get font information from your App.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Returns width and height that closely match React Native's own onLayout event, ensuring layout consistency. The README states it's 'practically the same as those received from the onLayout event of a <Text> component.'
The flatHeights function is optimized for measuring multiple text strings efficiently, with tests showing speed improvements from 49,624 ms to 1,091 ms on Android for 5,000 blocks, as noted in the README.
Provides detailed font information including ascender, descender, line height, and system font specs through functions like fontFromSpecs and specsForTextStyles, useful for typography systems.
Manages platform-specific nuances such as font padding on Android and scaling issues, helping developers create UIs that behave consistently on both iOS and Android, as outlined in the features.
Known issues include inconsistent width calculations between iOS and Android, and up to 1 pixel height discrepancies on iOS, as admitted in the README's 'Known Issues' section.
The author has publicly stated they cannot dedicate time to maintenance and are seeking a new maintainer, which could lead to unresolved bugs or lack of future updates.
Does not handle nested Text components or images inside text, which can result in different dimensions from actual rendering, limiting its use in complex text layouts, as mentioned in the README.
Some features like fontVariant are iOS-only, and letterSpacing does not scale with allowFontScaling on iOS, requiring workarounds for full cross-platform compatibility, per the 'Known Issues'.