-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Android ignores unicode soft hyphen (u00AD) #28279
Comments
This makes it very hard / practically impossible to get proper when-needed hyphenation on Android. iOS works perfectly and is easy to make buttons that properly wrap the text only when needed. |
What would the 'very hard' way be to get the hyphenation working on Android with this version of React Native? I'm experiencing the same bug... |
Good question, you would need to build some kind of regex/matcher that checks for |
This comment has been minimized.
This comment has been minimized.
EDIT: I found a more-or-less workable solution: onTextLayout gives you the lines, now you can check the last character and change it. So I've replaced \u00AD with \u200B and then this code works:
|
With this solution I have some weird effects because the changed text (additional "- ") is triggering the onTextLayout again, which is performing changes again because the text has to change again ... in an endless loop 🔁 |
I'm checking for that as well.
and I don't change the text again if alreadyHyphenated === true I know it's not perfect (yet), but it is a step in the right direction I think. Not it's just eliminating these quirks. |
Yes, that's what I'm experiencing right now too. Almost all dashes are within the words because the new lines breaks are different after adding the dashes. |
as we can read in this medium article it is possible on android thanks to setHyphenationFrequency so I solved this in native code like this in ReactTextView.java: const testString = 'sup\u00ADer\u00ADfrag\u00ADilis\u00ADtice\u00ADxpial\u00ADidocious' renders as: I'll write a pull request to add a prop Thanks a lot. Fabrizio |
Summary: JoshuaGross This issue fixes #28279 as discussed in #29157 (comment) Avoid calling [setHyphenationFrequency](https://developer.android.com/reference/android/widget/TextView#setHyphenationFrequency(int)) on Android Sdk < 23. ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://github.com/facebook/react-native/wiki/Changelog --> [Android] [Fixed] - do not call setHyphenationFrequency on AndroidSdk < 23 Pull Request resolved: #29258 Test Plan: | **BEFORE** | **AFTER** | |:-------------------------:|:-------------------------:| | <img src="https://user-images.githubusercontent.com/24992535/86214122-05bf0e00-bb7b-11ea-93b5-2174812bfec9.png" width="300" height="" />| <img src="https://user-images.githubusercontent.com/24992535/86214130-08216800-bb7b-11ea-9fc0-68b28638bf57.png" width="300" height="" /> | The warning displayed with `adb logcat | grep -P "ReactTextAnchorViewManager"` ![image](https://user-images.githubusercontent.com/24992535/86214242-34d57f80-bb7b-11ea-9945-30ae25332bfb.png) I remain available to do improvements. Thanks a lot. Fabrizio. Reviewed By: JoshuaGross Differential Revision: D22337095 Pulled By: mdvacca fbshipit-source-id: d0943397af180929c48044ccbc7a9388549021b8
this functionality will be available with 0.64 https://github.com/react-native-community/releases/blob/20a632d3a61153f813c020ef2c6bca6910958a10/CHANGELOG.md Thanks 🙏 |
Can someone confirm here that this is working in react-native 0.64? because it is not working for me (tested with device > v23) cc @fabriziobertoglio1987 |
it doesn't work for me either. |
@fabriziobertoglio1987 It does not work for me either.
The word is breaking |
https://developer.android.com/reference/android/widget/TextView#setHyphenationFrequency(int)
seems that |
it doesn't work for me either. |
Description:
On android soft-hyphen unicode
u00AD
is ignored, neither the word break nor the hyphen are displayed correctly. Usingu200B
is a workaround for getting better word wrapping results but is still missing the hyphen.React Native version:
Steps To Reproduce
Render the following on android vs. iOS
Expected Results
Screenshot from iOS
Actual Result
Screenshot from Android
The text was updated successfully, but these errors were encountered: