2014-09-01 36 views
1

我想通过@ font-face在QtWebkit中使用自定义字体,并且它只能在Windows上正常工作。QtWebkit渲染非标准字体,斜体和正常切换

这里是我的代码示例:

@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应该是正常的拉托,只有我的斜体H2。

它可以在Mac Os上工作,但在Windows上可以打开斜体和普通字体。我尝试了几件事,通过删除所有斜体字体(甚至从文件系统),但文本是以斜体呈现的样式...

我也尝试声明只有一个拉托字体,并为每个重量调用不同的.ttf和风格,但我有同样的问题。

也尝试从网站加载的拉托字体,同样的问题。

我真的不明白这里有什么问题。

更多的信息,应该是有帮助的:

  • Windows 7的

  • 的Qt 5.3.1

  • 文件从文件系统加载的,不在线(文件:// .. ...)

谢谢:)

回答

0

这不是QT的问题(注:现代的浏览器经常使用woff

您在@font-face添加font-style: italic;,这需要的Webkit /铬在您选择加入font-style: italic;也。

例子:

@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在现代浏览器中使用:铬6+,火狐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 */ 
} 
+0

谢谢!它运作良好。我认为它与Qt有关,因为我在Windows上没有Chrome问题。 – hereismass 2014-09-03 11:40:31

+0

在我的Chrome中有这个问题(Windows 7 64bit)。祝你好运! – 2014-09-03 13:02:38