【发布时间】:2014-07-17 22:13:58
【问题描述】:
我在 Chrome 浏览器中使用 Roboto 字体时遇到问题。特别是我似乎无法获得 Condensed 和 Thin/Light 等字体粗细。我下载了所有 3 种完整的字体:
@import url(https://fonts.googleapis.com/css?family=Roboto:100,100italic,300,300italic,400,400italic,500,500italic,700,700italic,900,900italic&subset=latin,latin-ext,cyrillic,cyrillic-ext,greek-ext,greek,vietnamese);
@import url(https://fonts.googleapis.com/css?family=Roboto+Condensed:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext,cyrillic-ext,cyrillic,greek-ext,greek,vietnamese);
@import url(https://fonts.googleapis.com/css?family=Roboto+Slab:400,100,300,700&subset=latin,latin-ext,greek-ext,greek,vietnamese,cyrillic,cyrillic-ext);
然后我在如下声明中使用它们:
Roboto 浓缩版
.mas-1st-col {
font-family: Roboto !important;
font-size: 8pt; !important
font-weight: 200 !important;
font-stretch: condensed !important;
}
机器人灯
span.f, div.f.kv + div.f.slp {
font-family: Roboto !important;
font-size: 8pt !important;
font-weight: 200 !important;
}
然而,它给我的是普通的 Roboto。如果我将“Condensed”更改为使用字体系列“Roboto Condensed”,它可以工作......这是有道理的,因为显然 chrome 采用font-stretch 很晚。但是,将字体系列更改为“roboto condensed”不会使用较轻的 font-weight(即 300),它保持在 400。即使我将 font-weight 更改为 300,它特别具有,它将保持在 400(在控制台中在 200、300 和 400 之间切换根本没有效果)。我必须专门输入“Roboto Condensed Light”,以获得较轻的字体粗细。
那么其他人呢? “Roboto Thin”不是专门下载或设置在 @font-face 中的......当我只想要一个字体粗细时,我不应该使用像“roboto Thin”这样的名称,不是吗?
详情
由于特里的好建议,下面是基本完整的相关代码:
function _miscCSS () {
var css = function(){/*
@import url(https://fonts.googleapis.com/css?family=Roboto:100,100italic,300,300italic,400,400italic,500,500italic,700,700italic,900,900italic&subset=latin,latin-ext,cyrillic,cyrillic-ext,greek-ext,greek,vietnamese);
@import url(https://fonts.googleapis.com/css?family=Roboto+Condensed:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext,cyrillic-ext,cyrillic,greek-ext,greek,vietnamese);
@import url(https://fonts.googleapis.com/css?family=Roboto+Slab:400,100,300,700&subset=latin,latin-ext,greek-ext,greek,vietnamese,cyrillic,cyrillic-ext);
...[css declarations follow]...
*/}.toString().slice(14,-3);
return css;
}
var misc_css = '<style>'+ _miscCSS() +'</style>';
jQ(misc_css).appendTo('head');
【问题讨论】:
标签: css google-chrome fonts