facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
118.06k stars 24.19k forks source link

Oppo A77 - Some texts gets cut-off #15114

Open mykelaballe opened 7 years ago

mykelaballe commented 7 years ago

Environment

  1. react-native -v: 0.34 through 0.59
  2. node -v:4.4.7
  3. npm -v: 4.5.0
  4. yarn --version:

Steps to Reproduce

There's no necessary steps to produce these bug. You just have to run the app either in dev or production

Expected Behavior

Texts should not be cut-off

Actual Behavior

Some texts are cut-off as shown below. These cut-off issue doesnt occur in iphone and other phone models except Oppo A77

Screenshots: image

image

Those screenshots are just few of the texts that are cut-off

Sorry i can't provide a link to the project

hramos commented 7 years ago

Thanks for opening the issue! It does not appear like a community member will be able to reliably reproduce this issue. This may be for several reasons; perhaps it affects a particular app but a minimal repro has not been provided, or the issue may be sporadic. As it happens, we need a concrete set of steps that can demonstrably reproduce the issue as this will allow your fellow community members to validate a fix. We'll close the issue for now, but feel free to submit a new issue once you're able to reliably reproduce the issue locally. Thanks for your understanding!

johnwook commented 7 years ago

@mykelaballe cc @hramos We've had similar issue(some texts getting cut off in Oppo device). Although it's not a complete solution, we found some hacky-way to solve this problem.

in short, (at least in our case) just adding empty space at the end of the text seems work. my colleague @saystone will explain in detail :)

for example, use 1.5.3+space instead of 1.5.3(space at the end of the string)

asdacap commented 6 years ago

As a side note, I also have this issue. It seems to appear on multiple Oppo devices. Probably something to do with fonts.

jemmyphan commented 6 years ago

@johnwook in short, (at least in our case) just adding empty space at the end of the text seems work. my colleague @saystone will explain in detail :)

do you still use this workaround?

johnwook commented 6 years ago

@jemmyphan Hello! Unfortunately yes :( . As our OPPO user grows, our team think we should SOLVE this problem right. For now there is no progress. If some arises, I'll let you know by commenting here. If you find some better solution please let me know :)

jemmyphan commented 6 years ago

@johnwook yeah, oppo user's grow so fast, anyway didn't expect it to be replied this fast. thanks and appreciate it a lot. ;)

yeswanth commented 6 years ago

I have faced similar issues in OnePlus 5. These issues only happen in a OnePlus 5 phone when you have chosen "OnePlus Slate" font in Settings. If you change the font to Roboto, the issues don't occur. I'm gonna ship Roboto font along with my app in the next version to go around this.

asdacap commented 6 years ago

@yeswanth Can you share how to ship the Roboto font along the app? Will all Text component automatically use the font or we'll have to make a wrapper Text component?

yeswanth commented 6 years ago

Hi @asdacap You can download roboto font and add it to your project(As shown in this link). Unfortunately, you will have to create a wrapper for all Text in order for this to work.

hkxicor commented 6 years ago

this solution works for me, you can try this

