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

Fix/text cutoff when scaling #39711

Closed
wants to merge 2 commits into from

Conversation

jcdhlzq
Copy link
Contributor

@jcdhlzq jcdhlzq commented Sep 29, 2023

Fix Text cut off issues when adjusting text size and font weight in system settings.

Summary:

This pr fixed the problem that can be reproduced with the snack on Xiaomi devices with MIUI13 and MIUI14. The problem is shown as the image below: the number "999" is cut off and only "99" is rendered.
text-cutoff-when-scaling-miui14

The problem is produced with setting font scaling in system settings like the image below shows.

settings

This text cut off case can be avoided by setting allowFontScaling to false. But this pr can make it no matter what value allowFontScaling is set.

The root cause of this case, according to MIUI developers, is that Misans typeface, as a variable font which will adjust the weight of different font axes with different font size, gets different widths when Text is measured and drawn for a bug in the framework of MIUI rom. They will fix this bug in next version while this pr fixed it in old versions.

Changelog:

[ANDROID][FIXED]-Fix Text cut off issues when adjusting text size and font weight in system settings.

Test Plan:

The effect after fixed is shown in the image below.

fixed

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 29, 2023
@analysis-bot
Copy link

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 8,337,005 -8,565,923
android hermes armeabi-v7a n/a --
android hermes x86 n/a --
android hermes x86_64 n/a --
android jsc arm64-v8a 9,575,117 -10,806,537
android jsc armeabi-v7a n/a --
android jsc x86 n/a --
android jsc x86_64 n/a --

Base commit: 8e36cc0
Branch: main

@facebook-github-bot facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Sep 29, 2023
@github-actions
Copy link

Warnings
⚠️ One hour and a half have passed and the E2E jobs haven't finished yet.

Generated by 🚫 dangerJS against 267c957

@jcdhlzq
Copy link
Contributor Author

jcdhlzq commented Oct 9, 2023

This PR fixed npe in #39581 which has been reverted.

@jcdhlzq
Copy link
Contributor Author

jcdhlzq commented Oct 10, 2023

Hi, @NickGerleman

Could you help to review this PR?

@andyjxli
Copy link

@jcdhlzq hi, I have the same problem as you, but I set allowFontScaling to false, and still could not display the numbers completely. what should I do?
<Text style={styles.price} allowFontScaling={false}>103</Text>
const price: TextStyle = { color: '#FF2442', fontSize: 32, fontWeight: FontWeight.medium, lineHeight: LineHeight.DisplayLabel, fontFamily: '', marginLeft: 2, };
image

Copy link

This PR is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Jun 25, 2024
Copy link

github-actions bot commented Jul 2, 2024

This PR was closed because it has been stalled for 7 days with no activity.

@github-actions github-actions bot closed this Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants