Google总是那么让人惊奇,最近又推出了Google Font API 服务。对于网络开发者来说,真的一个福音啊。只要链接一行CSS到你的HTML文件,就不用担心客户没有相应字体的烦恼了。
示例
<html>
<head>
<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Tangerine">
<style>
body {
font-family: 'Tangerine', serif;
font-size: 48px;
}
</style>
</head>
<body>
<h1>Making the Web Beautiful!</h1>
</body>
</html>
用法
只需要添加这段代码到你的HTML文件就行了。
<link rel=”stylesheet” type=”text/css” href=”http://fonts.googleapis.com/css?family=Reenie+Beanie”>
参数部分跟的是字体名字,有空格的用“+”替换,使用多个字体需要用“|”隔开每个字体的名称,还可以指定其它参数,比如粗体、斜体等,具体说明可以看这里
@font-face {
font-family: 'Tangerine';
font-style: normal;
font-weight: normal;
src: local('Tangerine'), url('http://themes.googleusercontent.com/font?kit=_jMq7r9ahcBZZjpP8hftNA') format('truetype');
}
WebFont
这是一段用来控制加载字体的JS,可以不用,但是用它可以更好地控制字体的行为,比如在字体加载完之前可以指定一个默认字体。详细情况在这里
目前支持的字体不多,在这里可以找到所有的字体列表,最要命的没有中文的:(
评论(0)