UIWebView,简单的select"actual"字体在css,不就是family吗?
UIWebView, simply select "actual" font in css, not just family?
在 iOS 中,我使用 UIWebView 加载了这个短文本文件
然后将其显示在 UIWebView 中。 (loadHTMLString
)
<html><head><style type='text/css'>
body
{
font-family:'Source Sans Pro';
font-size:12pt;
}
html { -webkit-text-size-adjust:none; }
</style></head>
<body leftmargin=0 topmargin=0>
example text...
</body></html>
这是安装的 12 个“实际”字体名称 (print(UIFont.fontNamesForFamilyName("Source Sans Pro"))
)
["SourceSansPro-BoldIt", "SourceSansPro-SemiboldIt", "SourceSansPro-ExtraLight", "SourceSansPro-Semibold", "SourceSansPro-Bold", "SourceSansPro-Black", "SourceSansPro-Regular", "SourceSansPro-Light", "SourceSansPro-BlackIt", "SourceSansPro-It", "SourceSansPro-ExtraLightIt", "SourceSansPro-LightIt"]
现在在 UIWebView 中
body
{
font-family:'Source Sans Pro';
font-size:12pt;
}
效果很好;出现常规 Source Sans Pro
字体。
但是。很简单,我怎么告诉 css 使用“ExtraLight”、“BlackIt”等等?
如何从12种字体中选择一种???
求助!
您必须在 CSS:
中使用实际的字体名称
<html>
<head>
<style type='text/css'>
body {
margin: 30px;
font-family: 'SourceSansPro-Regular';
font-size: 12pt;
}
h1 {
font-family: 'SourceSansPro-Black';
font-size: 16pt;
font-weight: normal
}
.light {
font-family: 'SourceSansPro-ExtraLight';
}
</style>
</head>
<body>
<h1>Header</h1>
<p>Normal Text</p>
<p class="light">Light Text</p>
</body>
</html>
附带说明:当您使用提供 'real' 粗体字体的字体时,最好删除 'artificial' 粗体字体粗细,因为它会使本已粗体的字体变得均匀看起来确实丑陋的大胆。 (这就是我将 font-weight: normal
添加到 h1
选择器的原因)
在 iOS 中,我使用 UIWebView 加载了这个短文本文件
然后将其显示在 UIWebView 中。 (loadHTMLString
)
<html><head><style type='text/css'>
body
{
font-family:'Source Sans Pro';
font-size:12pt;
}
html { -webkit-text-size-adjust:none; }
</style></head>
<body leftmargin=0 topmargin=0>
example text...
</body></html>
这是安装的 12 个“实际”字体名称 (print(UIFont.fontNamesForFamilyName("Source Sans Pro"))
)
["SourceSansPro-BoldIt", "SourceSansPro-SemiboldIt", "SourceSansPro-ExtraLight", "SourceSansPro-Semibold", "SourceSansPro-Bold", "SourceSansPro-Black", "SourceSansPro-Regular", "SourceSansPro-Light", "SourceSansPro-BlackIt", "SourceSansPro-It", "SourceSansPro-ExtraLightIt", "SourceSansPro-LightIt"]
现在在 UIWebView 中
body
{
font-family:'Source Sans Pro';
font-size:12pt;
}
效果很好;出现常规 Source Sans Pro
字体。
但是。很简单,我怎么告诉 css 使用“ExtraLight”、“BlackIt”等等?
如何从12种字体中选择一种???
求助!
您必须在 CSS:
中使用实际的字体名称<html>
<head>
<style type='text/css'>
body {
margin: 30px;
font-family: 'SourceSansPro-Regular';
font-size: 12pt;
}
h1 {
font-family: 'SourceSansPro-Black';
font-size: 16pt;
font-weight: normal
}
.light {
font-family: 'SourceSansPro-ExtraLight';
}
</style>
</head>
<body>
<h1>Header</h1>
<p>Normal Text</p>
<p class="light">Light Text</p>
</body>
</html>
附带说明:当您使用提供 'real' 粗体字体的字体时,最好删除 'artificial' 粗体字体粗细,因为它会使本已粗体的字体变得均匀看起来确实丑陋的大胆。 (这就是我将 font-weight: normal
添加到 h1
选择器的原因)