/ 1评 / 0

# 在网站中使用谷歌“ROBOTO”字体（解决ios数字1和0大小不等宽问题）

body{font-family:'Roboto',Roboto Lt;}

1. 下载字体包，链接是 FontSquirrel Roboto font page。

3. 下载完成之后，解压到当前文件夹，你可以看到解压出来的web fonts目录，打开该目录你会发现里面很多都是Roboto的各种字体。你直接选择一个你想要用在web size的上传到你的网站相关目录下面即可，当然，你还必须要添加一段css3 @font-face代码来进行嵌入扩展的字体到你的站点。代码如下：（注意，src path必须是根据你个人的具体情况来定，不是下面写死的代码。）

4. 1 @font-face {
2     font-family: 'Roboto';
3     src: url('Roboto-Regular-webfont.eot');
4     src: url('Roboto-Regular-webfont.eot?#iefix') format('embedded-opentype'),
5          url('Roboto-Regular-webfont.woff') format('woff'),
6          url('Roboto-Regular-webfont.ttf') format('truetype'),
7          url('Roboto-Regular-webfont.svg#RobotoRegular') format('svg');
8     font-weight: normal;
9     font-style: normal;
10 }
11
12 //假如你想要扩展更多的字体库，那么你就可以按照上面代码来进行引用就行。

# Installing Webfonts

Webfonts are supported by all major browser platforms but not all in the same way. There are currently four different font formats that must be included in order to target all browsers. This includes TTF, WOFF, EOT and SVG.

## 2. Include the webfont stylesheet

@font-face{
font-family: 'MyWebFont';
src: url('WebFont.eot');
src: url('WebFont.eot?iefix') format('eot'),
url('WebFont.woff') format('woff'),
url('WebFont.ttf') format('truetype'),
url('WebFont.svg#webfont') format('svg');
}

We've already gone ahead and generated the code for you. All you have to do is link to the stylesheet in your HTML, like this:

<link rel="stylesheet" href="stylesheet.css" type="text/css" charset="utf-8" />

## 3. Modify your own stylesheet

To take advantage of your new fonts, you must tell your stylesheet to use them. Look at the original @font-face declaration above and find the property called "font-family." The name linked there will be what you use to reference the font. Prepend that webfont name to the font stack in the "font-family" property, inside the selector you want to change. For example:

p { font-family: 'MyWebFont', Arial, sans-serif; }

## 4. Test

Getting webfonts to work cross-browser can be tricky. Use the information in the sidebar to help you if you find that fonts aren't loading in a particular browser.

## Troubleshooting Font-Face Problems

Having trouble getting your webfonts to load in your new website? Here are some tips to sort out what might be the problem.

### Fonts not showing in any browser

This sounds like you need to work on the plumbing. You either did not upload the fonts to the correct directory, or you did not link the fonts properly in the CSS. If you've confirmed that all this is correct and you still have a problem, take a look at your .htaccess file and see if requests are getting intercepted.

The most common problem here is that you are serving the fonts from an IIS server. IIS refuses to serve files that have unknown MIME types. If that is the case, you must set the MIME type for SVG to "image/svg+xml" in the server settings. Follow these instructions from Microsoft if you need help.

The primary reason for this failure? You are still using a version Firefox older than 3.5. So upgrade already! If that isn't it, then you are very likely serving fonts from a different domain. Firefox requires that all font assets be served from the same domain. Lastly it is possible that you need to add WOFF to your list of MIME types (if you are serving via IIS.)

Are you looking at Internet Explorer on an actual Windows machine or are you cheating by using a service like Adobe BrowserLab? Many of these screenshot services do not render @font-face for IE. Best to test it on a real machine.

IE9, like Firefox, requires that fonts be served from the same domain as the website. Make sure that is the case.

### 一条回应：“在网站中使用谷歌“ROBOTO”字体（解决ios数字1和0大小不等宽问题）”

1. repostone说道：

非技术的路过。

• 默认
• 护眼
• 夜晚
• Serif
• Sans