import React from 'react'; import { StyleSheet, Text, } from 'react-native';`

const styles = StyleSheet.create({ defaultFontFamily: { fontFamily: 'lucida grande', } });

const oldRender = Text.prototype.render; Text.prototype.render = function (...args) { const origin = oldRender.call(this, ...args); return React.cloneElement(origin, { style: [origin.props.style, styles.defaultFontFamily] }); };

gedeagas commented 6 years ago

@hkxicor trying your suggestion. will edit after the result

asdacap commented 6 years ago

I can say that it worked in my case.

jslok commented 6 years ago

@hkxicor do I need to place that code on every one of my js files with affected text or will it solve the issue for my entire app if I only put it in my main app.js? I'd test it myself but I do not personally have an oppo phone to reproduce on. Thank you

hkxicor commented 6 years ago

@jslok just put it on app.js it will work.

jslok commented 6 years ago

I tried the code but it appears to break react-native-vector-icons. All icons get replaced by X.

hkxicor commented 6 years ago

@jslok please update hare if you find any solution

justjavac commented 6 years ago

@hkxicor

 import React from 'react';

 import { StyleSheet, Text } from 'react-native';

 const styles = StyleSheet.create({
   defaultFontFamily: {
     fontFamily: 'lucida grande',
   },
 });

 export default function fixOppoTextCutOff() {
   const oldRender = Text.prototype.render;
   Text.prototype.render = function render(...args) {
     const origin = oldRender.call(this, ...args);
     return React.cloneElement(origin, {
-      style: [origin.props.style, styles.defaultFontFamily],
+      style: [styles.defaultFontFamily, origin.props.style],
     });
   };
 }
jslok commented 6 years ago

Can anybody else confirm if justjavac's solution above still fixes the issue of text getting cutoff? I don't have an oppo device to test, but I can say it does not cause react-native-vector-icons to break.

Also I have found OnePlus (not sure if some or all) devices also have this same issue.

jslok commented 6 years ago

Confirmed working

justjavac commented 6 years ago

@jslok

Perhaps because OnePlus does not have the Lucida Grande font installed by default, you can manually install the Lucida Grande font in your react-native project.

My solution above is to solve "All icons get replaced by X". If there is still a text cutoff problem, check your fonts.

jslok commented 6 years ago

@justjavac I meant the original issue of text getting cutoff exists on Oneplus devices just like Oppo devices. Your edit solves it on both, and also does not break react-native-vector-icons. Thank you and also thanks to @hkxicor

ghost commented 6 years ago

Setting the following seems to fix the issue:

<Text style={{fontFamily: ""}}>

mohammadavood commented 6 years ago

I have similar issue in LG G3 and react-native v0.53.0 it looks like is a bug in react native that react support team doesn't like accept and fix it. i solved it temporary by deleting ((alignItems: 'center')) from the component style

ou2s commented 6 years ago

@hramos This issue should be open... (like many others)

Anyway, thanks for the workaround guys.

mykelaballe commented 6 years ago

thank God people took notice of this issue already. quite sometime. thanks guys

parth3724 commented 6 years ago

@hkxicor your solution is working... but I don't understand the fix.. Fonts in my app are still Roboto and not lucida grande. I have not set fontfamily to Text component ...

ItsWendell commented 6 years ago

Subscribed, we're facing similar issues with texts on OnePlus devices!

ramosalx1504 commented 6 years ago

For me the best solution is to specify the "fontFamily" for the global component in my application, so, no matter what typography the user has on their device, the application will be displayed as I designed it.

** If not specified, it seems that the component uses the device's default, and here come the problems (One plus 5T slate default font for example).

hramos commented 6 years ago

It seems like this affects Oppo and OnePlus devices. Has someone looked into what in particular about this class of devices causes this? Is it the lack of the Roboto system font?

wenkangzhou commented 6 years ago

If some devices not install 'lucida grande',it can be work or crash?

justjavac commented 6 years ago

@wenkangzhou Not crash, it will fall back to using the default font

wenkangzhou commented 6 years ago

@justjavac ,good,thx.

rpavlovs commented 6 years ago

Same issue on iPhone X (iOS obviously) with 0.55.4, but it seems to show up only after I browse in the app for a bit.

I also found a stale issue with reproducible demo: https://github.com/facebook/react-native/issues/17960

hramos commented 6 years ago

@rpavlos does it repro on 0.56?

craigdanj commented 6 years ago

We had the same problem with a one plus 3. Changing the font to Roboto fixed this.

as @yeswanth had suggested.

byCedric commented 6 years ago

I can confirm that this happens on React Native 0.55.x with various custom fonts on Android. I haven't tried using the latest 0.56.x, will try it when I can use it in Expo! For us the problem caused the React Navigation's header title being cut off with an ellipsis. If you have the same problem, you can simply set width: '100%' to this header title as a temporary workaround.

Fitzpasd commented 6 years ago

We can repro this on Android with RN 0.55.4, without using a custom font. None of the suggested 'fixes'/workarounds in this thread work

hramos commented 6 years ago

Please let us know if this can be reproduced in 0.56. If you've only tested on earlier releases, no need to +1.

Fitzpasd commented 6 years ago

Yes, it repos on 0.56.

Eyosias5 commented 6 years ago

Its been a year and this issue is still here on the Oneplus 6 too.

craigdanj commented 6 years ago

So this goes away if you remove the one plus font called slate. Switch to roboto and you should see this go away.

Eyosias5 commented 6 years ago

Yeah that worked. But wouldn't that mean I have to tell everyone who has got a OnePlus to turn off the Slate font when they use my app? Isn't there a way to force the device to change the font as you load the app?

On Sat, Aug 4, 2018, 18:02 Craig Johnson notifications@github.com wrote:

So this goes away if you remove the one plus font called slate. Switch to robot and you should see this go away.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/facebook/react-native/issues/15114#issuecomment-410455506, or mute the thread https://github.com/notifications/unsubscribe-auth/AefC-MytKO7RFy4NciuWoO7ME4KxSlm8ks5uNbeMgaJpZM4OdgNs .

craigdanj commented 6 years ago

I'm not an expert but can't you just set the font for your app to some other font like roboto? That would override the system font.

Eyosias5 commented 6 years ago

Yep that works great. Thanks :)

On Sat, Aug 4, 2018, 19:53 Craig Johnson notifications@github.com wrote:

I'm not an expert but can't you just set the font for your app to some other font like roboto? That would override the system font.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/facebook/react-native/issues/15114#issuecomment-410462554, or mute the thread https://github.com/notifications/unsubscribe-auth/AefC-A5o502Qe13h5vz5q297wJu49D7xks5uNdGEgaJpZM4OdgNs .

hramos commented 6 years ago

So, what can we do to fix this in the framework itself? Is React Native making a false assumption about the system font, and can we address this via a PR? Or is this something any developer might run into when targeting these devices even without RN?

justjavac commented 6 years ago

In an APP that is not developed using RN, this problem does not exist. I wrote a simple demo using Flutter and there is no such problem. Maybe this is a RN's problem.

ou2s commented 6 years ago

My 2 cents hypothesis even if I don't have an affected model in my hands:

SamMatthewsIsACommonName commented 5 years ago

Hi guys, has there been an accepted universal solution for this, even a workaround? We cant simulalte either device so hoping one has been verified to work and we can send that out live and hope for the best. Im just asking because some later commenters have said some of these fixes still don't work for them.

rpavlovs commented 5 years ago

The cut-off line seems to slowly move further throughout the app use. See the recording: https://streamable.com/59hx4

vitorreis commented 5 years ago

it seems to be related to #21729