CSS中的Roboto字体

CSS中的Roboto字体,css,fonts,Css,Fonts,我想在prestashop中使用“Roboto”字体。我收到过.psd文件中的设计和图形设计师使用的字体“Roboto Medium”和“Roboto Regular”。我是否正确理解,当我想使用Roboto Normal时,我可以申请: font- family: "Roboto" font-weight: 400 当我想使用Roboto Medium时,我应该申请: font- family: "Roboto" font-weight: 500 换句话说,重量400和500分别等于Rob

我想在prestashop中使用“Roboto”字体。我收到过.psd文件中的设计和图形设计师使用的字体“Roboto Medium”和“Roboto Regular”。我是否正确理解,当我想使用Roboto Normal时,我可以申请:

font- family: "Roboto"
font-weight: 400
当我想使用Roboto Medium时,我应该申请:

font- family: "Roboto"
font-weight: 500

换句话说,重量400和500分别等于Roboto Normal和Roboto Medium吗?

确保关闭CSS行

font-family: "Roboto";
font-weight: 400;
是的,你的体重是正确的

font-weight: 400; //normal
font-weight: 500; //medium
font-weight: 700; //bold

请阅读有关
字体重量的内容,根据字体的不同,它并不总是可用。但是,根据,您应该能够毫无问题地使用这些权重。

我最初对此也有点困惑

我接到客户的请求,根据他们的风格指南,我需要为“Roboto”、“Roboto Medium”、“Roboto Light”等设置相应的字体

在谷歌的字体网站()上,他们展示了“Roboto”字体,然后是每种字体变体的示例“Medium”、“Light”等

但这并不明显涉及CSS中的两个设置。我最初的想法是这样设置:

* {font-family: 'Roboto Light', 'Roboto Medium', 'Roboto', etc}
.Roboto{font-family:'Roboto';font-weight:400;} /* 400 is industry standard for normal */

.RobotoLight{font-familiy:'Roboto';font-weight:300;} /* 300 is industry standard for normal */

.RobotoMedium{font-family:'Roboto';font-weight:500;} /* 500 is industry standard for normal */
但经过实验和一点研究,它涉及两种设置,一种是指定核心“族”,然后变化是“权重”,如下所示:

* {font-family: 'Roboto Light', 'Roboto Medium', 'Roboto', etc}
.Roboto{font-family:'Roboto';font-weight:400;} /* 400 is industry standard for normal */

.RobotoLight{font-familiy:'Roboto';font-weight:300;} /* 300 is industry standard for normal */

.RobotoMedium{font-family:'Roboto';font-weight:500;} /* 500 is industry standard for normal */

我认为您需要首先通过
@font-face
加载这两种字体,这样您就可以在
@font-face
块中指定每种字体的
字体重量。@HashemQolami,我这样做了-我粘贴到了标题,这是正确的,JaroslawRewers。不需要@font-face。不,普通和中等,以及瘦和粗体是不同的roboto字体变体,对应于不同的ttf文件。通过设置字体权重u,只需将该权重设置为默认的变体权重。您不会更改字体外观其他注意事项:如果我们必须通过CSS指定权重,我不确定为什么(使用Google字体时)我们还必须“下载”想要使用的适当权重(我认为字体只是一种“字体”,CSS权重控制的强度类似于使用粗体)。所以我认为下载一般,重量相应。不知道为什么不是这样。以下是我如何获得Roboto字体的轻、普通和中等重量:这是因为对于像Roboto这样的字体集,中等大小的字体在形状上也是可见的,不仅在重量上与普通字体和粗体字体不同。