如何在UIWebView中使用自定义字体

时间:2012-06-16 19:21:14

标签: iphone objective-c uiwebview custom-font

我正在开发一个使用UIWebView加载xhtml文件的iPhone应用程序 html文件可能包含使用自定义字体的css文件,但看起来Web视图不支持自定义字体,因为它不会在css文件中呈现自定义字体

例如: xhtml文件:

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

css文件:

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

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

有什么建议吗? thnx提前:))

2 个答案:

答案 0 :(得分:1)

您是否将字体添加到info.plist(UIAppFonts键)?

以下是此过程的教程,其中介绍了如何在UIWebView中使用该字体。

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

答案 1 :(得分:0)

在上述答案中将字体设置为 info.plist 之后。然后复制 - 将以下代码粘贴到本地 html 文件中:

<style>
    .heading1{font-family: "GurbaniAkharThick"}
    @font-face
       {
           font-family: 'GurbaniAkharThick';
           font-weight: 200;
           src: url(GurbaniAkharThick.ttf);
       }
    </style>
<div style = "font-family: 'GurbaniAkharThick'">AMimRq vyly dw jwp</div><br/>
相关问题