<?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>Frontend | Easton Man's Blog</title>
	<atom:link href="https://blog.eastonman.com/blog/tag/frontend/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.eastonman.com</link>
	<description>临渊羡鱼，不如退而结网</description>
	<lastBuildDate>Sun, 16 Aug 2020 11:53:46 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.5</generator>

<image>
	<url>https://blog.eastonman.com/wp-content/uploads/2021/02/cropped-Logo-e1613298891313-32x32.png</url>
	<title>Frontend | Easton Man's Blog</title>
	<link>https://blog.eastonman.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>FontCustom生成font-face字体图标</title>
		<link>https://blog.eastonman.com/blog/2018/02/fontcustomsheng-cheng-font-facezi-ti-tu-biao/</link>
					<comments>https://blog.eastonman.com/blog/2018/02/fontcustomsheng-cheng-font-facezi-ti-tu-biao/#respond</comments>
		
		<dc:creator><![CDATA[Easton Man]]></dc:creator>
		<pubDate>Fri, 09 Feb 2018 02:59:00 +0000</pubDate>
				<category><![CDATA[未分类]]></category>
		<category><![CDATA[Frontend]]></category>
		<guid isPermaLink="false">https://blog.eastonman.com/2018/02/09/fontcustomsheng-cheng-font-facezi-ti-tu-biao/</guid>

					<description><![CDATA[<p>预计阅读时间： 2 分钟这几天把页面底部的sns图标加进New Material主题，发现原作者是直接用png [&#8230;]</p>
The post <a href="https://blog.eastonman.com/blog/2018/02/fontcustomsheng-cheng-font-facezi-ti-tu-biao/">FontCustom生成font-face字体图标</a> first appeared on <a href="https://blog.eastonman.com">Easton Man's Blog</a>.]]></description>
										<content:encoded><![CDATA[<p class="wpwc-reading-time">预计阅读时间： 2 分钟</p><p>这几天把页面底部的sns图标加进New Material主题，发现原作者是直接用png做 <code>&lt;button&gt;</code> 的背景图，这样的话有几个缺点，一是png放大了一以后会不清楚（虽然改用svg也能解决），二是要写太多自定义的css了，可移植性差，这也是最主要的一点（我懒，嘻嘻嘻），还有就是html里标签又div又a又button又span的，可读性也差。作为一个完美主义者，我怎么能容忍这样的结构呢，于是我果断加入@font-face方式的图标。</p>
<h1 id="-font-face-">什么是font-face字体图标</h1>
<p>unicode编码（也叫utf-8）除了正常的字符以外，<code>\e000</code> 开始的一段是空的，也就是留给自造字用。如果把图标放到这一段呢？这就是字体图标的原理，字体在css里类是@font-face，所以又叫font-face图标。</p>
<h1 id="fontcustom">Fontcustom</h1>
<p>说了那么多，到底Fontcustom是什么呢？</p>
<p><a href="https://github.com/fontcustom/fontcustom">Fontcustom Github</a></p>
<p>Fontcustom是一个基于rubygems的工具，帮助个位开发者把svg图片转成@font-face需要的字体格式，也生成好所需的css，要用时只需外链一个css就可以了。</p>
<h1 id="-fontcustom">安装fontcustom</h1>
<h2 id="-rubygems">安装rubygems</h2>
<p>其实主要麻烦之处在于rubygems的安装，除了有一些坑以外，别的应该没有什么难度</p>
<p>ubuntu 16.04</p>
<pre><code>apt install ruby ruby-dev 
</code></pre>
<p>ubuntu 14.04</p>
<pre><code>apt install ruby rubygems
</code></pre>
<h2 id="-fontcustom-1">安装Fontcustom</h2>
<p>Fontcustom要求安装好 Ruby 1.9.3+, WOFF2, FontForge</p>
<p>安装依赖</p>
<pre><code># On Mac
brew tap bramstein/webfonttools
brew update
brew install woff2

brew install fontforge --with-python
brew install eot-utils
gem install fontcustom

# On Linux
sudo apt-get install zlib1g-dev fontforge
git clone https://github.com/bramstein/sfnt2woff-zopfli.git sfnt2woff-zopfli &amp;&amp; cd sfnt2woff-zopfli &amp;&amp; make &amp;&amp; mv sfnt2woff-zopfli /usr/local/bin/sfnt2woff
git clone --recursive https://github.com/google/woff2.git &amp;&amp; cd woff2 &amp;&amp; make clean all &amp;&amp; sudo mv woff2_compress /usr/local/bin/ &amp;&amp; sudo mv woff2_decompress /usr/local/bin
</code></pre>
<p>安装fontcustom</p>
<pre><code>gem install fontcustom
</code></pre>
<p>大功告成！<br />安装过程可能出现<br />gems报错<br />Cannot Compile Extension ffi<br />或者之类的</p>
<p>这是由于apt安装的rubygems要自行编译所有extension</p>
<p>安装libffi就可以了</p>
<pre><code>apt install libffi-dev
</code></pre>
<h1 id="fontcustom-">Fontcustom 简单使用</h1>
<pre><code>fontcustom compile my/vectors  # 生成到 `fontcustom/`
fontcustom watch my/vectors    # 监视my/vectors的文件改变，即时生成
fontcustom compile             # 使用默认的配置文件 ./fontcustom.yml
fontcustom config              # 生成空白的配置文件
fontcustom help                # 查看所有用法
</code></pre>
<p>啊哈！简直太方便了</p>The post <a href="https://blog.eastonman.com/blog/2018/02/fontcustomsheng-cheng-font-facezi-ti-tu-biao/">FontCustom生成font-face字体图标</a> first appeared on <a href="https://blog.eastonman.com">Easton Man's Blog</a>.]]></content:encoded>
					
					<wfw:commentRss>https://blog.eastonman.com/blog/2018/02/fontcustomsheng-cheng-font-facezi-ti-tu-biao/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
