Commit Graph

9 Commits

Author SHA1 Message Date
Adam Gleitman 11c8bf3137 Add Dynamic Type support for iOS (Paper and Fabric) (#35017)
Summary:
This adds Dynamic Type support in iOS as described [here](https://github.com/react-native-community/discussions-and-proposals/issues/519).

`Text` elements have a new prop, `dynamicTypeRamp`, that allows users to specify which font ramp a particular `Text` element should take on as the OS's accessibility setting for text size. The different types line up with different values of `UIFontTextStyle`. If not specified, we default to the current behavior.

~~For the moment, this change is only for Paper. I tried applying a corresponding change to Fabric by adding an additional field to [`facebook::react::TextAttributes`](https://github.com/facebook/react-native/blob/main/ReactCommon/react/renderer/attributedstring/TextAttributes.h) and changing [`RCTEffectiveFontSizeMultiplierFromTextAttributes`](https://github.com/facebook/react-native/blob/afb124dcf0cdf0db525acc7cfd2cea2742c64068/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTAttributedTextUtils.mm#L79-L84) to use that new field, but in the process I discovered that this function doesn't seem to ever get called, hence [this bug](https://github.com/facebook/react-native/issues/34990).~~

## Changelog

[iOS] [Added] - Dynamic Type support

Pull Request resolved: https://github.com/facebook/react-native/pull/35017

Test Plan:
Validated with a test page in RNTester. Screenshots follow:

A) Default text size
B) Largest non-accessibility text size
C) Largest accessibility text size, split across two screenshots due to size

| A | B | C |
|-|-|-|
| ![Simulator Screen Shot - iPad (9th generation) - 2022-10-18 at 16 17 08](https://user-images.githubusercontent.com/717674/196562746-c8bbf53d-3c70-4e55-8600-0cfed8aacf5d.png) | ![Simulator Screen Shot - iPad (9th generation) - 2022-10-18 at 16 17 55](https://user-images.githubusercontent.com/717674/196563051-68bb0e34-c573-47ed-8c19-58ae45a7ce2b.png) | ![Simulator Screen Shot - iPad (9th generation) - 2022-10-18 at 16 18 33](https://user-images.githubusercontent.com/717674/196563185-61ede5ee-e79e-4af5-84a7-8f1e230a25f8.png) |
||| ![Simulator Screen Shot - iPad (9th generation) - 2022-10-18 at 16 18 42](https://user-images.githubusercontent.com/717674/196563208-2242efa2-5f24-466d-80f5-eb57a7678a67.png) |

Reviewed By: sammy-SC

Differential Revision: D40779346

Pulled By: NickGerleman

fbshipit-source-id: efc7a8e9810a93afc82c5def97af15a2e8453d90
2022-11-15 19:03:37 -08:00
David Vacca 9578c2cadf Ship large meassure cache in all platforms
Summary:
Ship large meassure cache in all platforms

changelog: [internal] internal

Reviewed By: sammy-SC

Differential Revision: D40356835

fbshipit-source-id: 315862d7aa705e83086e102e20fe2c20fb3210b2
2022-10-18 13:32:03 -07:00
Andres Suarez 8bd3edec88 Update copyright headers from Facebook to Meta
Reviewed By: aaronabramov

Differential Revision: D33367752

fbshipit-source-id: 4ce94d184485e5ee0a62cf67ad2d3ba16e285c8f
2021-12-30 15:11:21 -08:00
Valentin Shergin 5f1012c6f2 Back out "Fix incorrect Height in Text components"
Summary:
Original commit changeset: 3e769e0ca35b

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D26696638

fbshipit-source-id: 1dd432b35505be8e1b437a4578342cf84a6a5134
2021-02-28 08:47:05 -08:00
David Vacca b3cdf8cd7e Fix incorrect Height in Text components
Summary:
This diff fixes a bug in the calculation of layout for text components

The rootcause of the bug is that fabric is not taking into consideration height constraints as part of the cache for text measurments.
The title text was being measured with a specific height constraint (22px) at the begining of the render, later there was a re-measure for the same Text component with a different height constraint, but fabric was reusing the result of the first calculation instead of re-measuring the text.

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D26676716

fbshipit-source-id: 3e769e0ca35b3e363b96d3a6d1626a091eaad908
2021-02-25 17:57:21 -08:00
Samuel Susla c1af56df71 Wire call from C++ to Java to get lines measurements
Summary: Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D23782998

fbshipit-source-id: fa9bda274c024d5bbd3ca24f394b5d76f8c07ad2
2020-09-22 01:53:24 -07:00
Samuel Susla 412fc7d324 Prevent calling onTextLayout with the same value
Summary:
Changelog: [internal]

In D23648430 (https://github.com/facebook/react-native/commit/a315e4cd30e4b8da841f587650146a62c868f67d) I made a mistake. I prevented calling `onTextLayout` unless there are attachments in the component. It fixed the problem because I unintentionally prevented `onTextLayout`  to be called. Therefore, changes from D23648430 (https://github.com/facebook/react-native/commit/a315e4cd30e4b8da841f587650146a62c868f67d) need to be reverted.

To prevent infinite loop in `onTextLayout`, ParagraphEventEmitter checks if `linesMeasurements` have changed before dispatching it to JS.

Reviewed By: shergin

Differential Revision: D23782717

fbshipit-source-id: 0e84ae4f46d79ce0cf4c7340cd32be6f562ae179
2020-09-20 08:18:55 -07:00
Samuel Susla 8d6b41e9bc Add support for onTextLayout in Text
Summary:
Changelog: [Internal]

Add `Text.onTextLayout` implementation

Reviewed By: JoshuaGross

Differential Revision: D22865139

fbshipit-source-id: 563084754ebdc9fb23463a306c526b97c61f85ec
2020-08-10 05:42:20 -07:00
David Vacca 3093010ea5 move fabric to ReactCommon/react/renderer
Summary:
This diff moves fabric C++ code from ReactCommon/fabric to ReactCommon/react/renderer
As part of this diff I also refactored components, codegen and callsites on CatalystApp, FB4A and venice

Script: P137350694

changelog: [internal] internal refactor

Reviewed By: fkgozali

Differential Revision: D22852139

fbshipit-source-id: f85310ba858b6afd81abfd9cbe6d70b28eca7415
2020-07-31 13:34:29 -07:00