Google Webfont与本地字体冲突 [英] Google Webfont conflict with local font

查看:300
本文介绍了Google Webfont与本地字体冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用google-webfonts有一个非常不好的冲突。
这里是代码:



这是在头:

 < link href ='http://fonts.googleapis.com/css?family = Oswald:700'rel ='stylesheet'type ='text / css'> 

这是在css文件中:

  body {
font-family:'Oswald',sans-serif;
font-weight:700; }

Oswald 是3种字体的字体族: / p>


  • 预订(300)

  • 正常(400)

  • bold(700)



正如你可以看到..我只加载了粗体(700)。 (你可以在查询中看到它)
它工作到这里,但是...



问题是:



我有一个桌面版本的3字体(300,400,700)安装在我的电脑上,只要这些字体被激活...浏览器显示我错误的字体重量(400)在我的html文档。 p>

好的。问题是,在我的css'Oswald'采取localfont而不是webfont。但是本地字体Oswald是Oswald正常。我不知道为什么google叫它'Oswald'而不是'Oswald Bold'。所以我不知道如何解决这个问题。



我不想让CSS指向本地字体..我想它总是显示webfont ...因为正确的字体重量!



你有什么想法吗?
请?



可以重命名webfont-call吗?

解决方案

您可以编辑CSS @ font-face 规则来满足您的需求,而不仅仅是加载从Google自动生成的规则。基本上问题是他们的规则喜欢本地版本( src:local('Oswald Bold'),local('Oswald-Bold'),... )。修正的版本如下:

  @ font-face {
font-family:'WebOswald';
font-style:normal;
font-weight:700;
src:url(https://themes.googleusercontent.com/static/fonts/oswald/v5/bH7276GfdCjMjApa_dkG6T8E0i7KZn-EPnyo3HZu7kw.woff)format('woff');
}

只需将它手动添加到您的CSS,然后使用



我希望能帮到你!

>

I have a really bad conflict with using google-webfonts. OK here is the code:

This is in head:

<link href='http://fonts.googleapis.com/css?family=Oswald:700' rel='stylesheet' type='text/css'>

And this is in the css-file:

body {
font-family: 'Oswald', sans-serif;
font-weight: 700; }

"Oswald" is a font-family of 3 fonts:

  • book (300)
  • normal (400)
  • bold (700)

As you can see.. i've loaded only the bold-face (700). (you can see it in the query) And it works till here BUT …

THE PROBLEM IS:

I have a desktop-version of the 3 fonts (300,400,700) installed on my computer and as long as these fonts are activated … the browser shows me the wrong font-weight (400) in my html-document.

OK. The problem is that in my css 'Oswald' takes the localfont and not the webfont. But the local font "Oswald" is "Oswald normal". I don't know why google is calling it 'Oswald' instead of 'Oswald Bold'. So I don't know how to fix this problem.

I don't want the css to point at the local-font .. i want it to show always the webfont … because of the right font-weight!

Do you have any ideas? Please?

Possible to Rename the webfont-call?

解决方案

You can edit the CSS @font-face rule to fit your needs instead of just loading the automatically-generated one from Google. Basically the issue is that their rule prefers local versions (src: local('Oswald Bold'), local('Oswald-Bold'), ...). The corrected verison would look like:

@font-face {
  font-family: 'WebOswald';
  font-style: normal;
  font-weight: 700;
  src: url(https://themes.googleusercontent.com/static/fonts/oswald/v5/bH7276GfdCjMjApa_dkG6T8E0i7KZn-EPnyo3HZu7kw.woff) format('woff');
}

Just add that to your CSS manually, and use font-family: 'WebOswald'; when you want to use Google's Web version of the font.

I hope that helped!

这篇关于Google Webfont与本地字体冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