Skip to content
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

RTL languages text gets cut-off vertically on Android #24837

Closed
iRayan7 opened this issue May 14, 2019 · 11 comments
Closed

RTL languages text gets cut-off vertically on Android #24837

iRayan7 opened this issue May 14, 2019 · 11 comments
Labels
Bug Platform: Android Android applications. Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@iRayan7
Copy link

iRayan7 commented May 14, 2019

RTL languages text gets cut-off vertically on Android (Pixel 2 and OnePlus 6). This is a new app just initialized to reproduce the issue.

Arabic text, last line vertically cut off:
Screen Shot 2019-05-14 at 3 27 46 AM
Where it should be rendered like this:
Screen Shot 2019-05-14 at 3 32 13 AM

Persian text, last line vertically cut off:
Screen Shot 2019-05-14 at 3 33 20 AM
Where it should be rendered like this:
Screen Shot 2019-05-14 at 3 33 13 AM

English text is rendered fine:
Screen Shot 2019-05-14 at 3 36 13 AM

Emulator: Pixel 2
Device: OnePlus 6
React Native version: 0.59.8

React Native Environment Info:
    System:
      OS: macOS 10.14.4
      CPU: (8) x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
      Memory: 422.23 MB / 16.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 10.15.1 - /usr/local/bin/node
      Yarn: 1.13.0 - ~/n/bin/yarn
      npm: 6.4.1 - ~/n/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
      Android SDK:
        API Levels: 23, 26, 27, 28
        Build Tools: 27.0.3, 28.0.2, 28.0.3, 29.0.0
        System Images: android-26 | Google APIs Intel x86 Atom, android-27 | Google APIs Intel x86 Atom, android-28 | Android TV Intel x86 Atom, android-28 | China version of Wear OS Intel x86 Atom, android-28 | Wear OS Intel x86 Atom, android-28 | Intel x86 Atom, android-28 | Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom, android-28 | Google APIs Intel x86 Atom_64, android-28 | Google Play Intel x86 Atom, android-28 | Google Play Intel x86 Atom_64
    IDEs:
      Android Studio: 3.4 AI-183.5429.30.34.5452501
      Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.8.3 => 16.8.3 
      react-native: 0.59.8 => 0.59.8 
    npmGlobalPackages:
      react-native-cli: 2.0.1
      react-native-git-upgrade: 0.2.7

Steps To Reproduce

  1. init a new app
  2. type a long text in Arabic inside a component, where the text has to wrap into multiple lines.

Describe what you expected to happen:
Text rendered normally.

Snack, code example, or link to a repository:

/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 *
 * @format
 * @flow
 */

import React, {Component} from 'react';
import {Platform, StyleSheet, Text, View} from 'react-native';


type Props = {};
export default class App extends Component<Props> {
  render() {
    return (
      <View style={styles.container}>
        <Text style={styles.instructions}>خلافاَ للإعتقاد السائد فإن لوريم إيبسوم ليس نصاَ عشوائياً، بل إن له جذور في قبل الميلاد، مما يجعله</Text>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  instructions: {
    textAlign: 'center',
    color: '#333333',
    fontSize: 40,
  },
});
@iRayan7 iRayan7 added the Bug label May 14, 2019
@react-native-bot react-native-bot added the Platform: Android Android applications. label May 14, 2019
@nadavmos
Copy link

same issue with hebrew when the targetSdkVersion is 28. you can change targetSdkVersion to 27 as a workaround

@iRayan7
Copy link
Author

iRayan7 commented May 14, 2019

Thanks, @nadavmos!
This is what solved the problem for me: in /android/build.gradle

buildscript {
    ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 21
        compileSdkVersion = 28
        targetSdkVersion = 27
        supportLibVersion = "28.0.0"
    }
    ... 
}

Wish it get solved for targetSdkVersion = 28 ASAP.

@nadav2051
Copy link

Same issue, downgrading from 28 to 27 has indeed solved it, but I've worked around that by providing the 'lineHeight' style property in the Text component and had it set to the same value of fontSize, seems to be working properly.

