Skip to content

Commit 6255c6b

Browse files
committed
Fix some errors in the Readme
1 parent 6cb4dd3 commit 6255c6b

File tree

2 files changed

+43
-17
lines changed

2 files changed

+43
-17
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
44

5+
## [Unreleased]
6+
7+
### Fixed
8+
- Some error in the README
9+
510
## [2.0.1] - 2018-08-22
611

712
### Fixed

README.md

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Both, width and height, are practically the same as those received in the `onLay
3131

3232
In addition, the library includes functions to obtain information about the fonts visible to the App.
3333

34-
rnTextSize is WIP, but if it has helped you, please support my work with a star or [buy me a coffee](https://www.buymeacoffee.com/aMarCruz).
34+
rnTextSize is WIP, but if it has helped you, please support my work with a star :star2: or [buy me a coffee](https://www.buymeacoffee.com/aMarCruz).
3535

3636
---
3737
**IMPORTANT:**
@@ -45,7 +45,7 @@ rnTextSize is WIP, but if it has helped you, please support my work with a star
4545
- React Native v0.52.0 or later
4646
- Targets Androind API 16 and iOS 9.0
4747

48-
The [sample App](https://github.com/aMarCruz/react-native-text-size/tree/master/example) uses RN v0.52.0, which is the minimum version supported by rnTextSize, but you can change it (See your README before testing it).
48+
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 you can change it (See your README before testing it).
4949

5050
To take advantage of features such as `letterSpacing`, and better support for the most modern devices, use RN v0.55 or above.
5151

@@ -58,12 +58,24 @@ $ yarn add react-native-text-size
5858
$ react-native link react-native-text-size
5959
```
6060

61-
If you are using Gradle plugin 3 or later, don't forget to change the `compile` directive to `implementation` in the dependencies block of the android/app/build.gradle file.
61+
If you are using Gradle 4 or later, don't forget to change the `compile` directive to `implementation` in the dependencies block of the android/app/build.gradle file.
6262

6363
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.
6464

6565
# API
6666

