Font issue on Android 4.x WebView
See original GitHub issueIs this a bug report?
Yes. It appears when this commit is merged. On RN 0.50.0 above, Android 4.x WebView cannot display text/html format.
Have you read the Contributing Guidelines?
Yes
Environment
Environment: OS: macOS High Sierra 10.13.2 Node: 8.9.1 Yarn: Not Found npm: 5.5.1 Watchman: Not Found Xcode: Xcode 9.2 Build version 9C40b Android Studio: 3.0 AI-171.4443003
Packages: (wanted => installed) react: 16.0.0 => 16.0.0 react-native: 0.50.0 => 0.50.0
Target Platform: Android 4.1.2 (API 16)
Steps to Reproduce
Render this component:
`export default class TestWebView extends Component<{}> {
render() {
const html = "<html>\n <body>" +
"※Facebook,並びにGoogle+へ許可なく投稿がされることはありません。" +
"</body>\n</html>";
return (
<WebView
style={{flex:1}}
source={{html}}/>
);
}
}`
Expected Behavior
Actual Behavior
Reproducible Demo
(Paste the link to an example project and exact instructions to reproduce the issue.)
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:11 (1 by maintainers)
Top Results From Across the Web
Some fonts no longer work in WebView in Android 4.2 ...
Another font which fails in 4.2 is Padauk. ttf which is used to view Burmese. However, a font which is fine under both...
Read more >Google webfonts not working using Web View in Android 4.0 ...
It turns out that fonts don't render in the WebView on Android 4.2 if the format() clause is present ... For 4.4.x devices,...
Read more >Build web apps in WebView - Android Developers
If you want to deliver a web application (or just a web page) as a part of a client application, you can do...
Read more >Android WebView Custom Fonts - YouTube
Now we can load html file with many language in Webview. Android Full Projects, check here ...
Read more >Android Webview on ChromeOS devices may not render content
Attached is a Simple Android App with a Webview that shows some Korean text that we have been able to reproduce this issue...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Guys! Here’s the solution that worked for me. On
Platform.OS === 'android'
addbaseUrl: ''
tosource
property of theWebView
. UTF-8 displays correctly then!@derakhshanfar, I can see two options if you need the fix for this problem asap. The first choice is using an older React Native version while the fix is not published. I guess that 0.49 is working fine. The second option is using a fork of React Native with my commit. You can use my branch if you don’t want to fork RN. In this case, you can follow this tutorial on how to use RN built from the source replacing:
npm install --save github:facebook/react-native#master
with:npm install --save github:adrianomelo/react-native#loadurl
I don’t recommend the second approach unless you are an experienced developer. This process usually takes a lot of time. Maintaining a fork is not fun. 😃
@huynhtansi, I already submitted a pull request with a fix for it. However, if you can test, it would be awesome. You can comment on the PR and it might speed up the process of merging it to upstream.