我想在我的网站上使用谷歌的Roboto字体,我正在遵循这个教程:
http://www.maketecheasier.com/use-google-roboto-font-everywhere/2012/03/15
我下载了一个文件夹结构如下所示的文件:
现在我有三个问题:
我有css在我的media/css/main.css url。我需要把文件夹放在哪里呢?
我需要提取所有的eot,svg等从所有子文件夹,并放在字体文件夹?
我需要创建css文件fonts.css和包括在我的基本模板文件?
他的例子是这样的
@font-face {
font-family: 'Roboto';
src: url('Roboto-ThinItalic-webfont.eot');
src: url('Roboto-ThinItalic-webfont.eot?#iefix') format('embedded-opentype'),
url('Roboto-ThinItalic-webfont.woff') format('woff'),
url('Roboto-ThinItalic-webfont.ttf') format('truetype'),
url('Roboto-ThinItalic-webfont.svg#RobotoThinItalic') format('svg'); (under the Apache Software License).
font-weight: 200;
font-style: italic;
}
我的url应该是什么样的,如果我想有dir结构像:
/media/fonts/roboto
对于网站,您可以使用“Roboto”字体如下:
如果你已经创建了单独的css文件,那么在css文件的顶部放置以下行:
@import url('https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,500,500i,700,700i,900,900i');
或者如果你不想创建单独的文件,那么在<style>…</style>:
<style>
@import url('https://fonts.googleapis.com/css?
family=Roboto:300,300i,400,400i,500,500i,700,700i,900,900i');
</style>
然后:
html, body {
font-family: 'Roboto', sans-serif;
}
老帖子了,我知道。
这也可以使用CSS @import url:
@import url(http://fonts.googleapis.com/css?family=Roboto:400,100,100italic,300,300italic,400italic,500,500italic,700,700italic,900italic,900);
html, body, html * {
font-family: 'Roboto', sans-serif;
}
花了一个小时,解决了字体问题。
相关答案-以下是React.js网站:
Install the npm module:
npm install --save typeface-roboto-mono
import in .js file you want to use
one of the below:
import "typeface-roboto-mono"; // if import is supported
require('typeface-roboto-mono') // if import is not supported
For the element you can use
one of the below:
fontFamily: "Roboto Mono, Menlo, Monaco, Courier, monospace", // material-ui
font-family: Roboto Mono, Menlo, Monaco, Courier, monospace; /* css */
style="font-family:Roboto Mono, Menlo, Monaco, Courier, monospace;font-weight:300;" /*inline css*/
希望这能有所帮助。