我正在尝试通过@ font-face在QtWebkit中使用自定义字体,并且它仅在Windows上无法正常工作。
这是我的代码示例:
@font-face {
font-family: 'LatoBoldItalic';
src: url('../fonts/Lato-Italic.ttf') format('truetype');
font-style: italic;
font-weight: 400;
text-rendering: optimizeLegibility;
}
@font-face {
font-family: 'LatoItalic';
src: url('../fonts/Lato-Light-Italic.ttf') format('truetype');
font-style: italic;
font-weight: 300;
text-rendering: optimizeLegibility;
}
@font-face {
font-family: 'Lato';
src: url('../fonts/Lato-Light.ttf') format('truetype');
font-style: normal;
font-weight: 300;
text-rendering: optimizeLegibility;
}
@font-face {
font-family: 'LatoBold';
src: url('../fonts/Lato-Regular.ttf') format('truetype');
font-style: normal;
font-weight: 400;
text-rendering: optimizeLegibility;
}
body{
font-family: "Lato";
}
h1{
font-family: 'LatoBold';
}
h2{
font-family: 'LatoItalic';
}
因此,我的内容和h1应该在普通的Lato中,而我的h2应该在斜体中。
它在Mac Os上确实可以使用,但是在Windows上已切换为斜体和普通字体。我尝试通过删除所有斜体字体(甚至从文件系统中删除)来做几件事,但是文本是用斜体呈现的样式...
我还尝试仅声明一种Lato字体,并为每种粗细和样式调用不同的.ttf,但是我遇到了同样的问题。
还尝试从网站加载Lato字体,同样的问题。
我真的不明白这里出了什么问题。
更多有用的信息:
Windows 7的
Qt 5.3.1
文件是从文件系统而不是在线加载的(文件:// .....)
谢谢 :)
这不是QT的问题(注意:现代浏览器经常使用woff
)
您font-style: italic;
在中添加了@font-face
,这还需要在font-style: italic;
选择器中添加的Webkit / Chrome中。
例子:
@font-face {
font-family: 'LatoItalic';
src: url('../fonts/Lato-Light-Italic.ttf') format('truetype');
font-style: italic;
font-weight: 300;
text-rendering: optimizeLegibility;
}
h2{
font-family: 'LatoItalic';
font-style: italic;
}
注意:woff
用于现代浏览器:Chrome 6+,Firefox 3.6+,IE 9+,Safari 5.1+注:尝试使用现代格式(和替代格式),请参见:
@font-face {
font-family: 'MyWebFont';
src: url('webfont.eot'); /* IE9 Compat Modes */
src: url('webfont.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('webfont.woff') format('woff'), /* Modern Browsers */
url('webfont.ttf') format('truetype'), /* Safari, Android, iOS */
url('webfont.svg#svgFontName') format('svg'); /* Legacy iOS */
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句