facebook-github-bot pushed a commit that referenced this issue Jun 27, 2019
Summary:
Fix wrapped some languages (like Japanese, Chinese) texts are cut off on android. This p-r is based on linjson [patch](#25275 (comment)).

- related (maybe)
    - #25297
    - #25275
    - #24837
    - #25155

`setUseLineSpacingFromFallbacks` is recommended to set true on [document](https://developer.android.com/reference/android/text/StaticLayout.Builder#setUseLineSpacingFromFallbacks(boolean))

>For backward compatibility reasons, the default is false, but setting this to true is strongly recommended. It is required to be true if text could be in languages like Burmese or Tibetan where text is typically much taller or deeper than Latin text.

## Changelog

[Android] [Fixed] - Fix some languages wrapped texts are cut off.
Pull Request resolved: #25306

Test Plan:
Set the target SDK to 28 in ``fbsource/fbandroid/java/com/facebook/catalyst/shell/AndroidManifest.xml``:
```
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="28"/>
```

Insert the following code into Playground.js: P67720709

Start the Catalyst Android app and navigate to the playground:

`buck install -r catalyst`

|Before|After|
|{F163482789}|{F163481060}|

Reviewed By: cpojer

Differential Revision: D15985809

Pulled By: makovkastar

fbshipit-source-id: 0f98760b7a7fe4689fa3fe90ca747e9bf9fc4780
kelset pushed a commit that referenced this issue Jun 28, 2019
Summary:
Fix wrapped some languages (like Japanese, Chinese) texts are cut off on android. This p-r is based on linjson [patch](#25275 (comment)).

- related (maybe)
    - #25297
    - #25275
    - #24837
    - #25155

`setUseLineSpacingFromFallbacks` is recommended to set true on [document](https://developer.android.com/reference/android/text/StaticLayout.Builder#setUseLineSpacingFromFallbacks(boolean))

>For backward compatibility reasons, the default is false, but setting this to true is strongly recommended. It is required to be true if text could be in languages like Burmese or Tibetan where text is typically much taller or deeper than Latin text.

## Changelog

[Android] [Fixed] - Fix some languages wrapped texts are cut off.
Pull Request resolved: #25306

Test Plan:
Set the target SDK to 28 in ``fbsource/fbandroid/java/com/facebook/catalyst/shell/AndroidManifest.xml``:
```
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="28"/>
```

Insert the following code into Playground.js: P67720709

Start the Catalyst Android app and navigate to the playground:

`buck install -r catalyst`

|Before|After|
|{F163482789}|{F163481060}|

Reviewed By: cpojer

Differential Revision: D15985809

Pulled By: makovkastar

fbshipit-source-id: 0f98760b7a7fe4689fa3fe90ca747e9bf9fc4780
@felixweinberger
Copy link

Same issue, downgrading from 28 to 27 has indeed solved it, but I've worked around that by providing the 'lineHeight' style property in the Text component and had it set to the same value of fontSize, seems to be working properly.

Thanks, this solution worked for me as well!

@fukuball
Copy link

fukuball commented Jul 11, 2019

Same issue, downgrading from 28 to 27 has indeed solved it, but I've worked around that by providing the 'lineHeight' style property in the Text component and had it set to the same value of fontSize, seems to be working properly.

Downgrade to 27 works, this hot fix commit #25297 does not work for me.

soh335 added a commit to natureglobal/react-native that referenced this issue Jul 16, 2019
Summary:
Fix wrapped some languages (like Japanese, Chinese) texts are cut off on android. This p-r is based on linjson [patch](facebook#25275 (comment)).

- related (maybe)
    - facebook#25297
    - facebook#25275
    - facebook#24837
    - facebook#25155

`setUseLineSpacingFromFallbacks` is recommended to set true on [document](https://developer.android.com/reference/android/text/StaticLayout.Builder#setUseLineSpacingFromFallbacks(boolean))

>For backward compatibility reasons, the default is false, but setting this to true is strongly recommended. It is required to be true if text could be in languages like Burmese or Tibetan where text is typically much taller or deeper than Latin text.

## Changelog

[Android] [Fixed] - Fix some languages wrapped texts are cut off.
Pull Request resolved: facebook#25306

Test Plan:
Set the target SDK to 28 in ``fbsource/fbandroid/java/com/facebook/catalyst/shell/AndroidManifest.xml``:
```
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="28"/>
```

Insert the following code into Playground.js: P67720709

Start the Catalyst Android app and navigate to the playground:

`buck install -r catalyst`

|Before|After|
|{F163482789}|{F163481060}|

Reviewed By: cpojer

Differential Revision: D15985809

Pulled By: makovkastar

fbshipit-source-id: 0f98760b7a7fe4689fa3fe90ca747e9bf9fc4780
@nadav2051
Copy link

Any idea when will we see a fix for this in one of the releases? as of August 1st, Google store will stop supporting new applications with API 27, and on November 1st, it will stop supporting updating existing apps with API 27, so this workaround is not viable anymore.

@soh335
Copy link
Contributor

soh335 commented Jul 24, 2019

We fork and apply patch to 0.59.10, and works. If you want to use forked react native, need to build from source.

@tarouboy
Copy link

Actually not just Arabic but many non-english text content as well.
Hope they will merge it soon.

@kelset
Copy link
Contributor

kelset commented Sep 19, 2019

hey folks - sorry for the late reply. It seems that the commit fixing this is actually in the 61 RC (76c50c1) so what I would suggest is to endure while we get to 0.61 (if you can! I'm not sure how far away from 0.61.0 we are atm) or do what @soh335 said and apply the patch locally.

hubertwang pushed a commit to hubertwang/react-native that referenced this issue Nov 1, 2019
Summary:
Fix wrapped some languages (like Japanese, Chinese) texts are cut off on android. This p-r is based on linjson [patch](facebook#25275 (comment)).

- related (maybe)
    - facebook#25297
    - facebook#25275
    - facebook#24837
    - facebook#25155

`setUseLineSpacingFromFallbacks` is recommended to set true on [document](https://developer.android.com/reference/android/text/StaticLayout.Builder#setUseLineSpacingFromFallbacks(boolean))

>For backward compatibility reasons, the default is false, but setting this to true is strongly recommended. It is required to be true if text could be in languages like Burmese or Tibetan where text is typically much taller or deeper than Latin text.

## Changelog

[Android] [Fixed] - Fix some languages wrapped texts are cut off.
Pull Request resolved: facebook#25306

Test Plan:
Set the target SDK to 28 in ``fbsource/fbandroid/java/com/facebook/catalyst/shell/AndroidManifest.xml``:
```
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="28"/>
```

Insert the following code into Playground.js: P67720709

Start the Catalyst Android app and navigate to the playground:

`buck install -r catalyst`

|Before|After|
|{F163482789}|{F163481060}|

Reviewed By: cpojer

Differential Revision: D15985809

Pulled By: makovkastar

fbshipit-source-id: 0f98760b7a7fe4689fa3fe90ca747e9bf9fc4780
hubertwang pushed a commit to hubertwang/react-native that referenced this issue Nov 1, 2019
Summary:
Fix wrapped some languages (like Japanese, Chinese) texts are cut off on android. This p-r is based on linjson [patch](facebook#25275 (comment)).

- related (maybe)
    - facebook#25297
    - facebook#25275
    - facebook#24837
    - facebook#25155

`setUseLineSpacingFromFallbacks` is recommended to set true on [document](https://developer.android.com/reference/android/text/StaticLayout.Builder#setUseLineSpacingFromFallbacks(boolean))

>For backward compatibility reasons, the default is false, but setting this to true is strongly recommended. It is required to be true if text could be in languages like Burmese or Tibetan where text is typically much taller or deeper than Latin text.

## Changelog

[Android] [Fixed] - Fix some languages wrapped texts are cut off.
Pull Request resolved: facebook#25306

Test Plan:
Set the target SDK to 28 in ``fbsource/fbandroid/java/com/facebook/catalyst/shell/AndroidManifest.xml``:
```
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="28"/>
```

Insert the following code into Playground.js: P67720709

Start the Catalyst Android app and navigate to the playground:

`buck install -r catalyst`

|Before|After|
|{F163482789}|{F163481060}|

Reviewed By: cpojer

Differential Revision: D15985809

Pulled By: makovkastar

fbshipit-source-id: 0f98760b7a7fe4689fa3fe90ca747e9bf9fc4780
tomitaku1013 pushed a commit to tomitaku1013/react-native that referenced this issue Dec 6, 2019
Summary:
Fix wrapped some languages (like Japanese, Chinese) texts are cut off on android. This p-r is based on linjson [patch](facebook#25275 (comment)).

- related (maybe)
    - facebook#25297
    - facebook#25275
    - facebook#24837
    - facebook#25155

`setUseLineSpacingFromFallbacks` is recommended to set true on [document](https://developer.android.com/reference/android/text/StaticLayout.Builder#setUseLineSpacingFromFallbacks(boolean))

>For backward compatibility reasons, the default is false, but setting this to true is strongly recommended. It is required to be true if text could be in languages like Burmese or Tibetan where text is typically much taller or deeper than Latin text.

## Changelog

[Android] [Fixed] - Fix some languages wrapped texts are cut off.
Pull Request resolved: facebook#25306

Test Plan:
Set the target SDK to 28 in ``fbsource/fbandroid/java/com/facebook/catalyst/shell/AndroidManifest.xml``:
```
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="28"/>
```

Insert the following code into Playground.js: P67720709

Start the Catalyst Android app and navigate to the playground:

`buck install -r catalyst`

|Before|After|
|{F163482789}|{F163481060}|

Reviewed By: cpojer

Differential Revision: D15985809

Pulled By: makovkastar

fbshipit-source-id: 0f98760b7a7fe4689fa3fe90ca747e9bf9fc4780
@stale
Copy link

stale bot commented Dec 18, 2019

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Dec 18, 2019
@stale
Copy link

stale bot commented Dec 25, 2019

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.

@stale stale bot closed this as completed Dec 25, 2019
@facebook facebook locked as resolved and limited conversation to collaborators Dec 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Platform: Android Android applications. Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests

9 participants