How to use system font in WebView of Android?
(实测不行)
You can use the following code to access and use the system font in a WebView of Android:
// Get the system font
Typeface typeface = ResourcesCompat.getFont(context, R.font.system_font);
// Create a String containing the HTML code with the font-family css attribute set to the system font
String htmlString = "<html><head><style>body{ font-family: '" + typeface.toString() + "'; }</style></head><body>Hello World!</body></html>";
// Set the HTML content of the WebView
webView.loadDataWithBaseURL(null, htmlString, "text/html", "utf-8", null);
How to change system font in Android?
1. On your Android device, go to Settings.
2. Tap on Display.
3. Tap on Font.
4. Select the font you would like to use.
5. Tap OK to save your changes.
评论