67+
- [`measure`](#measure)
68+
69+
- [`flatHeights`](#flatheights)
70+
71+
- [`specsForTextStyles`](#specsfortextstyles)
72+
73+
- [`fontFromSpecs`](#fontfromspecs)
74+
75+
- [`fontFamilyNames`](#fontfamilynames)
76+
77+
- [`fontNamesForFamilyName`](#fontnamesforfamilyname)
78+
6779
## `measure`
6880

6981
```js
@@ -74,7 +86,7 @@ This function measures the text as RN does and its result is consistent\* with t
7486

7587
If you provide the `width`, the measurement will apply automatic wrapping in addition to the explicit line breaks.
7688

77-
\* _On iOS, RN takes into account the absolute position on the screen to calculate the dimensions. rnTextSize can't do that and both width and height can have a difference of uo to 1 pixel (not point)._
89+
\* _There may be some inconsistencies in iOS, see this [Know Issue](#incorrent-height-ios) to know more._
7890

7991
**NOTE:**
8092

@@ -88,18 +100,18 @@ Property | Type | Default | Notes
88100
---------- | ------ | -------- | ------
89101
text | string | (none) | This is the only required parameter and may include _emojis_ or be empty, but it can not be `null`. If this is an empty string the resulting `width` will be zero.
90102
width | number | Infinity | Restrict the width. The resulting height will vary depending on the automatic flow of the text.
91-
usePreciseWidth | boolean | false | If `true`, request an exact `width` and the value of `lastLineWidth` (iOS always returns the exact width).<br>You can see the effect of this flag in the [sample App](https://github.com/aMarCruz/react-native-text-size/tree/master/example).
103+
usePreciseWidth | boolean | false | If `true`, request an exact `width` and the value of `lastLineWidth` (iOS always returns the exact width).<br>You can see the effect of this flag in the [sample App](https://github.com/aMarCruz/rn-text-size-sample-app).
92104
fontFamily | string | OS dependent | The default is the same applied by React Native: Roboto in Android, San Francisco in iOS.<br>**Note:** Device manufacturer or custom ROM can change the default font.
93105
fontWeight | string | 'normal' | On android, numeric ranges has no granularity and '500' to '900' becomes 'bold', but you can use fonts of specific weights, like "sans-serif-medium".
94106
fontSize | number | 14 | The default value comes from RN.
95107
fontStyle | string | 'normal' | One of "normal" or "italic".
96-
fontVariant | array | (none) | _iOS only_
108+
fontVariant | array | (none) | _iOS only_
97109
allowFontScaling | boolean | true | To respect the user' setting of large fonts (i.e. use SP units).
98110
letterSpacing | number | (none) | Additional spacing between characters (a.k.a. `tracking`).<br>**Note:** In iOS a zero cancels automatic kerning.<br>_All iOS, Android with API 21+ and RN 0.55+_
99111
includeFontPadding | boolean | true | Include additional top and bottom padding, to avoid clipping certain characters.<br>_Android only_
100112
textBreakStrategy | string | 'highQuality' | One of 'simple', 'balanced', or 'highQuality'.<br>_Android only, with API 23+_
101113

102-
The [sample App](https://github.com/aMarCruz/react-native-text-size/tree/master/example) shows interactively the effect of these parameters on the screen.
114+
The [sample App](https://github.com/aMarCruz/rn-text-size-sample-app) shows interactively the effect of these parameters on the screen.
103115

104116
**TSMeasureResult**
105117

@@ -172,8 +184,6 @@ class Test extends Component<Props, State> {
172184
}
173185
```
174186

175-
---
176-
177187
## `flatHeights`
178188

179189
```ts
@@ -221,12 +231,11 @@ The result is a Promise that resolves to an array with the height of each block
221231

222232
Unlike measure, `null` elements returns 0 without generating error, and empty strings returns the same height that RN assigns to empty `<Text>` components.
223233

224-
---
225234

226235
## `specsForTextStyles`
227236

228237
```ts
229-
specsForTextStyles(): Promise<{ [key: string]: TSFontSpec }>
238+
specsForTextStyles(): Promise<{ [key: string]: TSFontForStyle }>
230239
```
231240

232241
Get system font information for the running OS.
@@ -250,7 +259,6 @@ To know the key names, please see [Keys from specsForTextStyles](https://github.
250259

251260
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.
252261

253-
---
254262

255263
## `fontFromSpecs`
256264

@@ -307,11 +315,10 @@ See more in:
307315

308316
**Tip**
309317

310-
> Avoid `allowsFontScaling: false`.
311-
>
312-
> 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.
318+
Avoid `allowsFontScaling: false`.
319+
320+
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.
313321

314-
---
315322

316323
## `fontFamilyNames`
317324

@@ -327,7 +334,6 @@ On Android the result is hard-coded for the system fonts and complemented dynami
327334

328335
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.
329336

330-
---
331337

332338
## `fontNamesForFamilyName`
333339

@@ -344,8 +350,22 @@ You can use the rnTextSize's `fontFamilyNames` function to get an array of the a
344350

345351
## Known Issues
346352

353+
#### Incorrent height (iOS)
354+
355+
On iOS, RN takes into account the absolute position on the screen to calculate the dimensions. rnTextSize can't do that and both, width and height, can have a difference of up to 1 pixel (not point).
356+
357+
#### letterSpacing not scaling (iOS)
358+
359+
RN does not support the [Dynamic Type Sizes](https://developer.apple.com/design/human-interface-guidelines/ios/visual-design/typography#dynamic-type-sizes), but does an excellent job imitating this feature through `allowFontScaling` ...except for `letterSpacing` that is not scaled.
360+
361+
I hope that a future version of RN solves this issue.
362+
363+
#### lineHeight Support
364+
347365
Although rnTextSize provides the resulting `lineHeight` in some functions, it does not support it as a parameter because RN uses a non-standard algorithm to set it. I recommend you do not use `lineHeight` unless it is strictly necessary, but if you use it, try to make it 30% or more than the font size, or use rnTextSize [`fontFromSpecs`](#fontfromspecs) method if you want more precision.
348366

367+
#### Nexted Text
368+
349369
Nested `<Text>` components (or with images inside) can be rasterized with dimensions different from those calculated, rnTextSize does not accept multiple sizes in the text.
350370

351371

@@ -370,6 +390,7 @@ Feedback, PRs stars, and smiles are also welcome.
370390

371391
Thanks for your support!
372392

393+
373394
## License
374395

375396
The [BSD 2-Clause](LICENCE) "Simplified" License.

0 commit comments

Comments
 (0)