-
Notifications
You must be signed in to change notification settings - Fork 24.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial implementation of adjustsFontSizeToFit. #4026
Conversation
It had been way too long to fix it up myself, so I've reopened the PR. Here's the original. #2327 |
By analyzing the blame information on this pull request, we identified @nicklockwood, @sahrens and @a2 to be potential reviewers. |
This should be stable enough to merge now. |
24d1536
to
ee8f53f
Compare
Keeping this squashed on master led to a missed file. Corrected. |
@MattFoley updated the pull request. |
@nicklockwood, @sahrens, @a2 Correct me if I'm wrong, but the tests failing after my last commit/squash are not due to my code changes, correct? |
Cool :) |
Did something go wrong with the merge/rebase? The Also, you don't seem to have added the new props to |
I think that's just misunderstanding on my part, and the age of this PR. Let me remove them from I was assuming that RCTTextManager just needed the two |
RCT_EXPORT_SHADOW_PROPERTY exports properties on the shadow view. To export properties on the view you need RCT_EXPORT_VIEW_PROPERTY. I'm not sure how this could ever have worked in its current form. |
Miracle of science I suppose. |
Are you sure that RCT_EXPORT_VIEW_PROPERTY is correct in this instance? It's not used for RCTText at all. (I said project originally, I meant the RCTText class and related.) |
You know, I think I see part of what's missing. |
ee8f53f
to
ae5815d
Compare
@MattFoley updated the pull request. |
@MattFoley thanks, that makes more sense. Is there any reason that this resizing logic can't be implemented on the shadow view though? It seems like it only relies on the view frame, which is calculated on the shadow side. The reason we have this thread architecture is because calculating text layout is fairly expensive, so we do it off the main thread. But it seems like we lose the benefit of that if we then re-calculate it on the main thread in order to do the size adjustment. |
That makes sense. I think I'm mainly doing it on the main thread now so that I knew the font was only modified after the frame was completely set for the view. I'm trying to move it out to the RCTextShadowView now without much luck yet. |
Ah, immediately after typing that I figured out what I was doing wrong. Give me a bit and I'll have this cleaned up and moved out to RCTShadowText. |
ae5815d
to
4f8c401
Compare
@MattFoley updated the pull request. |
4f8c401
to
6d1d0f6
Compare
@MattFoley updated the pull request. |
This looks great, thanks! @facebook-github-bot import |
I'm going to run some more in depth tests on this @nicklockwood with some of my own projects that are using this, just to make sure everything is solid on master. But yay! 🎉 |
Thanks for importing. If you are an FB employee go to https://our.intern.facebook.com/intern/opensource/github/pull_request/1504537549873434/int_phab to review. |
added @platform iOS Building UIExplorer Example, adding back in height error margin requirement, and add in RCTMeasure call.
Note, I had to update this PR to fix a failing test due to a previous rebase. |
@facebook-github-bot shipit |
@MattFoley thank you SO much for sticking with this for so long. Sorry it took so long to get it merged! |
Thanks for importing.If you are an FB employee go to Phabricator to review internal test results. |
@skevy @MattFoley 👏👏👏👏 |
c6b6f53
@skevy Thanks!!!!!!!!!!!!!!!!!!!!!!!! ps. @brentvatne it happened. 🎉 |
👏👏👏 |
Summary: Closes facebook#4026 Differential Revision: D2678492 Pulled By: nicklockwood fbshipit-source-id: 0467814f810fee997ac50960ffb1daa74d52acba
Summary: Closes facebook#4026 Differential Revision: D2678492 Pulled By: nicklockwood fbshipit-source-id: 0467814f810fee997ac50960ffb1daa74d52acba
Summary: Closes facebook/react-native#4026 Differential Revision: D2678492 Pulled By: nicklockwood fbshipit-source-id: 0467814f810fee997ac50960ffb1daa74d52acba
@MattFoley so, is this available in react-native@0.32 or no? Thanks so much for this! |
It's in .33rc I think, you're welcome! Sent from my iPhone
|
Text gets truncated a little bit (maybe because of large font?). Easily solved by adding |
can adjustsFontSizeToFit work with TextInput? On the user input |
You can add
You can also add the following in your Text Component:
Or you can add the following into the parent of the Text component:
or both
or all three
after It all depends on what you're doing. You can also checkout my full blog post on the topic |
it does not work for Android in react 47.1 and does not work perfectly for IOS |
Does this work for Android? It works for me for IOS but need Android support as well. |
I should be doable for android https://react-native.canny.io/feature-requests/p/textandroid-autosizing-support. But I failed to implement it maybe someone more experienced with react-native can do it. |
Would be great to get this on Android too! |
We desperately need this on Android |
I see this is closed, was it merged in? |
No description provided.