2

我正在开发一个使用 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";
}

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

4

2 回答 2

1

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

这是此过程的教程,展示了如何在 UIWebView 中使用字体。

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

于 2012-06-16T20:00:38.043 回答
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/>
于 2021-02-27T22:51:41.337 回答