facebook / react-native

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

How do I set utf8 to an Text #36147

Closed vincent-cihan closed 1 year ago

vincent-cihan commented 1 year ago

Description

In my APP, I import ttf fonts using ICONS through fontFamily and it always works fine. Recently, in the latest version of Samsung OS (oneui5.0), inconsistencies occur when bold characters are set in the system Settings. After experiments, it was found that the problem was caused by coding format, which could be solved by StandardCharsets.UTF_8, but I could not change the code in react-native. Thanks for your help and guidance. The modified code of my experiment is as follows: public static void showIcon(TextView view) { Typeface font = Typeface.createFromAsset(view.getContext().getAssets(), "iconfont.ttf"); view.setTypeface(font); String iconText = view.getResources().getString(R.string.mine); iconText = new String(iconText.getBytes(StandardCharsets.UTF_8)); view.setText(iconText); }

Version

0.63.3

Output of npx react-native info

NA

Steps to reproduce

Import custom icon fonts and open bold in the latest version of Samsung System Settings showimage-9841907-4806ef000bad3475140decb93b155923_b0b64f2eac2fc41393a6f0bd5704edcb-thumb

Snack, code example, screenshot, or link to a repository

截屏2023-02-14 20 44 16 截屏2023-02-14 20 44 28

<Text selectable={false} style={[style,{ fontFamily: 'iconfont' }]}> {String.fromCharCode(parseInt('e96a', 16))} </Text>

github-actions[bot] commented 1 year ago

It looks like your issue or the example you provided uses an unsupported version of React Native. Due to the amount of issues we receive, we're currently accepting only new issues against one of the supported version. Please open your issue on StackOverflow to get further community support.

vincent-cihan commented 1 year ago

Thanks for your reply. I have not found any support for encoding format setting of Text component in the current and later versions. I would like to ask if there is any solution or support plan for later versions.

cortinico commented 1 year ago

Thanks for your reply. I have not found any support for encoding format setting of Text component in the current and later versions. I would like to ask if there is any solution or support plan for later versions.

Sadly, we don't backport fixes to older versions of RN as we're a really small team and our capacity is limited. As you confirmed that this issue is fixed in the latest version of RN, this issue can now be closed