<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>刘钢 - 我是UED &#187; 特殊字体</title>
	<atom:link href="http://www.iamued.com/tag/%e7%89%b9%e6%ae%8a%e5%ad%97%e4%bd%93/feed" rel="self" type="application/rss+xml" />
	<link>http://www.iamued.com</link>
	<description>http://www.IamUED.com</description>
	<lastBuildDate>Tue, 07 Sep 2010 08:30:48 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>在网页中嵌入任意字体的解决方案</title>
		<link>http://www.iamued.com/qianduan/731.html</link>
		<comments>http://www.iamued.com/qianduan/731.html#comments</comments>
		<pubDate>Wed, 09 Dec 2009 22:46:23 +0000</pubDate>
		<dc:creator>RichieLiu</dc:creator>
				<category><![CDATA[前端开发]]></category>
		<category><![CDATA[页面实现]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[前端]]></category>
		<category><![CDATA[特殊字体]]></category>

		<guid isPermaLink="false">http://www.iamued.com/?p=731</guid>
		<description><![CDATA[字体使用是网页设计中不可或缺的一部分。经常地，我们希望在网页中使用某一特定字体，但是该字体并非主流操作系统的内置字体，这样用户在浏览页面的时候就有可能看不到真实的设计。美工设计师最常做的办法是把想要的文字做成图片，这样做有几个明显缺陷：1. 不可能大范围的使用该字体；2. 图片内容相对使用文字不易修改；3. 不利于网站SEO（主流搜索引擎不会将图片alt内容作为判断网页内容相关性的有效因素）。网络上有一些使用sIFR技术、或javascript/flash hack的方法，但实现起来或繁琐，或有缺陷。下面要讲的是如何只通过CSS的@font-face属性来实现在网页中嵌入任意字体。
查看Demo 下载案例
【第一步】
获取要使用字体的三种文件格式，确保能在主流浏览器中都能正常显示该字体。
.TTF或.OTF，适用于Firefox 3.5、Safari、Opera
.EOT，适用于Internet Explorer 4.0+
.SVG，适用于Chrome、IPhone

下面要解决的是如何获取到某种字体的这三种格式文件。一般地，我们在手头上（或在设计资源站点已经找到）有该字体的某种格式文件，最常见的是.TTF文件，我们需要通过这种文件格式转换为其余两种文件格式。字体文件格式的转换可以通过网站FontsQuirrel或onlinefontconverter提供的在线字体转换服务获取。这里推荐第一个站点，它允许我们选择需要的字符生成字体文件（在服务的最后一个选项），这样就大大缩减了字体文件的大小，使得本方案更具实用性。
【第二步】
获取到三种格式的字体文件后，下一步要在样式表中声明该字体，并在需要的地方使用该字体。
字体声明如下：

@font-face {
	font-family: 'fontNameRegular';
	src: url('fontName.eot');
	src: local('fontName Regular'),
              local('fontName'),
              url('fontName.woff') format('woff'),
             [...]]]></description>
			<content:encoded><![CDATA[<p>字体使用是网页设计中不可或缺的一部分。经常地，我们希望在网页中使用某一特定字体，但是该字体并非主流操作系统的内置字体，这样用户在浏览页面的时候就有可能看不到真实的设计。美工设计师最常做的办法是把想要的文字做成图片，这样做有几个明显缺陷：1. 不可能大范围的使用该字体；2. 图片内容相对使用文字不易修改；3. 不利于网站SEO（主流搜索引擎不会将图片alt内容作为判断网页内容相关性的有效因素）。网络上有一些使用sIFR技术、或javascript/flash hack的方法，但实现起来或繁琐，或有缺陷。下面要讲的是如何只通过CSS的@font-face属性来实现在网页中嵌入任意字体。<br />
<a href="http://www.iamued.com/demo/font-face-solution/" target="_blank">查看Demo</a> <a href="http://www.iamued.com/demo/font-face-solution/font-face-solution.rar">下载案例</a></p>
<p>【第一步】</p>
<p>获取要使用字体的三种文件格式，确保能在主流浏览器中都能正常显示该字体。</p>
<p>.TTF或.OTF，适用于Firefox 3.5、Safari、Opera<br />
.EOT，适用于Internet Explorer 4.0+<br />
.SVG，适用于Chrome、IPhone</p>
<p><span id="more-731"></span><br />
下面要解决的是如何获取到某种字体的这三种格式文件。一般地，我们在手头上（或在设计资源站点已经找到）有该字体的某种格式文件，最常见的是.TTF文件，我们需要通过这种文件格式转换为其余两种文件格式。字体文件格式的转换可以通过网站<a href="http://www.fontsquirrel.com/fontface/generator" target="_blank">FontsQuirrel</a>或<a href="http://onlinefontconverter.com/" target="_blank">onlinefontconverter</a>提供的在线字体转换服务获取。这里推荐第一个站点，它允许我们选择需要的字符生成字体文件（在服务的最后一个选项），这样就大大缩减了字体文件的大小，使得本方案更具实用性。</p>
<p>【第二步】</p>
<p>获取到三种格式的字体文件后，下一步要在样式表中声明该字体，并在需要的地方使用该字体。</p>
<p>字体声明如下：</p>
<pre class="brush: css;">
@font-face {
	font-family: 'fontNameRegular';
	src: url('fontName.eot');
	src: local('fontName Regular'),
              local('fontName'),
              url('fontName.woff') format('woff'),
              url('fontName.ttf') format('truetype'),
              url('fontName.svg#fontName') format('svg');
}
/*其中fontName替换为你的字体名称*/
</pre>
<p>在页面中需要的地方使用该字体：</p>
<pre class="brush: css;">
p { font: 13px fontNameRegular, Arial, sans-serif; }
    h1{font-family: fontNameRegular}
</pre>
<p>或者</p>
<pre class="brush: xml;">
&lt;p style=&quot;font-family: fontNameRegular&quot;&gt;掬水月在手，落花香满衣&lt;/p&gt;</pre>
<p><a href="http://www.iamued.com/demo/font-face-solution/" target="_blank">查看Demo</a><br />
<a href="http://www.iamued.com/demo/font-face-solution/font-face-solution.rar">下载案例</a></p>
<p>转自：http://css9.net/css-font-face-solution/</p>
<h2  class="related_post_title">您可能还关注的？</h2><ul class="related_post"><li><a href="http://www.iamued.com/qianduan/891.html" title="“床”结构的写法 未知高度的垂直居中">“床”结构的写法 未知高度的垂直居中</a></li><li><a href="http://www.iamued.com/qianduan/619.html" title="border:none;与border:0;的区别">border:none;与border:0;的区别</a></li><li><a href="http://www.iamued.com/qianduan/608.html" title="转：让我们一起讨论如何把简单的事做好">转：让我们一起讨论如何把简单的事做好</a></li><li><a href="http://www.iamued.com/qianduan/554.html" title="由黄钻等级图标处理引发的思考">由黄钻等级图标处理引发的思考</a></li><li><a href="http://www.iamued.com/qianduan/533.html" title="纯CSS图片预加载 ">纯CSS图片预加载 </a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.iamued.com/qianduan/731.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
