最近因为项目上需要用到这个字体图标,但是它里面的许多也不能完全满足项目需要,因此就考虑将这个图标导出,然后自己再添加一些其他图标使用
搜索了些解决方案,如:http://www.oschina.net/translate/how-to-convert-font-awesome-to-png-icons,但是上面的步骤过于简单,一个新手完全不会使用,比如Python自己就一点都没接触过,因此自己走了许多弯路。
本文一方面记录以便以后自己再次使用,最重要的是将我自己的每个步骤详细的展现给有需要的大家,希望对大家有帮助。
好 还请留个好评
本文涉及所有资源可以到我的百度云下载:
第一步 下载图标字体源文件:
包含以下文件:
第二步 安装python-2.7.9(我电脑是64位的,截图也是64位,实际上只能安装32位,64位图标处理库(第二部会安装以处理图片)找不到安装路径,安装过程是一样的)
第三步 安装图形处理库
安装完成后:菜单》全部程序》 Python 2.7发现已经安装成功
第四部 你下载文件里面有个 目录font-awesome-to-png 里面有将会使用的 脚本文件和字体文件(也是你第一步下载的文件)
来点其他参数
颜色变了,证明其他参数也是可靠的,大功告成。
源代码1 font-awesome-to-png.py:
#!/usr/bin/env python
#
# font-awesome-to-png.py
#
# Exports Font Awesome icons as PNG images.
#
# Copyright (c) 2012-2014 Michal Wojciechowski (http://odyniec.net/)
#
# Font Awesome - http://fortawesome.github.com/Font-Awesome
#
import sys, argparse, re
from os import path, access, R_OK
from PIL import Image, ImageFont, ImageDraw
# Support Unicode literals with both Python 2 and 3
if sys.version < '3':
import codecs
def u(x):
return codecs.unicode_escape_decode(x)[0]
def uchr(x):
return unichr(x)
else:
def u(x):
return x
def uchr(x):
return chr(x)
# Mapping of icon names to character codes
icons = {
"adjust": u("\uf042"),
"adn": u("\uf170"),
"align-center": u("\uf037"),
"align-justify": u("\uf039"),
"align-left": u("\uf036"),
"align-right": u("\uf038"),
"ambulance": u("\uf0f9"),
"anchor": u("\uf13d"),
"android": u("\uf17b"),
"angle-double-down": u("\uf103"),
"angle-double-left": u("\uf100"),
"angle-double-right": u("\uf101"),
"angle-double-up": u("\uf102"),
"angle-down": u("\uf107"),
"angle-left": u("\uf104"),
"angle-right": u("\uf105"),
"angle-up": u("\uf106"),
"apple": u("\uf179"),
"archive": u("\uf187"),
"arrow-circle-down": u("\uf0ab"),
"arrow-circle-left": u("\uf0a8"),
"arrow-circle-o-down": u("\uf01a"),
"arrow-circle-o-left": u("\uf190"),
"arrow-circle-o-right": u("\uf18e"),
"arrow-circle-o-up": u("\uf01b"),
"arrow-circle-right": u("\uf0a9"),
"arrow-circle-up": u("\uf0aa"),
"arrow-down": u("\uf063"),
"arrow-left": u("\uf060"),
"arrow-right": u("\uf061"),
"arrow-up": u("\uf062"),
"arrows": u("\uf047"),
"arrows-alt": u("\uf0b2"),
"arrows-h": u("\uf07e"),
"arrows-v": u("\uf07d"),
"asterisk": u("\uf069"),
"automobile": u("\uf1b9"),
"backward": u("\uf04a"),
"ban": u("\uf05e"),
"bank": u("\uf19c"),
"bar-chart-o": u("\uf080"),
"barcode": u("\uf02a"),
"bars": u("\uf0c9"),
"beer": u("\uf0fc"),
"behance": u("\uf1b4"),
"behance-square": u("\uf1b5"),
"bell": u("\uf0f3"),
"bell-o": u("\uf0a2"),
"bitbucket": u("\uf171"),
"bitbucket-square": u("\uf172"),
"bitcoin": u("\uf15a"),
"bold": u("\uf032"),
"bolt": u("\uf0e7"),
"bomb": u("\uf1e2"),
"book": u("\uf02d"),
"bookmark": u("\uf02e"),
"bookmark-o": u("\uf097"),
"briefcase": u("\uf0b1"),
"btc": u("\uf15a"),
"bug": u("\uf188"),
"building": u("\uf1ad"),
"building-o": u("\uf0f7"),
"bullhorn": u("\uf0a1"),
"bullseye": u("\uf140"),
"cab": u("\uf1ba"),
"calendar": u(&#