简体   繁体   中英

UIWebView text improperly rendered at first after changing font family

I'm trying to change font of the text shown in a UIWebView using javascript. I'm doing this by calling a javascript function which adds a css rule to span and paragraph elements.

Problem is that when I do this for the first time after application is opened, at first webview is rendered with the new font, but after near 2-3 seconds, location of words are slided a little bit, such like if I narrowed the line spacing of the text.

After first load, all other font change requests work properly, spacing and positions not change after text is visible.

What could be the reason behind this strange behavior? What can i do to solve this?

I tried adding css rule directly into html code, but it does not change the result.

Thanks

Try apply this css padding-left: 5px; margin-left: -5px; padding-left: 5px; margin-left: -5px; on spans. Padding is the space to correct rendering text and margin is to get element back to original position.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM