You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+19-23Lines changed: 19 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,7 +27,7 @@ The other one gets detailed information about a block of text:
27
27
- The number of lines.
28
28
- The width of the last line, if required, useful to save space with "See more..." style labels or time stamps.
29
29
30
-
Both, width and height, are practically the same as those received in the `onLayout` event of a `<Text>` component with the same properties.
30
+
Both, width and height, are practically the same as those received from the `onLayout` event of a `<Text>` component with the same properties.
31
31
32
32
In addition, the library includes functions to obtain information about the fonts visible to the App.
33
33
@@ -38,7 +38,7 @@ rnTextSize is WIP, but if it has helped you, please support my work with a star
38
38
39
39
**rnTextSize (react-native-text-size) v2.0 is a complete refactoring, before using it, please unlink the previous version.**
40
40
41
-
**If `react-native unlink` fails, it reverses the changes described in [Manual Installation](https://github.com/aMarCruz/react-native-text-size/wiki/Manual-Installation).**
41
+
**If `react-native unlink` fails, please reverse the changes described in [Manual Installation](https://github.com/aMarCruz/react-native-text-size/wiki/Manual-Installation).**
42
42
43
43
---
44
44
@@ -47,7 +47,7 @@ rnTextSize is WIP, but if it has helped you, please support my work with a star
47
47
- React Native v0.52.0 or later
48
48
- Targets Android API 16 and iOS 9.0
49
49
50
-
The [sample App](https://github.com/aMarCruz/rn-text-size-sample-app) uses RN v0.52.0, which is the minimum version supported by rnTextSize but, to take advantage of features such as `letterSpacing` and better support for the most modern devices, use RN v0.55 or above.
50
+
The [sample App](https://github.com/aMarCruz/rn-text-size-sample-app) uses RN v0.52.0, the minimum supported version but, to take advantage of features such as `letterSpacing` and better support for the most modern devices, use RN v0.55 or above.
51
51
52
52
## Installation
53
53
@@ -60,7 +60,7 @@ If you are using Gradle 4 or later, don't forget to change the `compile` directi
60
60
61
61
See [Manual Installation](https://github.com/aMarCruz/react-native-text-size/wiki/Manual-Installation) on the Wiki as an alternative if you have problems with automatic installation.
62
62
63
-
# API
63
+
##API
64
64
65
65
-[`measure`](#measure)
66
66
@@ -74,7 +74,7 @@ See [Manual Installation](https://github.com/aMarCruz/react-native-text-size/wik
@@ -88,7 +88,7 @@ If you provide the `width`, the measurement will apply automatic wrapping in add
88
88
89
89
**NOTE:**
90
90
91
-
Although this function is accurate and provides complete information, it can be heavy if the text is a lot, like the one that can be displayed in a FlatList. For these cases, it is better to use [`flatHeights`](#flatheights), which is optimized fotr those cases.
91
+
Although this function is accurate and provides complete information, it can be heavy if the text is a lot, like the one that can be displayed in a FlatList. For these cases, better to use [`flatHeights`](#flatheights), which is optimized for batch processing.
92
92
93
93
<aname="tsmeasureparams"></a>**TSMeasureParams**
94
94
@@ -182,15 +182,15 @@ class Test extends Component<Props, State> {
Calculate the height of each of the strings in an array.
192
192
193
-
This is an alternative to `measure` designed for cases in which you have to calculate the height of numerous text blocks with common characteristics (width, font, etc), a Typical case in the`<FlatList>`.
193
+
This is an alternative to `measure` designed for cases in which you have to calculate the height of numerous text blocks with common characteristics (width, font, etc), a Typical case with`<FlatList>`.
194
194
195
195
The measurement uses the same algorithm as `measure` but it returns only the height of each block and, by avoiding multiple steps through the bridge, it is faster... _much faster_ on Android!
196
196
@@ -205,11 +205,7 @@ In the future I will prepare an example of its use with FlatList and multiple st
205
205
206
206
**TSHeightsParams**
207
207
208
-
This is an object similar to the one received by measure, with the difference that the text property is an array of strings, and the usePreciseWidth property is ignored.
209
-
210
-
The result is an array with the height of each block, in the same order was given.
211
-
212
-
This is an object similar to the one received by `measure`, but the `text` property is an array of strings and the `usePreciseWidth` property is ignored.
208
+
This is an object similar to the one you pass to `measure`, but the `text` property is an array of strings and the `usePreciseWidth` property is ignored.
213
209
214
210
Property | Type | Default
215
211
---------- | ------ | --------
@@ -225,12 +221,12 @@ letterSpacing | number | (none)
225
221
includeFontPadding | boolean | true
226
222
textBreakStrategy | string | 'highQuality'
227
223
228
-
The result is a Promise that resolves to an array with the height of each block (_SP_), in the same order in which they were received.
224
+
The result is a Promise that is resolves with an array with the height of each block (_SP_), in the same order in which the blocks were received.
229
225
230
-
Unlike measure, `null` elements returns 0 without generating error, and empty strings returns the same height that RN assigns to empty `<Text>` components.
226
+
Unlike measure, `null` elements returns 0 without generating error, and empty strings returns the same height that RN assigns to empty `<Text>` components (the difference of the result between `null` and empty is intentional).
fontFamily | string | System family name or font face.
250
246
fontSize | number | Font size in _SP_ (unscaled).
251
-
fontStyle | TSFontStyle | Only if 'italic', undefined for 'normal' style.
252
-
fontWeight | TSFontWeight | Undefined if the font weight is 'normal'.
253
-
fontVariant | TSFontVariant[] or null | _iOS only_.
247
+
fontStyle | TSFontStyle | Only if 'italic', undefined if the style is 'normal'.
248
+
fontWeight | TSFontWeight | Only if 'bold', undefined if the weight is 'normal'.
249
+
fontVariant | TSFontVariant[] or null | _iOS only_. Currently, no style includes this property.
254
250
letterSpacing | number | Omitted if running on Android with RN lower than 0.55
255
251
256
252
To know the key names, please see [Keys from specsForTextStyles](https://github.com/aMarCruz/react-native-text-size/wiki/Keys-from-specsForTextStyles) the Wiki.
257
253
258
254
I have not tried to normalize these keys since, with the exception of 2 or 3, they have a different interpretation in each OS. You will know how to use them to create custom styles according to your needs.
When setting the `fontSize` and `lineHeight` properties of `<Text>` and `<TextInput>`, if you omit, or set `allowFontScaling:true`, React Native performs the conversion and scaling automatically.
319
315
320
316
321
-
## `fontFamilyNames`
317
+
## fontFamilyNames
322
318
323
319
```ts
324
320
fontFamilyNames(): Promise<string[]>
@@ -333,7 +329,7 @@ On Android the result is hard-coded for the system fonts and complemented dynami
333
329
See [About Android Fonts](https://github.com/aMarCruz/react-native-text-size/wiki/About-Android-Fonts) and [Custom Fonts](https://github.com/aMarCruz/react-native-text-size/wiki/Custom-Fonts) in the Wiki to know more about this list.
0 commit comments