How to use a custom font inside a UIWebView

2019-07-30 22:24发布

I'm working on an iPhone application that use UIWebView which load xhtml files the html file could include css file that use custom fonts, but it's look like that the web view doesn't support custom fonts since it doesn't render the custom font in the css file

example: xhtml file:

<head>   
    <link href="../Styles/p1.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <p class="line1">تجريب</p>
</body>
</html>

css file:

@font-face {
font-family: "AHRAM";
font-style: normal;
font-weight: bold;
src:url("../Fonts/andlso.ttf");
} 

p.line1 {
font-family: "AHRAM";
}

any suggestion? thnx in advance :)

1条回答
我只想做你的唯一
2楼-- · 2019-07-30 22:50

Are you adding the font to your info.plist (UIAppFonts key) ?

Here's a tutorial for this process, which shows how to use the font in a UIWebView.

http://tetontech.wordpress.com/2010/09/03/using-custom-fonts-in-your-ios-application/

查看更多
登录 后发表回答