Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to de- and increase the font size with WKWebView?

In Safari you can increase and decrease the font size. How can I achieve the same effect with WKWebView?

like image 986
Mark Avatar asked Dec 07 '15 09:12

Mark


People also ask

How do I change the font in WKWebView?

To use custom fonts in WKWebView, we need to do three things. Add custom fonts to your app. Load custom fonts to CSS with @font-face. Introduce app bundle to WKWebView.

How do I increase the font size of a program in Linux?

In many applications, you can increase the text size at any time by pressing Ctrl + + . To reduce the text size, press Ctrl + - . Large Text will scale the text by 1.2 times. You can use Tweaks to make text size bigger or smaller.


1 Answers

The codes suggested by Inna used to work but stopped working from iOS10.3. I did some research and found that we need to make a slight change to it, just changing "%%" to a single "%".

So JS code should be:

let js = "document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust='\(fontSize)%'"

I got this info from Apple Developer forum. https://forums.developer.apple.com/thread/51079

like image 59
Yuichi Kato Avatar answered Sep 29 '22 21:09

Yuichi Kato