【发布时间】:2020-10-25 03:09:34
【问题描述】:
我正在使用最新版本的Xcode 和Swift。
我将一个名为Blastimo.ttf 的字体导入到我的Xcode 项目中,方法是将它拖放到Xcode 左侧的文件列表中。
我启用了Target Membership。
我添加了Fonts provided by application > Item 0 : Blastimo.ttf 到Info.plist。
现在我可以使用这种字体,例如标签。这是有效的。
我也想在我的WKWebView 中使用这种字体,如下所示:
let html = """
<html>
<body>
<head>
<style>
@font-face
{
font-family: 'Blastimo';
src: local('Blastimo'), url('Blastimo.ttf') format('truetype');
}
</style>
</head>
<h1 style="font-family:'Blastimo';font-size:50px;">This is my test!</h1>
</body>
</html>
"""
webView.loadHTMLString(html, baseURL: nil)
但这不起作用,标准字体被加载。
html 代码本身使用字体Blastimo.ttf。我在我的网络服务器上对其进行了测试。
但它不适用于WKWebView。我做错了什么?
【问题讨论】:
标签: ios xcode fonts font-face wkwebview